Changeset 12 in Main for trunk/Server/server.c
- Timestamp:
- Sep 13, 2024, 10:36:03 PM (2 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Server/server.c
r11 r12 3 3 #include "tw_server.h" 4 4 5 #include "tw_ssl.h" 5 6 #include "tw_config.h" 6 7 … … 115 116 struct pass_entry { 116 117 int sock; 118 int port; 117 119 bool ssl; 118 120 }; … … 121 123 int sock = ((struct pass_entry*)ptr)->sock; 122 124 bool ssl = ((struct pass_entry*)ptr)->ssl; 125 int port = ((struct pass_entry*)ptR)->port; 126 free(ptr); 123 127 #else 124 void tw_server_pass(int sock, bool ssl ) {128 void tw_server_pass(int sock, bool ssl, int port) { 125 129 #endif 130 SSL_CTX* ctx = NULL; 131 SSL* s = NULL; 132 if(ssl) { 133 ctx = tw_create_ssl_ctx(port); 134 s = SSL_new(ctx); 135 SSL_set_fd(s, sock); 136 if(SSL_accept(s) <= 0) goto cleanup; 137 } 138 cleanup: 126 139 close_socket(sock); 127 140 #ifdef __MINGW32__ … … 151 164 int clen = sizeof(claddr); 152 165 int sock = accept(sockets[i], (struct sockaddr*)&claddr, &clen); 166 cm_log("Server", "New connection accepted"); 153 167 #ifdef __MINGW32__ 154 168 HANDLE thread; … … 156 170 e->sock = sock; 157 171 e->ssl = config.ports[i] & (1ULL << 32); 172 e->port = config.ports[i]; 158 173 thread = (HANDLE)_beginthreadex(NULL, 0, tw_server_pass, e, 0, NULL); 159 174 #else 160 175 pid_t pid = fork(); 161 176 if(pid == 0) { 162 tw_server_pass(sock, config.ports[i] & (1ULL << 32) );177 tw_server_pass(sock, config.ports[i] & (1ULL << 32), config.ports[i]); 163 178 _exit(0); 164 179 } else {
Note:
See TracChangeset
for help on using the changeset viewer.