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.

drh 2019-03-25 11:31 trunk
Commit 8a4ad5cb547518dc75118c510b6e5c50ec1ced5671626c5ef490cb3d9e4cbcf7
1 file changed +8 -1
+8 -1
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -387,13 +387,20 @@
387387
/* Set the Global.zIpAddr variable to the server we are talking to.
388388
** This is used to populate the ipaddr column of the rcvfrom table,
389389
** if any files are received from the server.
390390
*/
391391
{
392
+#if OPENSSL_VERSION_NUMBER < 0x10100000
392393
/* 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);
394396
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
395402
}
396403
397404
X509_free(cert);
398405
return 0;
399406
}
400407
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button