conf.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /*
  2. * ngIRCd -- The Next Generation IRC Daemon
  3. * Copyright (c)2001-2011 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 nick names 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. /**
  123. * If true, mask channel MODE commands of IRC operators to the server.
  124. * Background: ircd2 will ignore channel MODE commands if an IRC operator
  125. * gives chanel operator privileges to someone without being a channel operator
  126. * himself. This enables a workaround: it masks the MODE command as coming
  127. * from the IRC server and not the IRC operator.
  128. */
  129. GLOBAL bool Conf_OperServerMode;
  130. /** Flag indicating if remote IRC operators are allowed to manage this server */
  131. GLOBAL bool Conf_AllowRemoteOper;
  132. /** Cloaked hostname of the clients */
  133. GLOBAL char Conf_CloakHost[CLIENT_ID_LEN];
  134. /** Use nick name as user name? */
  135. GLOBAL bool Conf_CloakUserToNick;
  136. /** Enable all DNS functions? */
  137. GLOBAL bool Conf_DNS;
  138. /** Enable IDENT lookups, even when compiled with support for it */
  139. GLOBAL bool Conf_Ident;
  140. /** Enable "more privacy" mode and "censor" some user-related information */
  141. GLOBAL bool Conf_MorePrivacy;
  142. /** Enable NOTICE AUTH messages on connect */
  143. GLOBAL bool Conf_NoticeAuth;
  144. /** Enable all usage of PAM, even when compiled with support for it */
  145. GLOBAL bool Conf_PAM;
  146. /** Disable all CTCP commands except for /me ? */
  147. GLOBAL bool Conf_ScrubCTCP;
  148. /*
  149. * try to connect to remote systems using the ipv6 protocol,
  150. * if they have an ipv6 address? (default yes)
  151. */
  152. GLOBAL bool Conf_ConnectIPv6;
  153. /** Try to connect to remote systems using the IPv4 protocol (true) */
  154. GLOBAL bool Conf_ConnectIPv4;
  155. /** Maximum number of simultaneous connections to this server */
  156. GLOBAL long Conf_MaxConnections;
  157. /** Maximum number of channels a user can join */
  158. GLOBAL int Conf_MaxJoins;
  159. /** Maximum number of connections per IP address */
  160. GLOBAL int Conf_MaxConnectionsIP;
  161. /** Maximum length of a nick name */
  162. GLOBAL unsigned int Conf_MaxNickLength;
  163. #ifndef STRICT_RFC
  164. /** Require "AUTH PING-PONG" on login */
  165. GLOBAL bool Conf_AuthPing;
  166. #endif
  167. #ifdef SYSLOG
  168. /* Syslog "facility" */
  169. GLOBAL int Conf_SyslogFacility;
  170. #endif
  171. GLOBAL void Conf_Init PARAMS((void));
  172. GLOBAL bool Conf_Rehash PARAMS((void));
  173. GLOBAL int Conf_Test PARAMS((void));
  174. GLOBAL void Conf_UnsetServer PARAMS(( CONN_ID Idx ));
  175. GLOBAL void Conf_SetServer PARAMS(( int ConfServer, CONN_ID Idx ));
  176. GLOBAL int Conf_GetServer PARAMS(( CONN_ID Idx ));
  177. GLOBAL bool Conf_EnableServer PARAMS(( const char *Name, UINT16 Port ));
  178. GLOBAL bool Conf_EnablePassiveServer PARAMS((const char *Name));
  179. GLOBAL bool Conf_DisableServer PARAMS(( const char *Name ));
  180. GLOBAL bool Conf_AddServer PARAMS(( const char *Name, UINT16 Port, const char *Host, const char *MyPwd, const char *PeerPwd ));
  181. GLOBAL bool Conf_IsService PARAMS((int ConfServer, const char *Nick));
  182. /* Password required by WEBIRC command */
  183. GLOBAL char Conf_WebircPwd[CLIENT_PASS_LEN];
  184. #ifdef DEBUG
  185. GLOBAL void Conf_DebugDump PARAMS((void));
  186. #endif
  187. #endif
  188. /* -eof- */