Module: ngircd.git
Branch: master
Commit: 5555b6cc8612e08d21750af0cd9dadb1196ff115
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=5555b6cc…
Author: Alexander Barton <alex(a)barton.de>
Date: Mon Dec 27 17:25:48 2010 +0100
Doxygen'ify conf.h
---
src/ngircd/conf.h | 138 ++++++++++++++++++++++++++++++-----------------------
1 files changed, 78 insertions(+), 60 deletions(-)
diff --git a/src/ngircd/conf.h b/src/ngircd/conf.h
index 7632e2b..8c6aea8 100644
--- a/src/ngircd/conf.h
+++ b/src/ngircd/conf.h
@@ -27,54 +27,66 @@
#include "proc.h"
#include "conf-ssl.h"
-
+/**
+ * Configured IRC operator.
+ * Please note the the name of the IRC operaor and his nick have nothing to
+ * do with each other! The IRC operator is only identified by the name and
+ * password configured in this structure.
+ */
struct Conf_Oper {
- char name[CLIENT_PASS_LEN]; /* Name (ID) of IRC operator */
- char pwd[CLIENT_PASS_LEN]; /* Password */
- char *mask; /* allowed host mask */
+ char name[CLIENT_PASS_LEN]; /**< Name (ID) */
+ char pwd[CLIENT_PASS_LEN]; /**< Password */
+ char *mask; /**< Allowed host mask */
};
+/**
+ * Configured server.
+ * Peers to which this daemon should establish an outgoing server link must
+ * have set a port number; all other servers are allowed to connect to this one.
+ */
typedef struct _Conf_Server
{
- char host[HOST_LEN]; /* Hostname */
- char name[CLIENT_ID_LEN]; /* IRC-Client-ID */
- char pwd_in[CLIENT_PASS_LEN]; /* Password which must be received */
- char pwd_out[CLIENT_PASS_LEN]; /* Password to send to peer */
- UINT16 port; /* Server port */
- int group; /* Group of server */
- time_t lasttry; /* Last connect attempt */
- PROC_STAT res_stat; /* Status of the resolver */
- int flags; /* Flags */
- CONN_ID conn_id; /* ID of server connection or NONE */
- ng_ipaddr_t bind_addr; /* source address to use for outgoing
- connections */
- ng_ipaddr_t dst_addr[2]; /* list of addresses to connect to */
+ char host[HOST_LEN]; /**< Hostname */
+ char name[CLIENT_ID_LEN]; /**< IRC client ID */
+ char pwd_in[CLIENT_PASS_LEN]; /**< Password which must be received */
+ char pwd_out[CLIENT_PASS_LEN]; /**< Password to send to the peer */
+ UINT16 port; /**< Server port to connect to */
+ int group; /**< Group ID of this server */
+ time_t lasttry; /**< Time of last connection attempt */
+ PROC_STAT res_stat; /**< Status of the resolver */
+ int flags; /**< Server flags */
+ CONN_ID conn_id; /**< ID of server connection or NONE */
+ ng_ipaddr_t bind_addr; /**< Source address to use for outgoing
+ connections */
+ ng_ipaddr_t dst_addr[2]; /**< List of addresses to connect to */
#ifdef SSL_SUPPORT
- bool SSLConnect; /* connect() using SSL? */
+ bool SSLConnect; /**< Establish connection using SSL? */
#endif
- char svs_mask[CLIENT_ID_LEN]; /* Mask of nick names that are
- services */
+ char svs_mask[CLIENT_ID_LEN]; /**< Mask of nick names that should be
+ treated and counted as services */
} CONF_SERVER;
#ifdef SSL_SUPPORT
+/** Configuration options required for SSL support */
struct SSLOptions {
- char *KeyFile;
- char *CertFile;
- char *DHFile;
- array ListenPorts;
- array KeyFilePassword;
+ char *KeyFile; /**< SSL key file */
+ char *CertFile; /**< SSL certificate file */
+ char *DHFile; /**< File containing DH parameters */
+ array ListenPorts; /**< Array of listening SSL ports */
+ array KeyFilePassword; /**< Key file password */
};
#endif
+/** Pre-defined channels */
struct Conf_Channel {
- char name[CHANNEL_NAME_LEN]; /* Name of the channel */
- char modes[CHANNEL_MODE_LEN]; /* Initial channel modes */
- char key[CLIENT_PASS_LEN]; /* Channel key ("password", mode "k" ) */
- char topic[COMMAND_LEN]; /* Initial topic */
- char keyfile[512]; /* Path and name of channel key file */
- unsigned long maxusers; /* maximum usercount for this channel, mode "l" */
+ char name[CHANNEL_NAME_LEN]; /**< Name of the channel */
+ char modes[CHANNEL_MODE_LEN]; /**< Initial channel modes */
+ char key[CLIENT_PASS_LEN]; /**< Channel key ("password", mode "k" ) */
+ char topic[COMMAND_LEN]; /**< Initial topic */
+ char keyfile[512]; /**< Path and name of channel key file */
+ unsigned long maxusers; /**< User limit for this channel, mode "l" */
};
@@ -82,76 +94,82 @@ struct Conf_Channel {
#define CONF_SFLAG_DISABLED 2 /* This server configuration entry is disabled */
-/* Name ("Nick") of the servers */
+/** Name (ID, "nick") of this server */
GLOBAL char Conf_ServerName[CLIENT_ID_LEN];
-/* Server info text */
+/** Server info text */
GLOBAL char Conf_ServerInfo[CLIENT_INFO_LEN];
-/* Global server passwort */
+/** Global server passwort */
GLOBAL char Conf_ServerPwd[CLIENT_PASS_LEN];
-/* Administrative information */
+/** Administrative information */
GLOBAL char Conf_ServerAdmin1[CLIENT_INFO_LEN];
GLOBAL char Conf_ServerAdmin2[CLIENT_INFO_LEN];
GLOBAL char Conf_ServerAdminMail[CLIENT_INFO_LEN];
-/* Message of the Day */
+/** Message of the day (MOTD) of this server */
GLOBAL array Conf_Motd;
-/* Ports the server should listen on */
+/** Array of ports this server should listen on */
GLOBAL array Conf_ListenPorts;
-/* Address to which the socket should be bound or empty (=all) */
+/** Address to which sockets should be bound to or empty (=all) */
GLOBAL char *Conf_ListenAddress;
-/* User and group ID the server should run with */
+/** User and group ID this daemon should run with */
GLOBAL uid_t Conf_UID;
GLOBAL gid_t Conf_GID;
-/* A directory to chroot() in */
+/** The directory to chroot() into */
GLOBAL char Conf_Chroot[FNAME_LEN];
-/* File with PID of daemon */
+/** Full path and name of a file to which the PID of daemon should be written */
GLOBAL char Conf_PidFile[FNAME_LEN];
-/* Timeouts for PING and PONG */
+/** Timeout (in seconds) for PING commands */
GLOBAL int Conf_PingTimeout;
+
+/** Timeout (in seconds) for PONG replies */
GLOBAL int Conf_PongTimeout;
-/* Seconds between connect attempts to other servers */
+/** Seconds between connection attempts to other servers */
GLOBAL int Conf_ConnectRetry;
-/* Operators */
+/** Array of configured IRC operators */
GLOBAL array Conf_Opers;
-/* Servers */
+/** Array of configured IRC servers */
GLOBAL CONF_SERVER Conf_Server[MAX_SERVERS];
-/* Pre-defined channels */
+/** Array of pre-defined channels */
GLOBAL array Conf_Channels;
-/* Pre-defined channels only */
+/** Flag indicating if only pre-defined channels are allowed (true) or not */
GLOBAL bool Conf_PredefChannelsOnly;
-/* Are IRC operators allowed to always use MODE? */
+/** Flag indicating if IRC operators are allowed to always use MODE (true) */
GLOBAL bool Conf_OperCanMode;
-/* If an IRC op gives chanop privileges without being a chanop,
- * ircd2 will ignore the command. This enables a workaround:
- * It masks the command as coming from the server */
+/**
+ * If true, mask channel MODE commands of IRC operators to the server.
+ * Background: ircd2 will ignore channel MODE commands if an IRC operator
+ * gives chanel operator privileges to someone without being a channel operator
+ * himself. This enables a workaround: it masks the MODE command as coming
+ * from the IRC server and not the IRC operator.
+ */
GLOBAL bool Conf_OperServerMode;
-/* Are remote IRC operators allowed to manage this server? */
+/** Flag indicating if remote IRC operators are allowed to manage this server */
GLOBAL bool Conf_AllowRemoteOper;
-/* Enable all DNS functions? */
+/** Enable all DNS functions? */
GLOBAL bool Conf_DNS;
-/* Enable IDENT lookups, even when compiled with support for it */
+/** Enable IDENT lookups, even when compiled with support for it */
GLOBAL bool Conf_Ident;
-/* Enable all usage of PAM, even when compiled with support for it */
+/** Enable all usage of PAM, even when compiled with support for it */
GLOBAL bool Conf_PAM;
/*
@@ -160,19 +178,19 @@ GLOBAL bool Conf_PAM;
*/
GLOBAL bool Conf_ConnectIPv6;
-/* same as above, but for ipv4 hosts, default: yes */
+/** Try to connect to remote systems using the IPv4 protocol (true) */
GLOBAL bool Conf_ConnectIPv4;
-/* Maximum number of connections to this server */
+/** Maximum number of simultaneous connections to this server */
GLOBAL long Conf_MaxConnections;
-/* Maximum number of channels a user can join */
+/** Maximum number of channels a user can join */
GLOBAL int Conf_MaxJoins;
-/* Maximum number of connections per IP address */
+/** Maximum number of connections per IP address */
GLOBAL int Conf_MaxConnectionsIP;
-/* Maximum length of a nick name */
+/** Maximum length of a nick name */
GLOBAL unsigned int Conf_MaxNickLength;
#ifdef SYSLOG
Module: ngircd.git
Branch: master
Commit: f732c7117e5a4b74b47c4594470506dcb2773760
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=f732c711…
Author: Alexander Barton <alex(a)barton.de>
Date: Sat Feb 12 23:24:56 2011 +0100
Make write buffers bigger, but flush early
This patch
- makes the server write buffer bigger: 64k,
- makes the regular write buffer bigger: 32k,
- tries to flush the write buffer starting at 4K.
Before this patch, a client got disconnected if the buffer flushing at 4k
failed, now regular clients can store up to 32k and servers up 64k even
if flushing is not possible at the moment (e.g. on slow links).
---
src/ngircd/conn.c | 4 ++--
src/ngircd/defines.h | 7 +++++--
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c
index e92240b..e58e633 100644
--- a/src/ngircd/conn.c
+++ b/src/ngircd/conn.c
@@ -858,7 +858,7 @@ static bool
Conn_Write( CONN_ID Idx, char *Data, size_t Len )
{
CLIENT *c;
- size_t writebuf_limit = WRITEBUFFER_LEN;
+ size_t writebuf_limit = WRITEBUFFER_MAX_LEN;
assert( Idx > NONE );
assert( Data != NULL );
assert( Len > 0 );
@@ -894,7 +894,7 @@ Conn_Write( CONN_ID Idx, char *Data, size_t Len )
/* Uncompressed link:
* Check if outbound buffer has enough space for the data. */
if (array_bytes(&My_Connections[Idx].wbuf) + Len >=
- writebuf_limit) {
+ WRITEBUFFER_FLUSH_LEN) {
/* Buffer is full, flush it. Handle_Write deals with
* low-level errors, if any. */
if (!Handle_Write(Idx))
diff --git a/src/ngircd/defines.h b/src/ngircd/defines.h
index 3f1122c..ec7bee9 100644
--- a/src/ngircd/defines.h
+++ b/src/ngircd/defines.h
@@ -59,9 +59,12 @@
#define READBUFFER_LEN 2048 /* Size of the read buffer of a
connection in bytes. */
-#define WRITEBUFFER_LEN 4096 /* Size of the write buffer of a
+#define WRITEBUFFER_FLUSH_LEN 4096 /* Size of a write buffer that triggers
+ buffer flushing if more space is
+ needed for storing data. */
+#define WRITEBUFFER_MAX_LEN 32768 /* Maximum size of the write buffer of a
connection in bytes. */
-#define WRITEBUFFER_SLINK_LEN 51200 /* Size of the write buffer of a
+#define WRITEBUFFER_SLINK_LEN 65536 /* Maximum size of the write buffer of a
server link connection in bytes. */
#define PROTOVER "0210" /* Implemented IRC protocol version,
Module: ngircd.git
Branch: master
Commit: 765dc320f11f117d63e5285a903dfe8af4a48795
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=765dc320…
Author: Alexander Barton <alex(a)barton.de>
Date: Sun Jan 23 15:14:18 2011 +0100
Read_Request(): don't access possibly free'd CLIENT structure
Handle_Buffer() can shut down connections and remove clients, so after
calling it, we have to make sure that our CLIENT pointer is still valid.
---
src/ngircd/conn.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c
index 98a0543..af79c13 100644
--- a/src/ngircd/conn.c
+++ b/src/ngircd/conn.c
@@ -1455,16 +1455,21 @@ Read_Request( CONN_ID Idx )
/* Update connection statistics */
My_Connections[Idx].bytes_in += len;
+ My_Connections[Idx].bps += Handle_Buffer(Idx);
+
+ /* Make sure that there is still a valid client registered */
+ c = Conn_GetClient(Idx);
+ if (!c)
+ return;
/* Update timestamp of last data received if this connection is
* registered as a user, server or service connection. Don't update
* otherwise, so users have at least Conf_PongTimeout seconds time to
* register with the IRC server -- see Check_Connections().
* Update "lastping", too, if time shifted backwards ... */
- c = Conn_GetClient(Idx);
- if (c && (Client_Type(c) == CLIENT_USER
- || Client_Type(c) == CLIENT_SERVER
- || Client_Type(c) == CLIENT_SERVICE)) {
+ if (Client_Type(c) == CLIENT_USER
+ || Client_Type(c) == CLIENT_SERVER
+ || Client_Type(c) == CLIENT_SERVICE) {
t = time(NULL);
if (My_Connections[Idx].lastdata != t)
My_Connections[Idx].bps = 0;
@@ -1475,7 +1480,6 @@ Read_Request( CONN_ID Idx )
}
/* Look at the data in the (read-) buffer of this connection */
- My_Connections[Idx].bps += Handle_Buffer(Idx);
if (Client_Type(c) != CLIENT_SERVER
&& Client_Type(c) != CLIENT_UNKNOWNSERVER
&& Client_Type(c) != CLIENT_SERVICE