conf.h 8.1 KB

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