- Timestamp:
- Sep 22, 2024, 10:43:47 PM (8 weeks ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Manpage/tewi.conf.5.tmpl
r38 r123 19 19 .It Pa "LoadModule" 20 20 Loads the module. 21 .It Pa "HidePort" "ShowPort" 22 Shows/Hides the port in directory listing, and the default error page. 21 23 .It Pa "MIMEType" 22 24 Specifies the MIME type for files. -
trunk/Server/config.c
r61 r123 85 85 config.root.index_count = 0; 86 86 config.root.readme_count = 0; 87 config.root.hideport = 0; 87 88 config.vhost_count = 0; 88 89 config.module_count = 0; … … 186 187 current->index_count = 0; 187 188 current->readme_count = 0; 189 current->hideport = -1; 188 190 int i; 189 191 current->name = cm_strdup(vhost); … … 217 219 config.ports[j] = port; 218 220 } 221 } else if(cm_strcaseequ(r[0], "HidePort")) { 222 current->hideport = 1; 223 } else if(cm_strcaseequ(r[0], "ShowPort")) { 224 current->hideport = 0; 219 225 } else if(cm_strcaseequ(r[0], "SSLKey")) { 220 226 if(r[1] == NULL) { -
trunk/Server/server.c
r122 r123 285 285 } 286 286 287 char* tw_http_default_error(int code, char* name, int port ) {287 char* tw_http_default_error(int code, char* name, int port, struct tw_config_entry* vhost) { 288 288 char address[1024]; 289 sprintf(address, "<address>%s Server at %s Port %d</address>", tw_server, name, port); 289 290 if((vhost->hideport == -1 ? config.root.hideport : vhost->hideport) == 1) { 291 sprintf(address, "<address>%s Server at %s</address>", tw_server, name, port); 292 } else { 293 sprintf(address, "<address>%s Server at %s Port %d</address>", tw_server, name, port); 294 } 290 295 291 296 char* st = cm_strdup(tw_http_status(code)); … … 306 311 } 307 312 308 void tw_http_error(SSL* ssl, int sock, int error, char* name, int port ) {309 char* str = tw_http_default_error(error, name, port );313 void tw_http_error(SSL* ssl, int sock, int error, char* name, int port, struct tw_config_entry* vhost) { 314 char* str = tw_http_default_error(error, name, port, vhost); 310 315 tw_process_page(ssl, sock, tw_http_status(error), "text/html", NULL, str, strlen(str), 0, 0); 311 316 free(str); … … 526 531 } 527 532 if(co == _TW_MODULE_ERROR) { 528 tw_http_error(s, sock, (ret & 0xffff00) >> 8, name, port );533 tw_http_error(s, sock, (ret & 0xffff00) >> 8, name, port, vhost_entry); 529 534 break; 530 535 } … … 566 571 if(!rej && stat(path, &st) == 0) { 567 572 if(!tw_permission_allowed(path, addr, req, vhost_entry)) { 568 tw_http_error(s, sock, 403, name, port );573 tw_http_error(s, sock, 403, name, port, vhost_entry); 569 574 } else if(S_ISDIR(st.st_mode)) { 570 575 if(req.path[strlen(req.path) - 1] != '/') { … … 738 743 } 739 744 addstring(&str, " <hr>\n"); 740 addstring(&str, " <address>%s Server at %s Port %d</address>\n", tw_server, name, port); 745 int hp = vhost_entry->hideport == -1 ? config.root.hideport : vhost_entry->hideport; 746 if(hp == 0) { 747 addstring(&str, " <address>%s Server at %s Port %d</address>\n", tw_server, name, port); 748 } else { 749 addstring(&str, " <address>%s Server at %s</address>\n", tw_server, name, port); 750 } 741 751 addstring(&str, " </body>\n"); 742 752 addstring(&str, "</html>\n"); … … 762 772 } 763 773 } else { 764 tw_http_error(s, sock, 404, name, port );774 tw_http_error(s, sock, 404, name, port, vhost_entry); 765 775 } 766 776 free(path); … … 770 780 } else if(ret == -1) { 771 781 } else { 772 tw_http_error(s, sock, 400, name, port );782 tw_http_error(s, sock, 400, name, port, &config.root); 773 783 } 774 784 tw_free_request(&req); -
trunk/Server/tw_config.h
r81 r123 61 61 char* sslcert; 62 62 char* root; 63 int hideport; 63 64 struct tw_dir_entry dirs[MAX_DIRS]; 64 65 int dir_count; -
trunk/Server/tw_version.h
r122 r123 4 4 #define __TW_VERSION_H__ 5 5 6 #define TW_VERSION "1.0 2A\0"6 #define TW_VERSION "1.03\0" 7 7 8 8 const char* tw_get_version(void);
Note:
See TracChangeset
for help on using the changeset viewer.