1 /* Icecast 2 * 3 * This program is distributed under the GNU General Public License, version 2. 4 * A copy of this license is included with this source. 5 * 6 * Copyright 2000-2004, Jack Moffitt <jack@xiph.org, 7 * Michael Smith <msmith@xiph.org>, 8 * oddsock <oddsock@xiph.org>, 9 * Karl Heyes <karl@xiph.org> 10 * and others (see AUTHORS for details). 11 */ 12 13 #ifndef __CFGFILE_H__ 14 #define __CFGFILE_H__ 15 16 #define CONFIG_EINSANE -1 17 #define CONFIG_ENOROOT -2 18 #define CONFIG_EBADROOT -3 19 #define CONFIG_EPARSE -4 20 21 #define MAX_YP_DIRECTORIES 25 22 23 #define XMLSTR (xmlChar *) 24 25 struct _mount_proxy; 26 struct ice_config_tag; 27 typedef struct _listener_t listener_t; 28 29 #include "avl/avl.h" 30 #include "auth.h" 31 #include "compat.h" 32 33 34 typedef struct _redirect_host 35 { 36 struct _redirect_host *next; 37 time_t next_update; 38 char *server; 39 int port; 40 } redirect_host; 41 42 43 typedef struct access_log 44 { 45 char *name; 46 int logid; 47 int log_ip; 48 int qstr; 49 int type; 50 int archive; 51 int display; 52 long size; 53 unsigned duration; 54 char *exclude_ext; 55 } access_log; 56 57 #define LOG_ACCESS_CLF 0 58 #define LOG_ACCESS_CLF_ESC 1 59 60 typedef struct error_log 61 { 62 char *name; 63 int logid; 64 int archive; 65 int display; 66 long size; 67 unsigned duration; 68 int level; 69 } error_log; 70 71 typedef struct playlist_log 72 { 73 char *name; 74 int logid; 75 int archive; 76 int display; 77 long size; 78 unsigned duration; 79 } playlist_log; 80 81 typedef struct error_log preroll_log; 82 83 84 typedef struct ice_config_dir_tag 85 { 86 char *host; 87 int touch_interval; 88 struct ice_config_dir_tag *next; 89 } ice_config_dir_t; 90 91 typedef struct _config_options { 92 char *name; 93 char *value; 94 struct _config_options *next; 95 } config_options_t; 96 97 typedef struct _mount_proxy { 98 char *mountname; /* The mountpoint this proxy is used for */ 99 100 char *username; /* Username and password for this mountpoint. If unset, */ 101 char *password; /* falls back to global source password */ 102 103 char *dumpfile; /* Filename to dump this stream to (will be appended). NULL 104 to not dump. */ 105 char *intro_filename; /* Send contents of file to client before the stream */ 106 107 /* whether to allow matching files to work with http ranges */ 108 int file_seekable; 109 110 int fallback_when_full; /* switch new listener to fallback source 111 when max listeners reached */ 112 /* Max bandwidth (kbps) for this mountpoint only. -1 (default) is not specified */ 113 int64_t max_bandwidth; 114 115 int max_listeners; /* Max listeners for this mountpoint only. -1 to not 116 limit here (i.e. only use the global limit) */ 117 char *fallback_mount; /* Fallback mountname */ 118 119 int fallback_override; /* When this source arrives, do we steal back 120 clients from the fallback? */ 121 int ban_client; /* do we add a client on this to the ban list automatically */ 122 int no_mount; /* Do we permit direct requests of this mountpoint? (or only 123 indirect, through fallbacks) */ 124 int so_sndbuf; /* TCP send buffer size for new clients */ 125 uint32_t burst_size; 126 uint32_t min_queue_size; /* minimum length of queue */ 127 uint32_t queue_size_limit; 128 int hidden; /* Do we list this on the xsl pages */ 129 unsigned int source_timeout; /* source timeout in seconds */ 130 char *charset; /* character set if not utf8 */ 131 int allow_chunked; /* allow chunked transfers */ 132 int mp3_meta_interval; /* outgoing per-stream metadata interval */ 133 int max_send_size; 134 int filter_theora; /* prevent theora pages getting queued */ 135 int url_ogg_meta; /* enable to allow updates via url requests for ogg */ 136 int ogg_passthrough; /* enable to prevent the ogg stream being rebuilt */ 137 int admin_comments_only; /* enable to only show comments set from the admin page */ 138 int skip_accesslog; /* skip logging client to access log */ 139 int intro_skip_replay; /* duration to cache IPs, for intro playing */ 140 141 int64_t limit_rate; 142 143 /* duration (secs) for mountpoint to be kept reserved after source client exits */ 144 int wait_time; 145 146 char *auth_type; /* Authentication type */ 147 struct auth_tag *auth; 148 char *cluster_password; 149 config_options_t *auth_options; /* Options for this type */ 150 char *on_connect; 151 char *on_disconnect; 152 unsigned int max_stream_duration; 153 unsigned int max_listener_duration; 154 155 struct access_log access_log; 156 preroll_log preroll_log; 157 158 char *redirect; 159 char *stream_name; 160 char *stream_description; 161 char *stream_url; 162 char *stream_genre; 163 char *bitrate; 164 char *type; 165 char *subtype; 166 int yp_public; 167 168 struct _mount_proxy *next; 169 } mount_proxy; 170 171 typedef struct _aliases { 172 char *source; 173 char *destination; 174 int port; 175 char *bind_address; 176 struct _aliases *next; 177 }aliases; 178 179 180 struct xforward_entry 181 { 182 char *ip; 183 struct xforward_entry *next; 184 }; 185 186 187 struct _listener_t 188 { 189 struct _listener_t *next; 190 int refcount; 191 int port; 192 char *bind_address; 193 char *shoutcast_mount; 194 int qlen; 195 int shoutcast_compat; 196 int ssl; 197 int so_sndbuf; 198 int so_mss; 199 }; 200 201 202 #define RELAY_RUNNING 1 203 #define RELAY_CLEANUP (1<<1) 204 #define RELAY_ON_DEMAND (1<<2) 205 #define RELAY_ICY_META (1<<3) 206 #define RELAY_FROM_MASTER (1<<4) 207 #define RELAY_SLAVE (1<<5) 208 #define RELAY_IN_LIST (1<<6) 209 210 typedef struct _relay_server_host 211 { 212 struct _relay_server_host *next; 213 char *ip; 214 char *bind; 215 char *mount; 216 int port; 217 int timeout; 218 int skip; 219 } relay_server_host; 220 221 222 typedef struct _relay_server 223 { 224 struct _relay_server *new_details; 225 struct source_tag *source; 226 time_t updated; 227 int interval; 228 int run_on; 229 unsigned char type; 230 unsigned char flags; 231 char *localmount; 232 relay_server_host *hosts, *in_use; 233 char *username; 234 char *password; 235 } relay_server; 236 237 238 typedef struct 239 { 240 char *hostname; 241 int port; 242 char *username; 243 char *password; 244 } ice_master_details; 245 246 247 typedef struct ice_config_tag 248 { 249 char *config_filename; 250 251 char *gitversion; 252 char *location; 253 char *admin; 254 255 int client_limit; 256 int source_limit; 257 unsigned int queue_size_limit; 258 int min_queue_size; 259 int workers_count; 260 uint32_t burst_size; 261 int client_timeout; 262 int header_timeout; 263 int source_timeout; 264 int ice_login; 265 int64_t max_bandwidth; 266 int max_listeners; 267 int fileserve; 268 int on_demand; /* global setting for all relays */ 269 270 char *shoutcast_mount; 271 char *source_password; 272 char *admin_username; 273 char *admin_password; 274 char *relay_username; 275 char *relay_password; 276 277 int inactivity_timeout; 278 int touch_interval; 279 ice_config_dir_t *dir_list; 280 281 char *hostname; 282 int port; 283 char *mimetypes_fn; 284 285 listener_t *listen_sock; 286 unsigned int listen_sock_count; 287 288 char *master_server; 289 int master_server_port; 290 int master_update_interval; 291 char *master_bind; 292 char *master_username; 293 char *master_password; 294 int master_relay_auth; 295 int master_relay_retry; 296 int master_ssl_port; 297 int master_redirect; 298 int master_run_on; 299 int max_redirects; 300 struct _redirect_host *redirect_hosts; 301 struct xforward_entry *xforward; 302 303 relay_server *relays; 304 305 mount_proxy *mounts; 306 avl_tree *mounts_tree; 307 308 char *server_id; 309 char *base_dir; 310 char *log_dir; 311 char *pidfile; 312 char *banfile; 313 char *allowfile; 314 char *agentfile; 315 char *cert_file; 316 char *key_file; 317 char *ca_file; 318 char *cipher_list; 319 char *webroot_dir; 320 char *adminroot_dir; 321 struct _aliases *aliases; 322 unsigned slaves_count; 323 324 struct access_log access_log; 325 struct error_log error_log; 326 struct playlist_log playlist_log; 327 preroll_log preroll_log; 328 329 int chroot; 330 int chuid; 331 char *user; 332 char *group; 333 char *yp_url[MAX_YP_DIRECTORIES]; 334 int yp_url_timeout[MAX_YP_DIRECTORIES]; 335 int yp_touch_interval[MAX_YP_DIRECTORIES]; 336 int num_yp_directories; 337 } ice_config_t; 338 339 typedef struct { 340 rwlock_t config_lock; 341 } ice_config_locks; 342 343 void config_initialize(void); 344 void config_shutdown(void); 345 346 int config_parse_file(const char *filename, ice_config_t *configuration); 347 int config_initial_parse_file(const char *filename); 348 int config_parse_cmdline(int arg, char **argv); 349 void config_set_config (ice_config_t *new_config, ice_config_t *old_config); 350 listener_t *config_clear_listener (listener_t *listener); 351 relay_server *config_clear_relay (relay_server *relay); 352 void config_clear(ice_config_t *config); 353 mount_proxy *config_find_mount (ice_config_t *config, const char *mount); 354 void config_xml_parse_failure (void*x, xmlErrorPtr error); 355 int config_qsizing_conv_a2n (const char *str, uint32_t *p); 356 357 int config_rehash(void); 358 359 ice_config_locks *config_locks(void); 360 361 ice_config_t *config_get_config(void); 362 ice_config_t *config_grab_config(void); 363 void config_release_config(void); 364 365 /* To be used ONLY in one-time startup code */ 366 ice_config_t *config_get_config_unlocked(void); 367 368 #endif /* __CFGFILE_H__ */ 369 370 371 372