Fossil SCM
Use the BIO_ADDR_hostname_string() function from OpenSSL to obtain the IP address of the remote side, if that function is available.
Commit
8a4ad5cb547518dc75118c510b6e5c50ec1ced5671626c5ef490cb3d9e4cbcf7
Parent
1614c9b5d06ee65…
1 file changed
+8
-1
+8
-1
| --- src/http_ssl.c | ||
| +++ src/http_ssl.c | ||
| @@ -387,13 +387,20 @@ | ||
| 387 | 387 | /* Set the Global.zIpAddr variable to the server we are talking to. |
| 388 | 388 | ** This is used to populate the ipaddr column of the rcvfrom table, |
| 389 | 389 | ** if any files are received from the server. |
| 390 | 390 | */ |
| 391 | 391 | { |
| 392 | +#if OPENSSL_VERSION_NUMBER < 0x10100000 | |
| 392 | 393 | /* IPv4 only code */ |
| 393 | - const unsigned char *ip = (const unsigned char *) BIO_ptr_ctrl(iBio,BIO_C_GET_CONNECT,2); | |
| 394 | + const unsigned char *ip; | |
| 395 | + ip = (const unsigned char*)BIO_ptr_ctrl(iBio,BIO_C_GET_CONNECT,2); | |
| 394 | 396 | g.zIpAddr = mprintf("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); |
| 397 | +#else | |
| 398 | + char *ip = BIO_ADDR_hostname_string(BIO_get_conn_address(iBio),1); | |
| 399 | + g.zIpAddr = mprintf("%s", ip); | |
| 400 | + OPENSSL_free(ip); | |
| 401 | +#endif | |
| 395 | 402 | } |
| 396 | 403 | |
| 397 | 404 | X509_free(cert); |
| 398 | 405 | return 0; |
| 399 | 406 | } |
| 400 | 407 |
| --- src/http_ssl.c | |
| +++ src/http_ssl.c | |
| @@ -387,13 +387,20 @@ | |
| 387 | /* Set the Global.zIpAddr variable to the server we are talking to. |
| 388 | ** This is used to populate the ipaddr column of the rcvfrom table, |
| 389 | ** if any files are received from the server. |
| 390 | */ |
| 391 | { |
| 392 | /* IPv4 only code */ |
| 393 | const unsigned char *ip = (const unsigned char *) BIO_ptr_ctrl(iBio,BIO_C_GET_CONNECT,2); |
| 394 | g.zIpAddr = mprintf("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); |
| 395 | } |
| 396 | |
| 397 | X509_free(cert); |
| 398 | return 0; |
| 399 | } |
| 400 |
| --- src/http_ssl.c | |
| +++ src/http_ssl.c | |
| @@ -387,13 +387,20 @@ | |
| 387 | /* Set the Global.zIpAddr variable to the server we are talking to. |
| 388 | ** This is used to populate the ipaddr column of the rcvfrom table, |
| 389 | ** if any files are received from the server. |
| 390 | */ |
| 391 | { |
| 392 | #if OPENSSL_VERSION_NUMBER < 0x10100000 |
| 393 | /* IPv4 only code */ |
| 394 | const unsigned char *ip; |
| 395 | ip = (const unsigned char*)BIO_ptr_ctrl(iBio,BIO_C_GET_CONNECT,2); |
| 396 | g.zIpAddr = mprintf("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); |
| 397 | #else |
| 398 | char *ip = BIO_ADDR_hostname_string(BIO_get_conn_address(iBio),1); |
| 399 | g.zIpAddr = mprintf("%s", ip); |
| 400 | OPENSSL_free(ip); |
| 401 | #endif |
| 402 | } |
| 403 | |
| 404 | X509_free(cert); |
| 405 | return 0; |
| 406 | } |
| 407 |