diff options
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | include/channel.h | 39 | ||||
-rw-r--r-- | include/client.h | 340 | ||||
-rw-r--r-- | include/conf.h | 162 | ||||
-rw-r--r-- | include/hash.h | 5 | ||||
-rw-r--r-- | include/ircd.h | 10 | ||||
-rw-r--r-- | include/listener.h | 2 | ||||
-rw-r--r-- | include/packet.h | 5 | ||||
-rw-r--r-- | include/s_auth.h | 26 | ||||
-rw-r--r-- | include/s_gline.h | 5 | ||||
-rw-r--r-- | include/send.h | 50 | ||||
-rw-r--r-- | src/channel.c | 2 | ||||
-rw-r--r-- | src/client.c | 4 | ||||
-rw-r--r-- | src/hash.c | 2 | ||||
-rw-r--r-- | src/ircd.c | 26 | ||||
-rw-r--r-- | src/listener.c | 4 | ||||
-rw-r--r-- | src/packet.c | 18 | ||||
-rw-r--r-- | src/s_auth.c | 4 | ||||
-rw-r--r-- | src/send.c | 20 |
19 files changed, 329 insertions, 400 deletions
@@ -1,12 +1,13 @@ -- ircd-hybrid-8.1.0beta1 Release Notes o) Improved WEBIRC authentication; added 'webirc' to auth::flags. A "webirc." spoof is now no longer required -o) Implemented new memory pool allocator which basically is taken from Tor's +o) Implemented new memory pool allocator which basically is based upon Tor's mempool allocator for Tor cells o) Major code cleanups -o) Implemented new binary database storage for X-,D-,K-,G-Lines and RESVs +o) Implemented new binary database storage for X-,D-,K-,G-Lines and RESVs. Temporary bans are now stored as well and will persist after a reboot + -- ircd-hybrid-8.0.7 Release Notes o) Added SVSHOST command handler which allows services to change the hostname of a specific user diff --git a/include/channel.h b/include/channel.h index bf7b9ad..a922715 100644 --- a/include/channel.h +++ b/include/channel.h @@ -29,6 +29,24 @@ #include "ircd_defs.h" /* KEYLEN, CHANNELLEN */ +/* channel visible */ +#define ShowChannel(v,c) (PubChannel(c) || IsMember((v),(c))) + +#define IsMember(who, chan) ((find_channel_link(who, chan)) ? 1 : 0) +#define AddMemberFlag(x, y) ((x)->flags |= (y)) +#define DelMemberFlag(x, y) ((x)->flags &= ~(y)) + +#define FLOOD_NOTICED 1 +#define JOIN_FLOOD_NOTICED 2 + +#define SetFloodNoticed(x) ((x)->flags |= FLOOD_NOTICED) +#define IsSetFloodNoticed(x) ((x)->flags & FLOOD_NOTICED) +#define ClearFloodNoticed(x) ((x)->flags &= ~FLOOD_NOTICED) + +#define SetJoinFloodNoticed(x) ((x)->flags |= JOIN_FLOOD_NOTICED) +#define IsSetJoinFloodNoticed(x) ((x)->flags & JOIN_FLOOD_NOTICED) +#define ClearJoinFloodNoticed(x) ((x)->flags &= ~JOIN_FLOOD_NOTICED) + struct Client; /*! \brief Mode structure for channels */ @@ -103,7 +121,7 @@ extern int can_join(struct Client *, struct Channel *, const char *); extern int has_member_flags(struct Membership *, unsigned int); extern void remove_ban(struct Ban *, dlink_list *); -extern void init_channels(void); +extern void channel_init(void); extern void add_user_to_channel(struct Channel *, struct Client *, unsigned int, int); extern void remove_user_from_channel(struct Membership *); @@ -122,23 +140,4 @@ extern const char *get_member_status(const struct Membership *, int); extern struct Channel *make_channel(const char *); extern struct Membership *find_channel_link(struct Client *, struct Channel *); - -/* channel visible */ -#define ShowChannel(v,c) (PubChannel(c) || IsMember((v),(c))) - -#define IsMember(who, chan) ((find_channel_link(who, chan)) ? 1 : 0) -#define AddMemberFlag(x, y) ((x)->flags |= (y)) -#define DelMemberFlag(x, y) ((x)->flags &= ~(y)) - -#define FLOOD_NOTICED 1 -#define JOIN_FLOOD_NOTICED 2 - -#define SetFloodNoticed(x) ((x)->flags |= FLOOD_NOTICED) -#define IsSetFloodNoticed(x) ((x)->flags & FLOOD_NOTICED) -#define ClearFloodNoticed(x) ((x)->flags &= ~FLOOD_NOTICED) - -#define SetJoinFloodNoticed(x) ((x)->flags |= JOIN_FLOOD_NOTICED) -#define IsSetJoinFloodNoticed(x) ((x)->flags & JOIN_FLOOD_NOTICED) -#define ClearJoinFloodNoticed(x) ((x)->flags &= ~JOIN_FLOOD_NOTICED) - #endif /* INCLUDED_channel_h */ diff --git a/include/client.h b/include/client.h index 5c94a0f..ed8ddb4 100644 --- a/include/client.h +++ b/include/client.h @@ -35,176 +35,6 @@ #include "dbuf.h" #include "channel.h" - -/*! \brief addr_mask_type enumeration */ -enum addr_mask_type -{ - HIDE_IP, /**< IP is hidden. Resolved hostname is shown instead */ - SHOW_IP, /**< IP is shown. No parts of it are hidden or masked */ - MASK_IP /**< IP is masked. 255.255.255.255 is shown instead */ -}; - -/*! \brief Server structure */ -struct Server -{ - dlink_list server_list; /**< Servers on this server */ - dlink_list client_list; /**< Clients on this server */ - char by[NICKLEN + 1]; /**< who activated this connection */ -}; - -/*! \brief ListTask structure */ -struct ListTask -{ - dlink_list show_mask; /**< show these channels.. */ - dlink_list hide_mask; /**< ..and hide these ones */ - - unsigned int hash_index; /**< the bucket we are currently in */ - unsigned int users_min; - unsigned int users_max; - unsigned int created_min; - unsigned int created_max; - unsigned int topicts_min; - unsigned int topicts_max; -}; - -/*! \brief LocalUser structure - * - * Allocated only for local clients, that are directly connected - * to \b this server with a socket. - */ -struct LocalUser -{ - dlink_node lclient_node; - - char client_host[HOSTLEN + 1]; - char client_server[HOSTLEN + 1]; - - unsigned int registration; - unsigned int cap_client; /**< Client capabilities (from us) */ - unsigned int cap_active; /**< Active capabilities (to us) */ - unsigned int caps; /**< capabilities bit-field */ - - unsigned int operflags; /**< IRC Operator privilege flags */ - unsigned int random_ping; /**< Holding a 32bit value used for PING cookies */ - - unsigned int serial; /**< used to enforce 1 send per nick */ - - time_t lasttime; /**< ...should be only LOCAL clients? --msa */ - time_t firsttime; /**< time client was created */ - time_t since; /**< last time we parsed something */ - time_t last_knock; /**< time of last knock */ - time_t last_join_time; /**< when this client last - joined a channel */ - time_t last_leave_time; /**< when this client last - * left a channel */ - int join_leave_count; /**< count of JOIN/LEAVE in less than - MIN_JOIN_LEAVE_TIME seconds */ - int oper_warn_count_down; /**< warn opers of this possible - spambot every time this gets to 0 */ - time_t last_caller_id_time; - time_t first_received_message_time; - time_t last_nick_change; - time_t last_privmsg; /**< Last time we got a PRIVMSG */ - time_t last_away; /**< Away since... */ - - int received_number_of_privmsgs; - unsigned int number_of_nick_changes; - - struct ListTask *list_task; - - struct dbuf_queue buf_sendq; - struct dbuf_queue buf_recvq; - - struct { - unsigned int messages; /**< Statistics: protocol messages sent/received */ - uint64_t bytes; /**< Statistics: total bytes sent/received */ - } recv, send; - - struct AuthRequest *auth; - struct Listener *listener; /**< listener accepted from */ - dlink_list acceptlist; /**< clients I'll allow to talk to me */ - dlink_list watches; /**< chain of Watch pointer blocks */ - dlink_list confs; /**< Configuration record associated */ - dlink_list invited; /**< chain of invite pointer blocks */ - struct irc_ssaddr ip; - int aftype; /**< Makes life easier for DNS res in IPV6 */ - - char *passwd; - fde_t fd; - - /* Anti-flood stuff. We track how many messages were parsed and how - * many we were allowed in the current second, and apply a simple - * decay to avoid flooding. - * -- adrian - */ - int allow_read; /**< how many we're allowed to read in this second */ - int sent_parsed; /**< how many messages we've parsed in this second */ - - char* response; /**< expected response from client */ - char* auth_oper; /**< Operator to become if they supply the response.*/ -}; - -/*! \brief Client structure */ -struct Client -{ - dlink_node node; - dlink_node lnode; /**< Used for Server->servers/users */ - - struct LocalUser *localClient; - struct Client *hnext; /**< For client hash table lookups by name */ - struct Client *idhnext; /**< For SID hash table lookups by sid */ - struct Server *serv; /**< ...defined, if this is a server */ - struct Client *servptr; /**< Points to server this Client is on */ - struct Client *from; /**< == self, if Local Client, *NEVER* NULL! */ - - time_t tsinfo; /**< TS on the nick, SVINFO on server */ - - unsigned int flags; /**< client flags */ - unsigned int umodes; /**< opers, normal users subset */ - unsigned int hopcount; /**< number of servers to this 0 = local */ - unsigned int status; /**< Client type */ - unsigned int handler; /**< Handler index */ - - dlink_list whowas; - dlink_list channel; /**< chain of channel pointer blocks */ - - char away[AWAYLEN + 1]; /**< Client's AWAY message. Can be set/unset via AWAY command */ - char name[HOSTLEN + 1]; /**< unique name for a client nick or host */ - char svid[HOSTLEN + 1]; /**< Services ID. XXX: Going with HOSTLEN for now. NICKLEN might be too small - if dealing with timestamps */ - char id[IDLEN + 1]; /**< client ID, unique ID per client */ - /* - * client->username is the username from ident or the USER message, - * If the client is idented the USER message is ignored, otherwise - * the username part of the USER message is put here prefixed with a - * tilde depending on the auth{} block. Once a client has registered, - * this field should be considered read-only. - */ - char username[USERLEN + 1]; /* client's username */ - - /* - * client->host contains the resolved name or ip address - * as a string for the user, it may be fiddled with for oper spoofing etc. - * once it's changed the *real* address goes away. This should be - * considered a read-only field after the client has registered. - */ - char host[HOSTLEN + 1]; /* client's hostname */ - - /* - * client->info for unix clients will normally contain the info from the - * gcos field in /etc/passwd but anything can go here. - */ - char info[REALLEN + 1]; /* Free form additional client info */ - - /* - * client->sockhost contains the ip address gotten from the socket as a - * string, this field should be considered read-only once the connection - * has been made. (set in s_bsd.c only) - */ - char sockhost[HOSTIPLEN + 1]; /* This is the host name from the - socket ip address as string */ -}; - /* * status macros. */ @@ -434,6 +264,174 @@ struct Client #define ClearSendqBlocked(x) ((x)->flags &= ~FLAGS_BLOCKED) +/*! \brief addr_mask_type enumeration */ +enum addr_mask_type +{ + HIDE_IP, /**< IP is hidden. Resolved hostname is shown instead */ + SHOW_IP, /**< IP is shown. No parts of it are hidden or masked */ + MASK_IP /**< IP is masked. 255.255.255.255 is shown instead */ +}; + +/*! \brief Server structure */ +struct Server +{ + dlink_list server_list; /**< Servers on this server */ + dlink_list client_list; /**< Clients on this server */ + char by[NICKLEN + 1]; /**< who activated this connection */ +}; + +/*! \brief ListTask structure */ +struct ListTask +{ + dlink_list show_mask; /**< show these channels.. */ + dlink_list hide_mask; /**< ..and hide these ones */ + + unsigned int hash_index; /**< the bucket we are currently in */ + unsigned int users_min; + unsigned int users_max; + unsigned int created_min; + unsigned int created_max; + unsigned int topicts_min; + unsigned int topicts_max; +}; + +/*! \brief LocalUser structure + * + * Allocated only for local clients, that are directly connected + * to \b this server with a socket. + */ +struct LocalUser +{ + dlink_node lclient_node; + + char client_host[HOSTLEN + 1]; + char client_server[HOSTLEN + 1]; + + unsigned int registration; + unsigned int cap_client; /**< Client capabilities (from us) */ + unsigned int cap_active; /**< Active capabilities (to us) */ + unsigned int caps; /**< capabilities bit-field */ + + unsigned int operflags; /**< IRC Operator privilege flags */ + unsigned int random_ping; /**< Holding a 32bit value used for PING cookies */ + + unsigned int serial; /**< used to enforce 1 send per nick */ + + time_t lasttime; /**< ...should be only LOCAL clients? --msa */ + time_t firsttime; /**< time client was created */ + time_t since; /**< last time we parsed something */ + time_t last_knock; /**< time of last knock */ + time_t last_join_time; /**< when this client last + joined a channel */ + time_t last_leave_time; /**< when this client last + * left a channel */ + int join_leave_count; /**< count of JOIN/LEAVE in less than + MIN_JOIN_LEAVE_TIME seconds */ + int oper_warn_count_down; /**< warn opers of this possible + spambot every time this gets to 0 */ + time_t last_caller_id_time; + time_t first_received_message_time; + time_t last_nick_change; + time_t last_privmsg; /**< Last time we got a PRIVMSG */ + time_t last_away; /**< Away since... */ + + int received_number_of_privmsgs; + unsigned int number_of_nick_changes; + + struct ListTask *list_task; + + struct dbuf_queue buf_sendq; + struct dbuf_queue buf_recvq; + + struct { + unsigned int messages; /**< Statistics: protocol messages sent/received */ + uint64_t bytes; /**< Statistics: total bytes sent/received */ + } recv, send; + + struct AuthRequest *auth; + struct Listener *listener; /**< listener accepted from */ + dlink_list acceptlist; /**< clients I'll allow to talk to me */ + dlink_list watches; /**< chain of Watch pointer blocks */ + dlink_list confs; /**< Configuration record associated */ + dlink_list invited; /**< chain of invite pointer blocks */ + struct irc_ssaddr ip; + int aftype; /**< Makes life easier for DNS res in IPV6 */ + + char *passwd; + fde_t fd; + /* Anti-flood stuff. We track how many messages were parsed and how + * many we were allowed in the current second, and apply a simple + * decay to avoid flooding. + * -- adrian + */ + int allow_read; /**< how many we're allowed to read in this second */ + int sent_parsed; /**< how many messages we've parsed in this second */ + + char* response; /**< expected response from client */ + char* auth_oper; /**< Operator to become if they supply the response.*/ +}; + +/*! \brief Client structure */ +struct Client +{ + dlink_node node; + dlink_node lnode; /**< Used for Server->servers/users */ + + struct LocalUser *localClient; + struct Client *hnext; /**< For client hash table lookups by name */ + struct Client *idhnext; /**< For SID hash table lookups by sid */ + struct Server *serv; /**< ...defined, if this is a server */ + struct Client *servptr; /**< Points to server this Client is on */ + struct Client *from; /**< == self, if Local Client, *NEVER* NULL! */ + + time_t tsinfo; /**< TS on the nick, SVINFO on server */ + + unsigned int flags; /**< client flags */ + unsigned int umodes; /**< opers, normal users subset */ + unsigned int hopcount; /**< number of servers to this 0 = local */ + unsigned int status; /**< Client type */ + unsigned int handler; /**< Handler index */ + + dlink_list whowas; + dlink_list channel; /**< chain of channel pointer blocks */ + + char away[AWAYLEN + 1]; /**< Client's AWAY message. Can be set/unset via AWAY command */ + char name[HOSTLEN + 1]; /**< unique name for a client nick or host */ + char svid[HOSTLEN + 1]; /**< Services ID. XXX: Going with HOSTLEN for now. NICKLEN might be too small + if dealing with timestamps */ + char id[IDLEN + 1]; /**< client ID, unique ID per client */ + /* + * client->username is the username from ident or the USER message, + * If the client is idented the USER message is ignored, otherwise + * the username part of the USER message is put here prefixed with a + * tilde depending on the auth{} block. Once a client has registered, + * this field should be considered read-only. + */ + char username[USERLEN + 1]; /* client's username */ + /* + * client->host contains the resolved name or ip address + * as a string for the user, it may be fiddled with for oper spoofing etc. + * once it's changed the *real* address goes away. This should be + * considered a read-only field after the client has registered. + */ + char host[HOSTLEN + 1]; /* client's hostname */ + + /* + * client->info for unix clients will normally contain the info from the + * gcos field in /etc/passwd but anything can go here. + */ + char info[REALLEN + 1]; /* Free form additional client info */ + + /* + * client->sockhost contains the ip address gotten from the socket as a + * string, this field should be considered read-only once the connection + * has been made. (set in s_bsd.c only) + */ + char sockhost[HOSTIPLEN + 1]; /* This is the host name from the + socket ip address as string */ +}; + + extern struct Client me; extern dlink_list listing_client_list; extern dlink_list global_client_list; @@ -451,7 +449,7 @@ extern void del_accept(struct split_nuh_item *, struct Client *); extern void del_all_accepts(struct Client *); extern void exit_client(struct Client *, struct Client *, const char *); extern void check_conf_klines(void); -extern void init_client(void); +extern void client_init(void); extern void dead_link_on_write(struct Client *, int); extern void dead_link_on_read(struct Client *, int); extern void exit_aborted_clients(void); diff --git a/include/conf.h b/include/conf.h index 16555f5..5a8c28b 100644 --- a/include/conf.h +++ b/include/conf.h @@ -34,14 +34,78 @@ #define CONF_NOREASON "<No reason supplied>" -struct conf_parser_context -{ - unsigned int boot; - unsigned int pass; - FILE *conf_file; -}; +#define IsConfOperator(x) ((x)->type == CONF_OPER) +#define IsConfKill(x) ((x)->type == CONF_KLINE) +#define IsConfClient(x) ((x)->type == CONF_CLIENT) +#define IsConfGline(x) ((x)->type == CONF_GLINE) + +/* MaskItem->flags */ +#define CONF_FLAGS_DO_IDENTD 0x00000001 +#define CONF_FLAGS_LIMIT_IP 0x00000002 +#define CONF_FLAGS_NO_TILDE 0x00000004 +#define CONF_FLAGS_NEED_IDENTD 0x00000008 +#define CONF_FLAGS_NOMATCH_IP 0x00000010 +#define CONF_FLAGS_EXEMPTKLINE 0x00000020 +#define CONF_FLAGS_NOLIMIT 0x00000040 +#define CONF_FLAGS_SPOOF_IP 0x00000080 +#define CONF_FLAGS_SPOOF_NOTICE 0x00000100 +#define CONF_FLAGS_REDIR 0x00000200 +#define CONF_FLAGS_EXEMPTGLINE 0x00000400 +#define CONF_FLAGS_CAN_FLOOD 0x00000800 +#define CONF_FLAGS_NEED_PASSWORD 0x00001000 +#define CONF_FLAGS_ALLOW_AUTO_CONN 0x00002000 +#define CONF_FLAGS_ENCRYPTED 0x00004000 +#define CONF_FLAGS_IN_DATABASE 0x00008000 +#define CONF_FLAGS_EXEMPTRESV 0x00010000 +#define CONF_FLAGS_SSL 0x00020000 +#define CONF_FLAGS_WEBIRC 0x00040000 + +/* Macros for struct MaskItem */ +#define IsConfWebIRC(x) ((x)->flags & CONF_FLAGS_WEBIRC) +#define IsLimitIp(x) ((x)->flags & CONF_FLAGS_LIMIT_IP) +#define IsNoTilde(x) ((x)->flags & CONF_FLAGS_NO_TILDE) +#define IsConfCanFlood(x) ((x)->flags & CONF_FLAGS_CAN_FLOOD) +#define IsNeedPassword(x) ((x)->flags & CONF_FLAGS_NEED_PASSWORD) +#define IsNeedIdentd(x) ((x)->flags & CONF_FLAGS_NEED_IDENTD) +#define IsNoMatchIp(x) ((x)->flags & CONF_FLAGS_NOMATCH_IP) +#define IsConfExemptKline(x) ((x)->flags & CONF_FLAGS_EXEMPTKLINE) +#define IsConfExemptLimits(x) ((x)->flags & CONF_FLAGS_NOLIMIT) +#define IsConfExemptGline(x) ((x)->flags & CONF_FLAGS_EXEMPTGLINE) +#define IsConfExemptResv(x) ((x)->flags & CONF_FLAGS_EXEMPTRESV) +#define IsConfDoIdentd(x) ((x)->flags & CONF_FLAGS_DO_IDENTD) +#define IsConfDoSpoofIp(x) ((x)->flags & CONF_FLAGS_SPOOF_IP) +#define IsConfSpoofNotice(x) ((x)->flags & CONF_FLAGS_SPOOF_NOTICE) +#define IsConfEncrypted(x) ((x)->flags & CONF_FLAGS_ENCRYPTED) +#define SetConfEncrypted(x) ((x)->flags |= CONF_FLAGS_ENCRYPTED) +#define ClearConfEncrypted(x) ((x)->flags &= ~CONF_FLAGS_ENCRYPTED) +#define IsConfAllowAutoConn(x) ((x)->flags & CONF_FLAGS_ALLOW_AUTO_CONN) +#define SetConfAllowAutoConn(x) ((x)->flags |= CONF_FLAGS_ALLOW_AUTO_CONN) +#define ClearConfAllowAutoConn(x) ((x)->flags &= ~CONF_FLAGS_ALLOW_AUTO_CONN) +#define IsConfRedir(x) ((x)->flags & CONF_FLAGS_REDIR) +#define IsConfSSL(x) ((x)->flags & CONF_FLAGS_SSL) +#define SetConfSSL(x) ((x)->flags |= CONF_FLAGS_SSL) +#define ClearConfSSL(x) ((x)->flags &= ~CONF_FLAGS_SSL) +#define IsConfDatabase(x) ((x)->flags & CONF_FLAGS_IN_DATABASE) +#define SetConfDatabase(x) ((x)->flags |= CONF_FLAGS_IN_DATABASE) + + +/* shared/cluster server entry types + * These defines are used for both shared and cluster. + */ +#define SHARED_KLINE 0x0001 +#define SHARED_UNKLINE 0x0002 +#define SHARED_XLINE 0x0004 +#define SHARED_UNXLINE 0x0008 +#define SHARED_RESV 0x0010 +#define SHARED_UNRESV 0x0020 +#define SHARED_LOCOPS 0x0040 +#define SHARED_DLINE 0x0080 +#define SHARED_UNDLINE 0x0100 +#define SHARED_ALL (SHARED_KLINE | SHARED_UNKLINE |\ + SHARED_XLINE | SHARED_UNXLINE |\ + SHARED_RESV | SHARED_UNRESV |\ + SHARED_LOCOPS | SHARED_DLINE | SHARED_UNDLINE) -extern struct conf_parser_context conf_parser_ctx; enum maskitem_type { @@ -65,6 +129,13 @@ enum maskitem_type CONF_CLASS = 1 << 17 /* XXX Same here; just for /stats Y|y */ }; +struct conf_parser_context +{ + unsigned int boot; + unsigned int pass; + FILE *conf_file; +}; + struct split_nuh_item { dlink_node node; @@ -121,79 +192,6 @@ struct CidrItem unsigned int number_on_this_cidr; }; - -#define IsConfOperator(x) ((x)->type == CONF_OPER) -#define IsConfKill(x) ((x)->type == CONF_KLINE) -#define IsConfClient(x) ((x)->type == CONF_CLIENT) -#define IsConfGline(x) ((x)->type == CONF_GLINE) - -/* MaskItem->flags */ -#define CONF_FLAGS_DO_IDENTD 0x00000001 -#define CONF_FLAGS_LIMIT_IP 0x00000002 -#define CONF_FLAGS_NO_TILDE 0x00000004 -#define CONF_FLAGS_NEED_IDENTD 0x00000008 -#define CONF_FLAGS_NOMATCH_IP 0x00000010 -#define CONF_FLAGS_EXEMPTKLINE 0x00000020 -#define CONF_FLAGS_NOLIMIT 0x00000040 -#define CONF_FLAGS_SPOOF_IP 0x00000080 -#define CONF_FLAGS_SPOOF_NOTICE 0x00000100 -#define CONF_FLAGS_REDIR 0x00000200 -#define CONF_FLAGS_EXEMPTGLINE 0x00000400 -#define CONF_FLAGS_CAN_FLOOD 0x00000800 -#define CONF_FLAGS_NEED_PASSWORD 0x00001000 -#define CONF_FLAGS_ALLOW_AUTO_CONN 0x00002000 -#define CONF_FLAGS_ENCRYPTED 0x00004000 -#define CONF_FLAGS_IN_DATABASE 0x00008000 -#define CONF_FLAGS_EXEMPTRESV 0x00010000 -#define CONF_FLAGS_SSL 0x00020000 -#define CONF_FLAGS_WEBIRC 0x00040000 - -/* Macros for struct MaskItem */ -#define IsConfWebIRC(x) ((x)->flags & CONF_FLAGS_WEBIRC) -#define IsLimitIp(x) ((x)->flags & CONF_FLAGS_LIMIT_IP) -#define IsNoTilde(x) ((x)->flags & CONF_FLAGS_NO_TILDE) -#define IsConfCanFlood(x) ((x)->flags & CONF_FLAGS_CAN_FLOOD) -#define IsNeedPassword(x) ((x)->flags & CONF_FLAGS_NEED_PASSWORD) -#define IsNeedIdentd(x) ((x)->flags & CONF_FLAGS_NEED_IDENTD) -#define IsNoMatchIp(x) ((x)->flags & CONF_FLAGS_NOMATCH_IP) -#define IsConfExemptKline(x) ((x)->flags & CONF_FLAGS_EXEMPTKLINE) -#define IsConfExemptLimits(x) ((x)->flags & CONF_FLAGS_NOLIMIT) -#define IsConfExemptGline(x) ((x)->flags & CONF_FLAGS_EXEMPTGLINE) -#define IsConfExemptResv(x) ((x)->flags & CONF_FLAGS_EXEMPTRESV) -#define IsConfDoIdentd(x) ((x)->flags & CONF_FLAGS_DO_IDENTD) -#define IsConfDoSpoofIp(x) ((x)->flags & CONF_FLAGS_SPOOF_IP) -#define IsConfSpoofNotice(x) ((x)->flags & CONF_FLAGS_SPOOF_NOTICE) -#define IsConfEncrypted(x) ((x)->flags & CONF_FLAGS_ENCRYPTED) -#define SetConfEncrypted(x) ((x)->flags |= CONF_FLAGS_ENCRYPTED) -#define ClearConfEncrypted(x) ((x)->flags &= ~CONF_FLAGS_ENCRYPTED) -#define IsConfAllowAutoConn(x) ((x)->flags & CONF_FLAGS_ALLOW_AUTO_CONN) -#define SetConfAllowAutoConn(x) ((x)->flags |= CONF_FLAGS_ALLOW_AUTO_CONN) -#define ClearConfAllowAutoConn(x) ((x)->flags &= ~CONF_FLAGS_ALLOW_AUTO_CONN) -#define IsConfRedir(x) ((x)->flags & CONF_FLAGS_REDIR) -#define IsConfSSL(x) ((x)->flags & CONF_FLAGS_SSL) -#define SetConfSSL(x) ((x)->flags |= CONF_FLAGS_SSL) -#define ClearConfSSL(x) ((x)->flags &= ~CONF_FLAGS_SSL) -#define IsConfDatabase(x) ((x)->flags & CONF_FLAGS_IN_DATABASE) -#define SetConfDatabase(x) ((x)->flags |= CONF_FLAGS_IN_DATABASE) - - -/* shared/cluster server entry types - * These defines are used for both shared and cluster. - */ -#define SHARED_KLINE 0x0001 -#define SHARED_UNKLINE 0x0002 -#define SHARED_XLINE 0x0004 -#define SHARED_UNXLINE 0x0008 -#define SHARED_RESV 0x0010 -#define SHARED_UNRESV 0x0020 -#define SHARED_LOCOPS 0x0040 -#define SHARED_DLINE 0x0080 -#define SHARED_UNDLINE 0x0100 -#define SHARED_ALL (SHARED_KLINE | SHARED_UNKLINE |\ - SHARED_XLINE | SHARED_UNXLINE |\ - SHARED_RESV | SHARED_UNRESV |\ - SHARED_LOCOPS | SHARED_DLINE | SHARED_UNDLINE) - struct config_file_entry { const char *dpath; /* DPATH if set from command line */ @@ -326,6 +324,7 @@ extern dlink_list xconf_items; extern dlink_list rxconf_items; extern dlink_list rkconf_items; extern dlink_list service_items; +extern struct conf_parser_context conf_parser_ctx; extern struct logging_entry ConfigLoggingEntry; extern struct config_file_entry ConfigFileEntry;/* defined in ircd.c*/ extern struct config_channel_entry ConfigChannel;/* defined in channel.c*/ @@ -335,9 +334,6 @@ extern struct admin_info AdminInfo; /* defined in ircd.c */ extern int valid_wild_card(struct Client *, int, int, ...); /* End GLOBAL section */ - - - extern void init_ip_hash_table(void); extern void count_ip_hash(unsigned int *, uint64_t *); extern void remove_one_ip(struct irc_ssaddr *); diff --git a/include/hash.h b/include/hash.h index b6a604f..bb4bb06 100644 --- a/include/hash.h +++ b/include/hash.h @@ -35,7 +35,8 @@ struct Channel; struct MaskItem; struct UserHost; -enum { +enum +{ HASH_TYPE_ID, HASH_TYPE_CLIENT, HASH_TYPE_CHANNEL, @@ -43,7 +44,7 @@ enum { HASH_TYPE_RESERVED }; -extern void init_hash(void); +extern void hash_init(void); extern void hash_add_client(struct Client *); extern void hash_del_client(struct Client *); extern void hash_add_channel(struct Channel *); diff --git a/include/ircd.h b/include/ircd.h index 785c349..5a1e4c4 100644 --- a/include/ircd.h +++ b/include/ircd.h @@ -28,7 +28,6 @@ #include "ircd_defs.h" #include "config.h" -//struct Client; struct SetOptions { @@ -69,9 +68,6 @@ struct ServerStatistics unsigned int is_abad; /* bad auth requests */ }; -extern struct ServerStatistics ServerStats; - - struct Counter { uint64_t totalrestartcount; /* Total client count ever */ @@ -86,14 +82,11 @@ struct Counter unsigned int max_loc_cli; /* XXX This is redundant - Max local client count */ }; -extern struct SetOptions GlobalSetOptions; /* defined in ircd.c */ - struct ServerState_t { int foreground; }; -extern struct ServerState_t server_state; extern char **myargv; extern const char *infotext[]; @@ -104,6 +97,9 @@ extern const char *pidFileName; extern int dorehash; extern int doremotd; extern struct Counter Count; +extern struct ServerStatistics ServerStats; +extern struct SetOptions GlobalSetOptions; /* defined in ircd.c */ +extern struct ServerState_t server_state; extern struct timeval SystemTime; #define CurrentTime SystemTime.tv_sec extern int default_server_capabs; diff --git a/include/listener.h b/include/listener.h index 6e402f6..dac40bb 100644 --- a/include/listener.h +++ b/include/listener.h @@ -36,7 +36,7 @@ struct Client; struct Listener { - dlink_node listener_node; /* list node pointer */ + dlink_node node; /* list node pointer */ fde_t fd; /* file descriptor */ int port; /* listener IP port */ int ref_count; /* number of connection references */ diff --git a/include/packet.h b/include/packet.h index 1f2b272..3042561 100644 --- a/include/packet.h +++ b/include/packet.h @@ -46,11 +46,6 @@ #define MAX_FLOOD 5 #define MAX_FLOOD_BURST MAX_FLOOD * 8 -struct Callback; - -void *iorecv_default(va_list); -extern struct Callback *iorecv_cb; - PF read_packet; PF flood_recalc; void flood_endgrace(struct Client *); diff --git a/include/s_auth.h b/include/s_auth.h index b9ffc35..44a1246 100644 --- a/include/s_auth.h +++ b/include/s_auth.h @@ -25,21 +25,8 @@ #ifndef INCLUDED_s_auth_h #define INCLUDED_s_auth_h -#include "irc_res.h" #include "hook.h" - -struct Client; - -struct AuthRequest -{ - dlink_node node; /* auth_doing_list */ - int flags; - struct Client* client; /* pointer to client struct for request */ - fde_t fd; /* file descriptor for auth queries */ - time_t timeout; /* time when query expires */ -}; - /* * flag values for AuthRequest * NAMESPACE: AM_xxx - Authentication Module @@ -55,9 +42,20 @@ struct AuthRequest #define ClearAuth(x) ((x)->flags &= ~AM_DOING_AUTH) #define IsDoingAuth(x) ((x)->flags & AM_DOING_AUTH) +struct Client; + +struct AuthRequest +{ + dlink_node node; /* auth_doing_list */ + int flags; + struct Client* client; /* pointer to client struct for request */ + fde_t fd; /* file descriptor for auth queries */ + time_t timeout; /* time when query expires */ +}; + extern struct Callback *auth_cb; -extern void init_auth(void); +extern void auth_init(void); extern void send_auth_query(struct AuthRequest *); extern void remove_auth_request(struct AuthRequest *); extern void delete_auth(struct AuthRequest *); diff --git a/include/s_gline.h b/include/s_gline.h index 2222b7d..677d7b2 100644 --- a/include/s_gline.h +++ b/include/s_gline.h @@ -30,6 +30,8 @@ #define GLINE_PENDING_DEL_TYPE 0 #define GLINE_PENDING_ADD_TYPE 1 +#define CLEANUP_GLINES_TIME 300 + struct MaskItem; extern void cleanup_glines(void *); @@ -53,8 +55,5 @@ struct gline_pending char host[HOSTLEN * 2 + 2]; }; - -#define CLEANUP_GLINES_TIME 300 - extern dlink_list pending_glines[]; #endif /* INCLUDED_s_gline_h */ diff --git a/include/send.h b/include/send.h index 668428b..3e34b6f 100644 --- a/include/send.h +++ b/include/send.h @@ -27,20 +27,35 @@ #include "fdlist.h" +#define ALL_MEMBERS 0 +#define NON_CHANOPS 1 +#define ONLY_CHANOPS_VOICED 2 +#define ONLY_CHANOPS 3 +#define ONLY_SERVERS 4 /* for channel_mode.c */ + +#define L_ALL 0 +#define L_OPER 1 +#define L_ADMIN 2 + +#define SEND_NOTICE 1 +#define SEND_GLOBAL 2 +#define SEND_LOCOPS 3 + +#define NOCAPS 0 /* no caps */ +#define NOFLAGS 0 /* no flags */ + +/* used when sending to #mask or $mask */ +#define MATCH_SERVER 1 +#define MATCH_HOST 2 + /* * struct decls */ -struct Callback; struct Channel; struct Client; -struct dlink_list; - -extern void *iosend_default(va_list); -extern struct Callback *iosend_cb; /* send.c prototypes */ - extern void sendq_unblocked(fde_t *, struct Client *); extern void send_queued_write(struct Client *); extern void send_queued_all(void); @@ -76,27 +91,4 @@ extern void kill_client(struct Client *, struct Client *, const char *, ... ) AFP(3,4); extern void kill_client_ll_serv_butone(struct Client *, struct Client *, const char *, ...) AFP(3,4); - - -#define ALL_MEMBERS 0 -#define NON_CHANOPS 1 -#define ONLY_CHANOPS_VOICED 2 -#define ONLY_CHANOPS 3 -#define ONLY_SERVERS 4 /* for channel_mode.c */ - -#define L_ALL 0 -#define L_OPER 1 -#define L_ADMIN 2 - -#define SEND_NOTICE 1 -#define SEND_GLOBAL 2 -#define SEND_LOCOPS 3 - -#define NOCAPS 0 /* no caps */ -#define NOFLAGS 0 /* no flags */ - -/* used when sending to #mask or $mask */ -#define MATCH_SERVER 1 -#define MATCH_HOST 2 - #endif /* INCLUDED_send_h */ diff --git a/src/channel.c b/src/channel.c index 14abc87..5ee5977 100644 --- a/src/channel.c +++ b/src/channel.c @@ -58,7 +58,7 @@ static char parabuf[MODEBUFLEN]; /*! \brief Initializes the channel blockheap, adds known channel CAPAB */ void -init_channels(void) +channel_init(void) { add_capability("EX", CAP_EX, 1); add_capability("IE", CAP_IE, 1); diff --git a/src/client.c b/src/client.c index 0077fa6..17e5b34 100644 --- a/src/client.c +++ b/src/client.c @@ -78,14 +78,14 @@ static void check_unknowns_list(void); static void ban_them(struct Client *, struct MaskItem *); -/* init_client() +/* client_init() * * inputs - NONE * output - NONE * side effects - initialize client free memory */ void -init_client(void) +client_init(void) { /* start off the check ping event .. -- adrian * Every 30 seconds is plenty -- db @@ -68,7 +68,7 @@ static struct MaskItem *resvchannelTable[HASHSIZE]; * functions and clear the tables */ void -init_hash(void) +hash_init(void) { /* Default the userhost/namehost sizes to CLIENT_HEAP_SIZE for now, * should be a good close approximation anyway @@ -432,7 +432,7 @@ setup_corefile(void) * side effects - setups SSL context. */ static void -init_ssl(void) +ssl_init(void) { #ifdef HAVE_LIBCRYPTO SSL_load_error_strings(); @@ -466,19 +466,6 @@ init_ssl(void) #endif /* HAVE_LIBCRYPTO */ } -/* init_callbacks() - * - * inputs - nothing - * output - nothing - * side effects - setups standard hook points - */ -static void -init_callbacks(void) -{ - iorecv_cb = register_callback("iorecv", iorecv_default); - iosend_cb = register_callback("iosend", iosend_default); -} - int main(int argc, char *argv[]) { @@ -531,7 +518,7 @@ main(int argc, char *argv[]) exit(EXIT_FAILURE); } - init_ssl(); + ssl_init(); if (!server_state.foreground) { @@ -555,24 +542,23 @@ main(int argc, char *argv[]) mp_pool_init(); init_dlink_nodes(); - init_callbacks(); initialize_message_files(); dbuf_init(); - init_hash(); + hash_init(); init_ip_hash_table(); /* client host ip hash table */ init_host_hash(); /* Host-hashtable. */ - init_client(); + client_init(); class_init(); whowas_init(); watch_init(); - init_auth(); /* Initialise the auth code */ + auth_init(); /* Initialise the auth code */ init_resolver(); /* Needs to be setup before the io loop */ modules_init(); read_conf_files(1); /* cold start init conf files */ init_uid(); initialize_server_capabs(); /* Set up default_server_capabs */ initialize_global_set_options(); - init_channels(); + channel_init(); if (EmptyString(ServerInfo.sid)) { diff --git a/src/listener.c b/src/listener.c index 2486980..bd577a7 100644 --- a/src/listener.c +++ b/src/listener.c @@ -57,7 +57,7 @@ free_listener(struct Listener *listener) { assert(listener != NULL); - dlinkDelete(&listener->listener_node, &ListenerPollList); + dlinkDelete(&listener->node, &ListenerPollList); MyFree(listener); } @@ -298,7 +298,7 @@ add_listener(int port, const char *vhost_ip, unsigned int flags) else { listener = make_listener(port, &vaddr); - dlinkAdd(listener, &listener->listener_node, &ListenerPollList); + dlinkAdd(listener, &listener->node, &ListenerPollList); listener->flags = flags; } diff --git a/src/packet.c b/src/packet.c index b6224e6..0d23553 100644 --- a/src/packet.c +++ b/src/packet.c @@ -39,8 +39,6 @@ #define READBUF_SIZE 16384 -struct Callback *iorecv_cb = NULL; - static char readBuf[READBUF_SIZE]; static void client_dopacket(struct Client *, char *, size_t); @@ -271,20 +269,6 @@ flood_recalc(fde_t *fd, void *data) } /* - * iorecv_default - append a packet to the recvq dbuf - */ -void * -iorecv_default(va_list args) -{ - struct Client *client_p = va_arg(args, struct Client *); - int length = va_arg(args, int); - char *buf = va_arg(args, char *); - - dbuf_put(&client_p->localClient->buf_recvq, buf, length); - return NULL; -} - -/* * read_packet - Read a 'packet' of data from a connection and process it. */ void @@ -347,7 +331,7 @@ read_packet(fde_t *fd, void *data) return; } - execute_callback(iorecv_cb, client_p, length, readBuf); + dbuf_put(&client_p->localClient->buf_recvq, readBuf, length); if (client_p->localClient->lasttime < CurrentTime) client_p->localClient->lasttime = CurrentTime; diff --git a/src/s_auth.c b/src/s_auth.c index 3c4f2a7..9be758f 100644 --- a/src/s_auth.c +++ b/src/s_auth.c @@ -87,12 +87,12 @@ static CBFUNC start_auth; struct Callback *auth_cb = NULL; -/* init_auth() +/* auth_init * * Initialise the auth code */ void -init_auth(void) +auth_init(void) { auth_pool = mp_pool_new(sizeof(struct AuthRequest), MP_CHUNK_SIZE_AUTH); auth_cb = register_callback("start_auth", start_auth); @@ -37,11 +37,9 @@ #include "conf.h" #include "log.h" #include "memory.h" -#include "hook.h" #include "packet.h" -struct Callback *iosend_cb = NULL; static unsigned int current_serial = 0; @@ -81,20 +79,6 @@ send_format(char *lsendbuf, int bufsize, const char *pattern, va_list args) } /* - * iosend_default - append a packet to the client's sendq. - */ -void * -iosend_default(va_list args) -{ - struct Client *to = va_arg(args, struct Client *); - int length = va_arg(args, int); - char *buf = va_arg(args, char *); - - dbuf_put(&to->localClient->buf_sendq, buf, length); - return NULL; -} - -/* ** send_message ** Internal utility which appends given buffer to the sockets ** sendq. @@ -118,8 +102,8 @@ send_message(struct Client *to, char *buf, int len) dead_link_on_write(to, 0); return; } - - execute_callback(iosend_cb, to, len, buf); + + dbuf_put(&to->localClient->buf_sendq, buf, len); /* ** Update statistics. The following is slightly incorrect |