#include "stdinc.h"
#include "channel.h"
+#include "chmode.h"
#include "client.h"
#include "common.h"
#include "hash.h"
#include "s_newconf.h"
#include "logger.h"
+struct config_channel_entry ConfigChannel;
+rb_dlink_list global_channel_list;
static rb_bh *channel_heap;
static rb_bh *ban_heap;
static rb_bh *topic_heap;
free_channel(struct Channel *chptr)
{
rb_free(chptr->chname);
+ rb_free(chptr->mode_lock);
rb_bh_free(channel_heap, chptr);
}
if(client_p->servptr == &me)
rb_dlinkDelete(&msptr->locchannode, &chptr->locmembers);
- chptr->users_last = rb_current_time();
-
if(!(chptr->mode.mode & MODE_PERMANENT) && rb_dlink_list_length(&chptr->members) <= 0)
destroy_channel(chptr);
if(client_p->servptr == &me)
rb_dlinkDelete(&msptr->locchannode, &chptr->locmembers);
- chptr->users_last = rb_current_time();
-
if(!(chptr->mode.mode & MODE_PERMANENT) && rb_dlink_list_length(&chptr->members) <= 0)
destroy_channel(chptr);
* input - client to check, channel to check for, key
* output - reason for not being able to join, else 0
* side effects -
+ * caveats - this function should only be called on a local user.
*/
int
can_join(struct Client *source_p, struct Channel *chptr, char *key)
source_p->localClient->oper_warn_count_down--;
else
source_p->localClient->oper_warn_count_down = 0;
- if(source_p->localClient->oper_warn_count_down == 0)
+ if(source_p->localClient->oper_warn_count_down == 0 &&
+ name != NULL)
{
/* Its already known as a possible spambot */
- if(name != NULL)
- sendto_realops_snomask(SNO_BOTS, L_NETWIDE,
- "User %s (%s@%s) trying to join %s is a possible spambot",
- source_p->name,
- source_p->username, source_p->orighost, name);
- else
- sendto_realops_snomask(SNO_BOTS, L_NETWIDE,
- "User %s (%s@%s) is a possible spambot",
- source_p->name,
- source_p->username, source_p->orighost);
+ sendto_realops_snomask(SNO_BOTS, L_NETWIDE,
+ "User %s (%s@%s) trying to join %s is a possible spambot",
+ source_p->name,
+ source_p->username, source_p->orighost, name);
source_p->localClient->oper_warn_count_down = OPER_SPAM_COUNTDOWN;
}
}
JOIN_LEAVE_COUNT_EXPIRE_TIME)
{
decrement_count = (t_delta / JOIN_LEAVE_COUNT_EXPIRE_TIME);
- if(decrement_count > source_p->localClient->join_leave_count)
+ if(name != NULL)
+ ;
+ else if(decrement_count > source_p->localClient->join_leave_count)
source_p->localClient->join_leave_count = 0;
else
source_p->localClient->join_leave_count -= decrement_count;
"Network rejoined, deactivating splitmode");
rb_event_delete(check_splitmode_ev);
+ check_splitmode_ev = NULL;
}
}
}
sendto_server(client_p, chptr, cap, nocap, "%s %s", modebuf, parabuf);
}
}
+
+void
+resv_chan_forcepart(const char *name, const char *reason, int temp_time)
+{
+ rb_dlink_node *ptr;
+ rb_dlink_node *next_ptr;
+ struct Channel *chptr;
+ struct membership *msptr;
+ struct Client *target_p;
+
+ if(!ConfigChannel.resv_forcepart)
+ return;
+
+ /* for each user on our server in the channel list
+ * send them a PART, and notify opers.
+ */
+ chptr = find_channel(name);
+ if(chptr != NULL)
+ {
+ RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->locmembers.head)
+ {
+ msptr = ptr->data;
+ target_p = msptr->client_p;
+
+ if(IsExemptResv(target_p))
+ continue;
+
+ sendto_server(target_p, chptr, CAP_TS6, NOCAPS,
+ ":%s PART %s", target_p->id, chptr->chname);
+
+ sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s :%s",
+ target_p->name, target_p->username,
+ target_p->host, chptr->chname, target_p->name);
+
+ remove_user_from_channel(msptr);
+
+ /* notify opers & user they were removed from the channel */
+ sendto_realops_snomask(SNO_GENERAL, L_ALL,
+ "Forced PART for %s!%s@%s from %s (%s)",
+ target_p->name, target_p->username,
+ target_p->host, name, reason);
+
+ if(temp_time > 0)
+ sendto_one_notice(target_p, ":*** Channel %s is temporarily unavailable on this server.",
+ name);
+ else
+ sendto_one_notice(target_p, ":*** Channel %s is no longer available on this server.",
+ name);
+ }
+ }
+}