X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodes%2Fcmode_k.cpp;h=fd5808b739b3e2b3c94a9d32a812fea308795b12;hb=c5077c1c908ffb5581b8c54253d63ea6b38c0be0;hp=8e00f96f7059229e6645e0d10d336790b74d1bf4;hpb=f9636a2eff46f6829bf9e01c711ab1ba45a7d50a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modes/cmode_k.cpp b/src/modes/cmode_k.cpp index 8e00f96f7..fd5808b73 100644 --- a/src/modes/cmode_k.cpp +++ b/src/modes/cmode_k.cpp @@ -18,7 +18,32 @@ ModePair ModeChannelKey::ModeSet(userrec* source, userrec* dest, chanrec* channe { return std::make_pair(false, parameter); } -} +} + +void ModeChannelKey::RemoveMode(chanrec* channel) +{ + /** +k needs a parameter when being removed, + * so we have a special-case RemoveMode here for it + */ + char moderemove[MAXBUF]; + const char* parameters[] = { channel->name, moderemove, channel->key }; + + if (channel->IsModeSet(this->GetModeChar())) + { + userrec* n = new userrec(ServerInstance); + + sprintf(moderemove,"-%c",this->GetModeChar()); + n->SetFd(FD_MAGIC_NUMBER); + + ServerInstance->SendMode(parameters, 3, n); + + delete n; + } +} + +void ModeChannelKey::RemoveMode(userrec* user) +{ +} bool ModeChannelKey::CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, chanrec* channel) { @@ -33,15 +58,19 @@ ModeAction ModeChannelKey::OnModeChange(userrec* source, userrec* dest, chanrec* if (((channel->modes[CM_KEY]) && (strcasecmp(parameter.c_str(),channel->key))) && (IS_LOCAL(source))) { /* Key is currently set and the correct key wasnt given */ - log(DEBUG,"Key Cond 2"); return MODEACTION_DENY; } else if ((!channel->modes[CM_KEY]) || ((adding) && (!IS_LOCAL(source)))) { /* Key isnt currently set */ - strlcpy(channel->key,parameter.c_str(),32); - channel->modes[CM_KEY] = adding; - return MODEACTION_ALLOW; + if ((parameter.length()) && (parameter.length() < 32) && (parameter.rfind(' ') == std::string::npos)) + { + strlcpy(channel->key,parameter.c_str(),32); + channel->modes[CM_KEY] = adding; + return MODEACTION_ALLOW; + } + else + return MODEACTION_DENY; } else if (((channel->modes[CM_KEY]) && (!strcasecmp(parameter.c_str(),channel->key))) || ((!adding) && (!IS_LOCAL(source)))) { @@ -50,12 +79,11 @@ ModeAction ModeChannelKey::OnModeChange(userrec* source, userrec* dest, chanrec* channel->modes[CM_KEY] = adding; return MODEACTION_ALLOW; } - log(DEBUG,"Key Cond three"); return MODEACTION_DENY; } else { - log(DEBUG,"Key Condition one"); return MODEACTION_DENY; } } +