1 #ifndef HTTPD_CONF_MAIN_H 2 #define HTTPD_CONF_MAIN_H 3 4 #ifndef HTTPD_H 5 # error "include just httpd.h" 6 #endif 7 8 #include "opt_serv.h" 9 #include "mime_types.h" 10 #include "date.h" 11 12 /* **** defaults for runtime conf **** */ 13 #define HTTPD_CONF_VERSION "0.99.1" 14 15 /* note that the strings are assigned in httpd_main_conf.c */ 16 17 #define HTTPD_CONF_PROG_NAME "jhttpd" 18 #define HTTPD_CONF_SERVER_COMMENT "(Vstr)" 19 #define HTTPD_CONF_DEF_SERVER_NAME \ 20 HTTPD_CONF_PROG_NAME "/" \ 21 HTTPD_CONF_VERSION " " HTTPD_CONF_SERVER_COMMENT 22 #define HTTPD_CONF_USE_MMAP FALSE 23 #define HTTPD_CONF_USE_SENDFILE TRUE 24 #define HTTPD_CONF_USE_KEEPA TRUE 25 #define HTTPD_CONF_USE_KEEPA_1_0 TRUE 26 #define HTTPD_CONF_USE_VHOSTS_NAME FALSE 27 #define HTTPD_CONF_USE_RANGE TRUE 28 #define HTTPD_CONF_USE_RANGE_1_0 TRUE 29 #define HTTPD_CONF_USE_PUBLIC_ONLY FALSE 30 #define HTTPD_CONF_USE_ENC_CONTENT_REPLACEMENT TRUE 31 #define HTTPD_CONF_DEF_DIR_FILENAME "index.html" 32 #define HTTPD_CONF_MIME_TYPE_DEF_CT "" /* "application/octet-stream" */ 33 #define HTTPD_CONF_MIME_TYPE_MAIN "/etc/mime.types" 34 #define HTTPD_CONF_MIME_TYPE_XTRA "" 35 #define HTTPD_CONF_USE_ERR_406 TRUE 36 #define HTTPD_CONF_USE_CANONIZE_HOST FALSE 37 #define HTTPD_CONF_USE_HOST_ERR_400 TRUE 38 #define HTTPD_CONF_USE_HOST_ERR_CHK TRUE 39 #define HTTPD_CONF_USE_x2_HDR_CHK TRUE 40 #define HTTPD_CONF_USE_TRACE_OP TRUE 41 #define HTTPD_CONF_USE_REMOVE_FRAG TRUE 42 #define HTTPD_CONF_USE_REMOVE_QUERY FALSE 43 #define HTTPD_CONF_USE_SECURE_DIRS TRUE 44 #define HTTPD_CONF_USE_FRIENDLY_DIRS TRUE 45 #define HTTPD_CONF_USE_POSIX_FADVISE TRUE /* NOTE that this SEGV's on FC1 */ 46 #define HTTPD_CONF_USE_TCP_CORK TRUE 47 #define HTTPD_CONF_USE_REQ_CONF TRUE 48 #define HTTPD_CONF_USE_ALLOW_HDR_SPLIT TRUE 49 #define HTTPD_CONF_USE_ALLOW_HDR_NIL TRUE 50 #define HTTPD_CONF_USE_CHK_DOT_DIR TRUE 51 #define HTTPD_CONF_USE_CHK_ENCODED_SLASH TRUE 52 #define HTTPD_CONF_USE_CHK_ENCODED_DOT TRUE 53 #define HTTPD_CONF_USE_NON_SPC_HDRS TRUE 54 #define HTTPD_CONF_ADD_DEF_PORT TRUE 55 #define HTTPD_CONF_MAX_REQUESTS 0 56 #define HTTPD_CONF_MAX_NEG_A_NODES 8 57 #define HTTPD_CONF_MAX_NEG_AL_NODES 0 58 #define HTTPD_CONF_MAX_A_NODES 128 /* lynx uses 53 */ 59 #define HTTPD_CONF_MAX_AC_NODES 8 60 #define HTTPD_CONF_MAX_AE_NODES 32 61 #define HTTPD_CONF_MAX_AL_NODES 16 62 #define HTTPD_CONF_MAX_CONNECTION_NODES 64 63 #define HTTPD_CONF_MAX_ETAG_NODES 16 64 #define HTTPD_CONF_MAX_RANGE_NODES 1 /* zsync needs more */ 65 #define HTTPD_CONF_REQ_CONF_MAXSZ (16 * 1024) 66 67 /* this is configurable, but is much higher than EX_MAX_R_DATA_INCORE due to 68 * allowing largish requests with HTTP */ 69 #ifdef VSTR_AUTOCONF_NDEBUG 70 # define HTTPD_CONF_INPUT_MAXSZ ( 1 * 1024 * 1024) 71 #else 72 # define HTTPD_CONF_INPUT_MAXSZ (128 * 1024) /* debug */ 73 #endif 74 75 typedef struct Httpd_policy_opts 76 { 77 Opt_serv_policy_opts s[1]; 78 79 Vstr_base *document_root; 80 Vstr_base *server_name; 81 Vstr_base *dir_filename; 82 Mime_types mime_types[1]; 83 Vstr_base *mime_types_def_ct; 84 Vstr_base *mime_types_main; 85 Vstr_base *mime_types_xtra; 86 Vstr_base *default_hostname; 87 Vstr_base *req_conf_dir; 88 Vstr_base *req_err_dir; 89 Vstr_base *auth_realm; 90 Vstr_base *auth_token; 91 92 unsigned int use_mmap : 1; 93 unsigned int use_sendfile : 1; 94 unsigned int use_keep_alive : 1; 95 unsigned int use_keep_alive_1_0 : 1; 96 unsigned int use_vhosts_name : 1; 97 unsigned int use_range : 1; 98 unsigned int use_range_1_0 : 1; 99 unsigned int use_public_only : 1; /* 8th bitfield */ 100 unsigned int use_enc_content_replacement : 1; 101 102 unsigned int use_err_406 : 1; 103 unsigned int use_canonize_host : 1; 104 unsigned int use_host_err_400 : 1; 105 unsigned int use_host_err_chk : 1; 106 unsigned int use_x2_hdr_chk : 1; 107 unsigned int use_trace_op : 1; 108 unsigned int remove_url_frag : 1; 109 unsigned int remove_url_query : 1; 110 unsigned int use_secure_dirs : 1; 111 unsigned int use_friendly_dirs : 1; 112 113 unsigned int use_posix_fadvise : 1; 114 unsigned int use_tcp_cork : 1; 115 116 unsigned int use_req_conf : 1; 117 unsigned int allow_hdr_split : 1; /* 16th bitfield */ 118 unsigned int allow_hdr_nil : 1; 119 120 unsigned int chk_dot_dir : 1; 121 122 unsigned int chk_encoded_slash : 1; 123 unsigned int chk_encoded_dot : 1; 124 125 unsigned int add_def_port : 1; 126 127 unsigned int use_non_spc_hdrs : 1; /* 22nd bitfield */ 128 129 unsigned int max_header_sz; 130 131 unsigned int max_requests; 132 133 unsigned int max_neg_A_nodes; 134 unsigned int max_neg_AL_nodes; 135 136 unsigned int max_A_nodes; 137 unsigned int max_AC_nodes; 138 unsigned int max_AE_nodes; 139 unsigned int max_AL_nodes; 140 141 unsigned int max_connection_nodes; 142 unsigned int max_etag_nodes; 143 144 unsigned int max_range_nodes; 145 146 unsigned int max_req_conf_sz; 147 } Httpd_policy_opts; /* NOTE: remember to copy changes to 148 * httpd_policy.c:httpd_policy_init 149 * httpd_policy.c:httpd_policy_copy */ 150 151 typedef struct Httpd_opts 152 { 153 Opt_serv_opts s[1]; 154 155 time_t beg_time; 156 157 Date_store *date; 158 159 Conf_parse *conf; 160 unsigned int conf_num; 161 162 Conf_token match_connection[1]; 163 Conf_token tmp_match_connection[1]; 164 Conf_token match_request[1]; 165 Conf_token tmp_match_request[1]; 166 } Httpd_opts; 167 #define HTTPD_CONF_MAIN_DECL_OPTS(N) \ 168 Httpd_opts N[1] = { \ 169 { \ 170 {{OPT_SERV_CONF_INIT_OPTS(HTTPD_CONF_PROG_NAME, HTTPD_CONF_VERSION)}}, \ 171 (time_t)-1, \ 172 NULL, \ 173 NULL, \ 174 0, \ 175 {CONF_TOKEN_INIT}, \ 176 {CONF_TOKEN_INIT}, \ 177 {CONF_TOKEN_INIT}, \ 178 {CONF_TOKEN_INIT}, \ 179 } \ 180 } 181 182 extern int httpd_conf_main_init(Httpd_opts *); 183 extern void httpd_conf_main_free(Httpd_opts *); 184 185 extern int httpd_policy_connection(struct Con *, 186 Conf_parse *, const Conf_token *); 187 extern int httpd_policy_request(struct Con *, struct Httpd_req_data *, 188 Conf_parse *, const Conf_token *); 189 190 191 extern int httpd_conf_main(Httpd_opts *, Conf_parse *, Conf_token *); 192 extern int httpd_conf_main_parse_cstr(Vstr_base *, Httpd_opts *, const char *); 193 extern int httpd_conf_main_parse_file(Vstr_base *, Httpd_opts *, const char *); 194 195 #endif 196