31 |
|
#include "client.h" |
32 |
|
#include "common.h" |
33 |
|
#include "hash.h" |
34 |
+ |
#include "hostmask.h" |
35 |
|
#include "irc_string.h" |
36 |
|
#include "sprintf_irc.h" |
37 |
|
#include "ircd.h" |
191 |
|
if (ms->flags & CHFL_CHANOP) |
192 |
|
tlen++; |
193 |
|
#ifdef HALFOPS |
194 |
< |
if (ms->flags & CHFL_HALFOP) |
194 |
> |
else if (ms->flags & CHFL_HALFOP) |
195 |
|
tlen++; |
196 |
|
#endif |
197 |
|
if (ms->flags & CHFL_VOICE) |
207 |
|
t = start; |
208 |
|
} |
209 |
|
|
210 |
< |
strcpy(t, get_member_status(ms, YES)); |
211 |
< |
t += strlen(t); |
210 |
> |
if ((ms->flags & (CHFL_CHANOP | CHFL_HALFOP))) |
211 |
> |
*t++ = (!(ms->flags & CHFL_CHANOP) && IsCapable(client_p, CAP_HOPS)) ? |
212 |
> |
'%' : '@'; |
213 |
> |
if ((ms->flags & CHFL_VOICE)) |
214 |
> |
*t++ = '+'; |
215 |
|
|
216 |
|
if (IsCapable(client_p, CAP_TS6)) |
217 |
|
strcpy(t, ID(ms->client_p)); |
532 |
|
/* |
533 |
|
* delete last link in chain if the list is max length |
534 |
|
*/ |
535 |
< |
if (dlink_list_length(&who->invited) >= |
535 |
> |
if (dlink_list_length(&who->localClient->invited) >= |
536 |
|
ConfigChannel.max_chans_per_user) |
537 |
< |
del_invite(who->invited.tail->data, who); |
537 |
> |
del_invite(who->localClient->invited.tail->data, who); |
538 |
|
|
539 |
|
/* add client to channel invite list */ |
540 |
|
dlinkAdd(who, make_dlink_node(), &chptr->invites); |
541 |
|
|
542 |
|
/* add channel to the end of the client invite list */ |
543 |
< |
dlinkAdd(chptr, make_dlink_node(), &who->invited); |
543 |
> |
dlinkAdd(chptr, make_dlink_node(), &who->localClient->invited); |
544 |
|
} |
545 |
|
|
546 |
|
/*! \brief Delete Invite block from channel invite list |
553 |
|
{ |
554 |
|
dlink_node *ptr = NULL; |
555 |
|
|
556 |
< |
if ((ptr = dlinkFindDelete(&who->invited, chptr))) |
556 |
> |
if ((ptr = dlinkFindDelete(&who->localClient->invited, chptr))) |
557 |
|
free_dlink_node(ptr); |
558 |
|
|
559 |
|
if ((ptr = dlinkFindDelete(&chptr->invites, who))) |
617 |
|
|
618 |
|
DLINK_FOREACH(ptr, list->head) |
619 |
|
{ |
620 |
< |
const struct Ban *bp = ptr->data; |
620 |
> |
struct Ban *bp = ptr->data; |
621 |
|
|
622 |
< |
if (match(bp->name, who->name) && |
623 |
< |
match(bp->username, who->username) && |
624 |
< |
(match(bp->host, who->host) || |
625 |
< |
match(bp->host, who->sockhost) || |
626 |
< |
match_cidr(bp->host, who->sockhost))) |
627 |
< |
return 1; |
622 |
> |
if (match(bp->name, who->name) && match(bp->username, who->username)) |
623 |
> |
{ |
624 |
> |
switch (bp->type) |
625 |
> |
{ |
626 |
> |
case HM_HOST: |
627 |
> |
if (match(bp->host, who->host) || match(bp->host, who->sockhost)) |
628 |
> |
return 1; |
629 |
> |
break; |
630 |
> |
case HM_IPV4: |
631 |
> |
if (who->localClient->aftype == AF_INET) |
632 |
> |
if (match_ipv4(&who->localClient->ip, &bp->addr, bp->bits)) |
633 |
> |
return 1; |
634 |
> |
break; |
635 |
> |
#ifdef IPV6 |
636 |
> |
case HM_IPV6: |
637 |
> |
if (who->localClient->aftype == AF_INET6) |
638 |
> |
if (match_ipv6(&who->localClient->ip, &bp->addr, bp->bits)) |
639 |
> |
return 1; |
640 |
> |
break; |
641 |
> |
#endif |
642 |
> |
default: |
643 |
> |
assert(0); |
644 |
> |
} |
645 |
> |
} |
646 |
|
} |
647 |
|
|
648 |
|
return 0; |
677 |
|
return ERR_BANNEDFROMCHAN; |
678 |
|
|
679 |
|
if (chptr->mode.mode & MODE_INVITEONLY) |
680 |
< |
if (!dlinkFind(&source_p->invited, chptr)) |
680 |
> |
if (!dlinkFind(&source_p->localClient->invited, chptr)) |
681 |
|
if (!ConfigChannel.use_invex || !find_bmask(source_p, &chptr->invexlist)) |
682 |
|
return ERR_INVITEONLYCHAN; |
683 |
|
|
717 |
|
/*! |
718 |
|
* \param chptr pointer to Channel struct |
719 |
|
* \param source_p pointer to Client struct |
720 |
+ |
* \param ms pointer to Membership struct (can be NULL) |
721 |
|
* \return CAN_SEND_OPV if op or voiced on channel\n |
722 |
|
* CAN_SEND_NONOP if can send to channel but is not an op\n |
723 |
|
* CAN_SEND_NO if they cannot send to channel\n |
724 |
|
*/ |
725 |
|
int |
726 |
< |
can_send(struct Channel *chptr, struct Client *source_p) |
726 |
> |
can_send(struct Channel *chptr, struct Client *source_p, struct Membership *ms) |
727 |
|
{ |
705 |
– |
struct Membership *ms = NULL; |
706 |
– |
|
728 |
|
if (IsServer(source_p)) |
729 |
|
return CAN_SEND_OPV; |
730 |
|
|
733 |
|
(!hash_find_resv(chptr->chname) == ConfigChannel.restrict_channels)) |
734 |
|
return CAN_SEND_NO; |
735 |
|
|
736 |
< |
if ((ms = find_channel_link(source_p, chptr)) == NULL) |
716 |
< |
{ |
717 |
< |
if (chptr->mode.mode & MODE_NOPRIVMSGS) |
718 |
< |
return CAN_SEND_NO; |
719 |
< |
} |
720 |
< |
else |
736 |
> |
if (ms != NULL || (ms = find_channel_link(source_p, chptr))) |
737 |
|
{ |
738 |
|
if (ms->flags & (CHFL_CHANOP|CHFL_HALFOP|CHFL_VOICE)) |
739 |
|
return CAN_SEND_OPV; |
756 |
|
} |
757 |
|
} |
758 |
|
} |
759 |
< |
|
744 |
< |
if (chptr->mode.mode & MODE_MODERATED) |
759 |
> |
else if (chptr->mode.mode & MODE_NOPRIVMSGS) |
760 |
|
return CAN_SEND_NO; |
761 |
|
|
747 |
– |
return CAN_SEND_NONOP; |
748 |
– |
} |
749 |
– |
|
750 |
– |
/*! \brief Checks to see if given client can send a part message |
751 |
– |
* \param member pointer to channel membership |
752 |
– |
* \param chptr pointer to channel struct |
753 |
– |
* \param source_p pointer to struct Client to check |
754 |
– |
*/ |
755 |
– |
int |
756 |
– |
can_send_part(struct Membership *member, struct Channel *chptr, |
757 |
– |
struct Client *source_p) |
758 |
– |
{ |
759 |
– |
if (has_member_flags(member, CHFL_CHANOP|CHFL_HALFOP)) |
760 |
– |
return CAN_SEND_OPV; |
761 |
– |
|
762 |
|
if (chptr->mode.mode & MODE_MODERATED) |
763 |
|
return CAN_SEND_NO; |
764 |
|
|
765 |
– |
if (ConfigChannel.quiet_on_ban && MyClient(source_p) && |
766 |
– |
is_banned(chptr, source_p)) |
767 |
– |
return CAN_SEND_NO; |
768 |
– |
|
765 |
|
return CAN_SEND_NONOP; |
766 |
|
} |
767 |
|
|
922 |
|
} |
923 |
|
else |
924 |
|
{ |
925 |
+ |
/* |
926 |
+ |
* Do not reset chptr->topic_time here, it's required for |
927 |
+ |
* bursting topics properly. |
928 |
+ |
*/ |
929 |
|
if (chptr->topic != NULL) |
930 |
|
free_topic(chptr); |
931 |
– |
|
932 |
– |
chptr->topic_time = 0; |
931 |
|
} |
932 |
|
} |
935 |
– |
|