conf.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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 that the name of the IRC operator 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[512]; /**< Initial channel modes to evaluate */
  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. unsigned int modes_num; /**< Number of channel modes to evaluate */
  82. };
  83. #define CONF_SFLAG_ONCE 1 /* Delete this entry after next disconnect */
  84. #define CONF_SFLAG_DISABLED 2 /* This server configuration entry is disabled */
  85. /** Name (ID, "nick") of this server */
  86. GLOBAL char Conf_ServerName[CLIENT_ID_LEN];
  87. /** Server info text */
  88. GLOBAL char Conf_ServerInfo[CLIENT_INFO_LEN];
  89. /** Global server passwort */
  90. GLOBAL char Conf_ServerPwd[CLIENT_PASS_LEN];
  91. /** Administrative information */
  92. GLOBAL char Conf_ServerAdmin1[CLIENT_INFO_LEN];
  93. GLOBAL char Conf_ServerAdmin2[CLIENT_INFO_LEN];
  94. GLOBAL char Conf_ServerAdminMail[CLIENT_INFO_LEN];
  95. /** Network name (optional, no spaces allowed) */
  96. GLOBAL char Conf_Network[CLIENT_INFO_LEN];
  97. /** Message of the day (MOTD) of this server */
  98. GLOBAL array Conf_Motd;
  99. /** Help text of this server */
  100. GLOBAL array Conf_Helptext;
  101. /** Array of ports this server should listen on */
  102. GLOBAL array Conf_ListenPorts;
  103. /** Address to which sockets should be bound to or empty (=all) */
  104. GLOBAL char *Conf_ListenAddress;
  105. /** User and group ID this daemon should run with */
  106. GLOBAL uid_t Conf_UID;
  107. GLOBAL gid_t Conf_GID;
  108. /** The directory to chroot() into */
  109. GLOBAL char Conf_Chroot[FNAME_LEN];
  110. /** Full path and name of a file to which the PID of daemon should be written */
  111. GLOBAL char Conf_PidFile[FNAME_LEN];
  112. /** Timeout (in seconds) for PING commands */
  113. GLOBAL int Conf_PingTimeout;
  114. /** Timeout (in seconds) for PONG replies */
  115. GLOBAL int Conf_PongTimeout;
  116. /** Seconds between connection attempts to other servers */
  117. GLOBAL int Conf_ConnectRetry;
  118. /** Array of configured IRC operators */
  119. GLOBAL array Conf_Opers;
  120. /** Array of configured IRC servers */
  121. GLOBAL CONF_SERVER Conf_Server[MAX_SERVERS];
  122. /** Array of pre-defined channels */
  123. GLOBAL array Conf_Channels;
  124. /** String containing all locally allowed channel prefixes for new channels */
  125. GLOBAL char Conf_AllowedChannelTypes[8];
  126. /** Flag indicating if IRC operators are allowed to always use MODE (true) */
  127. GLOBAL bool Conf_OperCanMode;
  128. /** Flag indicating if IRC operators get AutoOp in persistent (+P) channels */
  129. GLOBAL bool Conf_OperChanPAutoOp;
  130. /**
  131. * If true, mask channel MODE commands of IRC operators to the server.
  132. * Background: ircd2 will ignore channel MODE commands if an IRC operator
  133. * gives channel operator privileges to someone without being a channel operator
  134. * himself. This enables a workaround: it masks the MODE command as coming
  135. * from the IRC server and not the IRC operator.
  136. */
  137. GLOBAL bool Conf_OperServerMode;
  138. /** Flag indicating if remote IRC operators are allowed to manage this server */
  139. GLOBAL bool Conf_AllowRemoteOper;
  140. /** Cloaked hostname of the clients */
  141. GLOBAL char Conf_CloakHost[CLIENT_ID_LEN];
  142. /** Cloaked hostname for clients that did +x */
  143. GLOBAL char Conf_CloakHostModeX[CLIENT_ID_LEN];
  144. /** Salt for hostname hash for cloaked hostnames */
  145. GLOBAL char Conf_CloakHostSalt[CLIENT_ID_LEN];
  146. /** Use nickname as user name? */
  147. GLOBAL bool Conf_CloakUserToNick;
  148. /** Enable all DNS functions? */
  149. GLOBAL bool Conf_DNS;
  150. /** Enable IDENT lookups, even when compiled with support for it */
  151. GLOBAL bool Conf_Ident;
  152. /** Enable "more privacy" mode and "censor" some user-related information */
  153. GLOBAL bool Conf_MorePrivacy;
  154. /** Enable "NOTICE *" messages on connect */
  155. GLOBAL bool Conf_NoticeBeforeRegistration;
  156. /** Enable all usage of PAM, even when compiled with support for it */
  157. GLOBAL bool Conf_PAM;
  158. /** Don't require all clients to send a password an to be PAM authenticated */
  159. GLOBAL bool Conf_PAMIsOptional;
  160. /** The service name to use for PAM */
  161. GLOBAL char Conf_PAMServiceName[MAX_PAM_SERVICE_NAME_LEN];
  162. /** Disable all CTCP commands except for /me ? */
  163. GLOBAL bool Conf_ScrubCTCP;
  164. /** Default user modes for new local clients */
  165. GLOBAL char Conf_DefaultUserModes[CLIENT_MODE_LEN];
  166. /*
  167. * try to connect to remote systems using the ipv6 protocol,
  168. * if they have an ipv6 address? (default yes)
  169. */
  170. GLOBAL bool Conf_ConnectIPv6;
  171. /** Try to connect to remote systems using the IPv4 protocol (true) */
  172. GLOBAL bool Conf_ConnectIPv4;
  173. /** Idle timout (seconds), after which the daemon should exit */
  174. GLOBAL int Conf_IdleTimeout;
  175. /** Maximum number of simultaneous connections to this server */
  176. GLOBAL int Conf_MaxConnections;
  177. /** Maximum number of channels a user can join */
  178. GLOBAL int Conf_MaxJoins;
  179. /** Maximum number of connections per IP address */
  180. GLOBAL int Conf_MaxConnectionsIP;
  181. /** Maximum length of a nickname */
  182. GLOBAL unsigned int Conf_MaxNickLength;
  183. /** Maximum number of channels returned to /list */
  184. GLOBAL int Conf_MaxListSize;
  185. /** Maximium seconds to add per "penalty". -1 = unlimited. */
  186. GLOBAL time_t Conf_MaxPenaltyTime;
  187. #ifndef STRICT_RFC
  188. /** Require "AUTH PING-PONG" on login */
  189. GLOBAL bool Conf_AuthPing;
  190. #endif
  191. #ifdef SYSLOG
  192. /* Syslog "facility" */
  193. GLOBAL int Conf_SyslogFacility;
  194. #endif
  195. GLOBAL void Conf_Init PARAMS((void));
  196. GLOBAL bool Conf_Rehash PARAMS((void));
  197. GLOBAL int Conf_Test PARAMS((void));
  198. GLOBAL void Conf_UnsetServer PARAMS(( CONN_ID Idx ));
  199. GLOBAL bool Conf_SetServer PARAMS(( int ConfServer, CONN_ID Idx ));
  200. GLOBAL int Conf_GetServer PARAMS(( CONN_ID Idx ));
  201. GLOBAL bool Conf_EnableServer PARAMS(( const char *Name, UINT16 Port ));
  202. GLOBAL bool Conf_EnablePassiveServer PARAMS((const char *Name));
  203. GLOBAL bool Conf_DisableServer PARAMS(( const char *Name ));
  204. GLOBAL bool Conf_AddServer PARAMS(( const char *Name, UINT16 Port, const char *Host, const char *MyPwd, const char *PeerPwd ));
  205. GLOBAL bool Conf_NickIsService PARAMS((int ConfServer, const char *Nick));
  206. GLOBAL bool Conf_NickIsBlocked PARAMS((const char *Nick));
  207. #ifdef SSL_SUPPORT
  208. GLOBAL bool Conf_SSLInUse PARAMS((void));
  209. #endif
  210. /* Password required by WEBIRC command */
  211. GLOBAL char Conf_WebircPwd[CLIENT_PASS_LEN];
  212. #ifdef DEBUG
  213. GLOBAL void Conf_DebugDump PARAMS((void));
  214. #endif
  215. #endif
  216. /* -eof- */