- Timestamp:
- Sep 21, 2024, 5:40:13 PM (8 weeks ago)
- Location:
- trunk/Server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Server/main.c
r95 r116 9 9 #include <string.h> 10 10 #include <signal.h> 11 #include <stdlib.h> 11 12 12 13 #ifndef NO_SSL -
trunk/Server/server.c
r105 r116 31 31 32 32 #ifdef __MINGW32__ 33 #include <ws2tcpip.h> 34 #include <wspiapi.h> 33 35 #include <winsock2.h> 34 36 #include <process.h> … … 42 44 #include <netinet/in.h> 43 45 #include <netinet/tcp.h> 46 #include <netdb.h> 44 47 #endif 45 48 … … 433 436 void* s = NULL; 434 437 #endif 438 439 char address[513]; 440 address[0] = 0; 441 struct sockaddr* sa = (struct sockaddr*)&addr; 442 getnameinfo(sa, sizeof(addr), address, 512, NULL, 0, NI_NUMERICHOST); 443 435 444 struct tw_http_request req; 436 445 struct tw_http_response res; … … 440 449 int ret = tw_http_parse(s, sock, &req); 441 450 if(ret == 0) { 451 char date[513]; 452 time_t t = time(NULL); 453 struct tm* tm = localtime(&t); 454 strftime(date, 512, "%a, %d %b %Y %H:%M:%S %Z", tm); 455 456 char* useragent = cm_strdup(""); 457 458 int i; 459 for(i = 0; req.headers[i] != NULL; i += 2){ 460 if(cm_strcaseequ(req.headers[i], "User-Agent")){ 461 free(useragent); 462 useragent = cm_strdup(req.headers[i + 1]); 463 } 464 } 465 466 char* tmp = cm_strcat3(address, " - [", date); 467 char* tmp2 = cm_strcat3(tmp, "] \"", req.method); 468 char* tmp3 = cm_strcat3(tmp2, " ", req.path); 469 char* tmp4 = cm_strcat3(tmp3, " ", req.version); 470 char* tmp5 = cm_strcat3(tmp4, "\" \"", useragent); 471 char* log = cm_strcat(tmp5, "\""); 472 free(tmp); 473 free(tmp2); 474 free(tmp3); 475 free(tmp4); 476 free(tmp5); 477 free(useragent); 478 cm_force_log(log); 479 free(log); 480 442 481 char* vhost = cm_strdup(config.hostname); 443 int i;444 482 time_t cmtime = 0; 445 483 if(req.headers != NULL) {
Note:
See TracChangeset
for help on using the changeset viewer.