conf.h 8.9 KB

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