Changeset 123 in Main for trunk/Server/server.c
- Timestamp:
- Sep 22, 2024, 10:43:47 PM (8 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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);
Note:
See TracChangeset
for help on using the changeset viewer.