|
@@ -132,16 +132,16 @@ static void cmd_setkey(int idx, char *par) {
|
|
|
putlog(LOG_CMDS, "*", "#%s# setkey %s", dcc[idx].nick, par);
|
|
putlog(LOG_CMDS, "*", "#%s# setkey %s", dcc[idx].nick, par);
|
|
|
|
|
|
|
|
if (!par[0]) {
|
|
if (!par[0]) {
|
|
|
- dprintf(idx, "Usage: setkey <nick|channel> [key]\n");
|
|
|
|
|
|
|
+ dprintf(idx, "Usage: setkey <nick|channel> [key|rand]\n");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
char *target = newsplit(&par);
|
|
char *target = newsplit(&par);
|
|
|
- char *key = newsplit(&par);
|
|
|
|
|
|
|
+ char *newkey = newsplit(&par);
|
|
|
bool have_key = FishKeys.contains(target);
|
|
bool have_key = FishKeys.contains(target);
|
|
|
fish_data_t* fishData = NULL;
|
|
fish_data_t* fishData = NULL;
|
|
|
|
|
|
|
|
- if (!key[0]) {
|
|
|
|
|
|
|
+ if (!newkey[0]) {
|
|
|
// Clear the key
|
|
// Clear the key
|
|
|
if (have_key) {
|
|
if (have_key) {
|
|
|
fishData = FishKeys[target];
|
|
fishData = FishKeys[target];
|
|
@@ -152,12 +152,23 @@ static void cmd_setkey(int idx, char *par) {
|
|
|
dprintf(idx, "No key found for '%s'\n", target);
|
|
dprintf(idx, "No key found for '%s'\n", target);
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- // Set the key
|
|
|
|
|
|
|
+ // Set a new key
|
|
|
fishData = new fish_data_t;
|
|
fishData = new fish_data_t;
|
|
|
- fishData->sharedKey = key;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (!strcmp(newkey, "rand")) {
|
|
|
|
|
+ // Set a RANDOM key
|
|
|
|
|
+ rand_key = (char*)my_calloc(1, 32+1);
|
|
|
|
|
+ make_rand_str(rand_key, 32);
|
|
|
|
|
+ fishData->sharedKey = rand_key;
|
|
|
|
|
+ free(rand_key);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ fishData->sharedKey = newkey;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Set the key
|
|
|
fishData->timestamp = now;
|
|
fishData->timestamp = now;
|
|
|
FishKeys[target] = fishData;
|
|
FishKeys[target] = fishData;
|
|
|
- dprintf(idx, "Set key for '%s' to: %s", target, key);
|
|
|
|
|
|
|
+ dprintf(idx, "Set key for '%s' to: %s", target, fishData->sharedKey);
|
|
|
}
|
|
}
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|