conf.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. /*
  2. * ngIRCd -- The Next Generation IRC Daemon
  3. * Copyright (c)2001-2013 Alexander Barton (alex@barton.de) and Contributors.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. * Please read the file COPYING, README and AUTHORS for more information.
  10. */
  11. #ifndef __conf_h__
  12. #define __conf_h__
  13. /**
  14. * @file
  15. * Configuration management (header)
  16. */
  17. #include <time.h>
  18. #include "defines.h"
  19. #include "array.h"
  20. #include "portab.h"
  21. #include "tool.h"
  22. #include "ng_ipaddr.h"
  23. #include "proc.h"
  24. #include "conf-ssl.h"
  25. /**
  26. * Configured IRC operator.
  27. * Please note the the name of the IRC operaor and his nick have nothing to
  28. * do with each other! The IRC operator is only identified by the name and
  29. * password configured in this structure.
  30. */
  31. struct Conf_Oper {
  32. char name[CLIENT_PASS_LEN]; /**< Name (ID) */
  33. char pwd[CLIENT_PASS_LEN]; /**< Password */
  34. char *mask; /**< Allowed host mask */
  35. };
  36. /**
  37. * Configured server.
  38. * Peers to which this daemon should establish an outgoing server link must
  39. * have set a port number; all other servers are allowed to connect to this one.
  40. */
  41. typedef struct _Conf_Server
  42. {
  43. char host[HOST_LEN]; /**< Hostname */
  44. char name[CLIENT_ID_LEN]; /**< IRC client ID */
  45. char pwd_in[CLIENT_PASS_LEN]; /**< Password which must be received */
  46. char pwd_out[CLIENT_PASS_LEN]; /**< Password to send to the peer */
  47. UINT16 port; /**< Server port to connect to */
  48. int group; /**< Group ID of this server */
  49. time_t lasttry; /**< Time of last connection attempt */
  50. PROC_STAT res_stat; /**< Status of the resolver */
  51. int flags; /**< Server flags */
  52. CONN_ID conn_id; /**< ID of server connection or NONE */
  53. ng_ipaddr_t bind_addr; /**< Source address to use for outgoing
  54. connections */
  55. ng_ipaddr_t dst_addr[2]; /**< List of addresses to connect to */
  56. #ifdef SSL_SUPPORT
  57. bool SSLConnect; /**< Establish connection using SSL? */
  58. #endif
  59. char svs_mask[CLIENT_ID_LEN]; /**< Mask of nicknames that should be
  60. treated and counted as services */
  61. } CONF_SERVER;
  62. #ifdef SSL_SUPPORT
  63. /** Configuration options required for SSL support */
  64. struct SSLOptions {
  65. char *KeyFile; /**< SSL key file */
  66. char *CertFile; /**< SSL certificate file */
  67. char *DHFile; /**< File containing DH parameters */
  68. array ListenPorts; /**< Array of listening SSL ports */
  69. array KeyFilePassword; /**< Key file password */
  70. char *CipherList; /**< Set SSL cipher list to use */
  71. };
  72. #endif
  73. /** Pre-defined channels */
  74. struct Conf_Channel {
  75. char name[CHANNEL_NAME_LEN]; /**< Name of the channel */
  76. char modes[CHANNEL_MODE_LEN]; /**< Initial channel modes */
  77. char key[CLIENT_PASS_LEN]; /**< Channel key ("password", mode "k" ) */
  78. char topic[COMMAND_LEN]; /**< Initial topic */
  79. char keyfile[512]; /**< Path and name of channel key file */
  80. unsigned long maxusers; /**< User limit for this channel, mode "l" */
  81. };
  82. #define CONF_SFLAG_ONCE 1 /* Delete this entry after next disconnect */
  83. #define CONF_SFLAG_DISABLED 2 /* This server configuration entry is disabled */
  84. /** Name (ID, "nick") of this server */
  85. GLOBAL char Conf_ServerName[CLIENT_ID_LEN];
  86. /** Server info text */
  87. GLOBAL char Conf_ServerInfo[CLIENT_INFO_LEN];
  88. /** Global server passwort */
  89. GLOBAL char Conf_ServerPwd[CLIENT_PASS_LEN];
  90. /** Administrative information */
  91. GLOBAL char Conf_ServerAdmin1[CLIENT_INFO_LEN];
  92. GLOBAL char Conf_ServerAdmin2[CLIENT_INFO_LEN];
  93. GLOBAL char Conf_ServerAdminMail[CLIENT_INFO_LEN];
  94. /** Network name (optional, no spaces allowed) */
  95. GLOBAL char Conf_Network[CLIENT_INFO_LEN];
  96. /** Message of the day (MOTD) of this server */
  97. GLOBAL array Conf_Motd;
  98. /** Help text of this server */
  99. GLOBAL array Conf_Helptext;
  100. /** Array of ports this server should listen on */
  101. GLOBAL array Conf_ListenPorts;
  102. /** Address to which sockets should be bound to or empty (=all) */
  103. GLOBAL char *Conf_ListenAddress;
  104. /** User and group ID this daemon should run with */
  105. GLOBAL uid_t Conf_UID;
  106. GLOBAL gid_t Conf_GID;
  107. /** The directory to chroot() into */
  108. GLOBAL char Conf_Chroot[FNAME_LEN];
  109. /** Full path and name of a file to which the PID of daemon should be written */
  110. GLOBAL char Conf_PidFile[FNAME_LEN];
  111. /** Timeout (in seconds) for PING commands */
  112. GLOBAL int Conf_PingTimeout;
  113. /** Timeout (in seconds) for PONG replies */
  114. GLOBAL int Conf_PongTimeout;
  115. /** Seconds between connection attempts to other servers */
  116. GLOBAL int Conf_ConnectRetry;
  117. /** Array of configured IRC operators */
  118. GLOBAL array Conf_Opers;
  119. /** Array of configured IRC servers */
  120. GLOBAL CONF_SERVER Conf_Server[MAX_SERVERS];
  121. /** Array of pre-defined channels */
  122. GLOBAL array Conf_Channels;
  123. /** String containing all locally allowed channel prefixes for new channels */
  124. GLOBAL char Conf_AllowedChannelTypes[8];
  125. /** Flag indicating if IRC operators are allowed to always use MODE (true) */
  126. GLOBAL bool Conf_OperCanMode;
  127. /** Flag indicating if IRC operators get AutoOp in persistent (+P) channels */
  128. GLOBAL bool Conf_OperChanPAutoOp;
  129. /**
  130. * If true, mask channel MODE commands of IRC operators to the server.
  131. * Background: ircd2 will ignore channel MODE commands if an IRC operator
  132. * gives channel operator privileges to someone without being a channel operator
  133. * himself. This enables a workaround: it masks the MODE command as coming
  134. * from the IRC server and not the IRC operator.
  135. */
  136. GLOBAL bool Conf_OperServerMode;
  137. /** Flag indicating if remote IRC operators are allowed to manage this server */
  138. GLOBAL bool Conf_AllowRemoteOper;
  139. /** Cloaked hostname of the clients */
  140. GLOBAL char Conf_CloakHost[CLIENT_ID_LEN];
  141. /** Cloaked hostname for clients that did +x */
  142. GLOBAL char Conf_CloakHostModeX[CLIENT_ID_LEN];
  143. /** Salt for hostname hash for cloaked hostnames */
  144. GLOBAL char Conf_CloakHostSalt[CLIENT_ID_LEN];
  145. /** Use nickname as user name? */
  146. GLOBAL bool Conf_CloakUserToNick;
  147. /** Enable all DNS functions? */
  148. GLOBAL bool Conf_DNS;
  149. /** Enable IDENT lookups, even when compiled with support for it */
  150. GLOBAL bool Conf_Ident;
  151. /** Enable "more privacy" mode and "censor" some user-related information */
  152. GLOBAL bool Conf_MorePrivacy;
  153. /** Enable "NOTICE *" messages on connect */
  154. GLOBAL bool Conf_NoticeBeforeRegistration;
  155. /** Enable all usage of PAM, even when compiled with support for it */
  156. GLOBAL bool Conf_PAM;
  157. /** Don't require all clients to send a password an to be PAM authenticated */
  158. GLOBAL bool Conf_PAMIsOptional;
  159. /** The service name to use for PAM */
  160. GLOBAL char Conf_PAMServiceName[MAX_PAM_SERVICE_NAME_LEN];
  161. /** Disable all CTCP commands except for /me ? */
  162. GLOBAL bool Conf_ScrubCTCP;
  163. /** Default user modes for new local clients */
  164. GLOBAL char Conf_DefaultUserModes[CLIENT_MODE_LEN];
  165. /*
  166. * try to connect to remote systems using the ipv6 protocol,
  167. * if they have an ipv6 address? (default yes)
  168. */
  169. GLOBAL bool Conf_ConnectIPv6;
  170. /** Try to connect to remote systems using the IPv4 protocol (true) */
  171. GLOBAL bool Conf_ConnectIPv4;
  172. /** Idle timout (seconds), after which the daemon should exit */
  173. GLOBAL int Conf_IdleTimeout;
  174. /** Maximum number of simultaneous connections to this server */
  175. GLOBAL int Conf_MaxConnections;
  176. /** Maximum number of channels a user can join */
  177. GLOBAL int Conf_MaxJoins;
  178. /** Maximum number of connections per IP address */
  179. GLOBAL int Conf_MaxConnectionsIP;
  180. /** Maximum length of a nickname */
  181. GLOBAL unsigned int Conf_MaxNickLength;
  182. /** Maximum number of channels returned to /list */
  183. GLOBAL int Conf_MaxListSize;
  184. /** Maximium seconds to add per "penalty". -1 = unlimited. */
  185. GLOBAL time_t Conf_MaxPenaltyTime;
  186. #ifndef STRICT_RFC
  187. /** Require "AUTH PING-PONG" on login */
  188. GLOBAL bool Conf_AuthPing;
  189. #endif
  190. #ifdef SYSLOG
  191. /* Syslog "facility" */
  192. GLOBAL int Conf_SyslogFacility;
  193. #endif
  194. GLOBAL void Conf_Init PARAMS((void));
  195. GLOBAL bool Conf_Rehash PARAMS((void));
  196. GLOBAL int Conf_Test PARAMS((void));
  197. GLOBAL void Conf_UnsetServer PARAMS(( CONN_ID Idx ));
  198. GLOBAL bool Conf_SetServer PARAMS(( int ConfServer, CONN_ID Idx ));
  199. GLOBAL int Conf_GetServer PARAMS(( CONN_ID Idx ));
  200. GLOBAL bool Conf_EnableServer PARAMS(( const char *Name, UINT16 Port ));
  201. GLOBAL bool Conf_EnablePassiveServer PARAMS((const char *Name));
  202. GLOBAL bool Conf_DisableServer PARAMS(( const char *Name ));
  203. GLOBAL bool Conf_AddServer PARAMS(( const char *Name, UINT16 Port, const char *Host, const char *MyPwd, const char *PeerPwd ));
  204. GLOBAL bool Conf_NickIsService PARAMS((int ConfServer, const char *Nick));
  205. GLOBAL bool Conf_NickIsBlocked PARAMS((const char *Nick));
  206. #ifdef SSL_SUPPORT
  207. GLOBAL bool Conf_SSLInUse PARAMS((void));
  208. #endif
  209. /* Password required by WEBIRC command */
  210. GLOBAL char Conf_WebircPwd[CLIENT_PASS_LEN];
  211. #ifdef DEBUG
  212. GLOBAL void Conf_DebugDump PARAMS((void));
  213. #endif
  214. #endif
  215. /* -eof- */