Fossil SCM

Fix the SSL transport so that it honors the --ipv4 flag. See [forum:/forumpost/ea4b2ec3fe577e79|forum post ea4b2ec3f]. To facilitate testing, add the --ipv4 flag to the test-httpmsg command and report the IP-address when the -v flag is present.

drh 2025-03-21 13:50 trunk
Commit 136dbe9ce0fbd46046a11bae037b92cb7766932c75a44f5674f233552e0868c1
2 files changed +4 +8 -2
+4
--- src/http.c
+++ src/http.c
@@ -512,10 +512,13 @@
512512
transport_send(&g.url, &hdr);
513513
transport_send(&g.url, &payload);
514514
blob_reset(&hdr);
515515
blob_reset(&payload);
516516
transport_flip(&g.url);
517
+ if( mHttpFlags & HTTP_VERBOSE ){
518
+ fossil_print("IP-Address: %s\n", g.zIpAddr);
519
+ }
517520
518521
/*
519522
** Read and interpret the server reply
520523
*/
521524
closeConnection = 1;
@@ -793,10 +796,11 @@
793796
}
794797
if( find_option("xfer",0,0)!=0 ){
795798
mHttpFlags |= HTTP_USE_LOGIN;
796799
mHttpFlags &= ~HTTP_GENERIC;
797800
}
801
+ if( find_option("ipv4",0,0) ) g.fIPv4 = 1;
798802
verify_all_options();
799803
if( g.argc<3 || g.argc>5 ){
800804
usage("URL ?PAYLOAD? ?OUTPUT?");
801805
}
802806
zInFile = g.argc>=4 ? g.argv[3] : 0;
803807
--- src/http.c
+++ src/http.c
@@ -512,10 +512,13 @@
512 transport_send(&g.url, &hdr);
513 transport_send(&g.url, &payload);
514 blob_reset(&hdr);
515 blob_reset(&payload);
516 transport_flip(&g.url);
 
 
 
517
518 /*
519 ** Read and interpret the server reply
520 */
521 closeConnection = 1;
@@ -793,10 +796,11 @@
793 }
794 if( find_option("xfer",0,0)!=0 ){
795 mHttpFlags |= HTTP_USE_LOGIN;
796 mHttpFlags &= ~HTTP_GENERIC;
797 }
 
798 verify_all_options();
799 if( g.argc<3 || g.argc>5 ){
800 usage("URL ?PAYLOAD? ?OUTPUT?");
801 }
802 zInFile = g.argc>=4 ? g.argv[3] : 0;
803
--- src/http.c
+++ src/http.c
@@ -512,10 +512,13 @@
512 transport_send(&g.url, &hdr);
513 transport_send(&g.url, &payload);
514 blob_reset(&hdr);
515 blob_reset(&payload);
516 transport_flip(&g.url);
517 if( mHttpFlags & HTTP_VERBOSE ){
518 fossil_print("IP-Address: %s\n", g.zIpAddr);
519 }
520
521 /*
522 ** Read and interpret the server reply
523 */
524 closeConnection = 1;
@@ -793,10 +796,11 @@
796 }
797 if( find_option("xfer",0,0)!=0 ){
798 mHttpFlags |= HTTP_USE_LOGIN;
799 mHttpFlags &= ~HTTP_GENERIC;
800 }
801 if( find_option("ipv4",0,0) ) g.fIPv4 = 1;
802 verify_all_options();
803 if( g.argc<3 || g.argc>5 ){
804 usage("URL ?PAYLOAD? ?OUTPUT?");
805 }
806 zInFile = g.argc>=4 ? g.argv[3] : 0;
807
+8 -2
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -451,11 +451,14 @@
451451
ssl_global_init_client();
452452
if( pUrlData->useProxy ){
453453
int rc;
454454
char *connStr = mprintf("%s:%d", g.url.name, pUrlData->port);
455455
BIO *sBio = BIO_new_connect(connStr);
456
- free(connStr);
456
+ if( g.fIPv4 ){
457
+ BIO_set_conn_ip_family(sBio, BIO_FAMILY_IPV4);
458
+ }
459
+ fossil_free(connStr);
457460
if( BIO_do_connect(sBio)<=0 ){
458461
ssl_set_errmsg("SSL: cannot connect to proxy %s:%d (%s)",
459462
pUrlData->name, pUrlData->port,
460463
ERR_reason_error_string(ERR_get_error()));
461464
ssl_close_client();
@@ -503,11 +506,14 @@
503506
#endif
504507
505508
if( !pUrlData->useProxy ){
506509
char *connStr = mprintf("%s:%d", pUrlData->name, pUrlData->port);
507510
BIO_set_conn_hostname(iBio, connStr);
508
- free(connStr);
511
+ fossil_free(connStr);
512
+ if( g.fIPv4 ){
513
+ BIO_set_conn_ip_family(iBio, BIO_FAMILY_IPV4);
514
+ }
509515
if( BIO_do_connect(iBio)<=0 ){
510516
ssl_set_errmsg("SSL: cannot connect to host %s:%d (%s)",
511517
pUrlData->name, pUrlData->port,
512518
ERR_reason_error_string(ERR_get_error()));
513519
ssl_close_client();
514520
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -451,11 +451,14 @@
451 ssl_global_init_client();
452 if( pUrlData->useProxy ){
453 int rc;
454 char *connStr = mprintf("%s:%d", g.url.name, pUrlData->port);
455 BIO *sBio = BIO_new_connect(connStr);
456 free(connStr);
 
 
 
457 if( BIO_do_connect(sBio)<=0 ){
458 ssl_set_errmsg("SSL: cannot connect to proxy %s:%d (%s)",
459 pUrlData->name, pUrlData->port,
460 ERR_reason_error_string(ERR_get_error()));
461 ssl_close_client();
@@ -503,11 +506,14 @@
503 #endif
504
505 if( !pUrlData->useProxy ){
506 char *connStr = mprintf("%s:%d", pUrlData->name, pUrlData->port);
507 BIO_set_conn_hostname(iBio, connStr);
508 free(connStr);
 
 
 
509 if( BIO_do_connect(iBio)<=0 ){
510 ssl_set_errmsg("SSL: cannot connect to host %s:%d (%s)",
511 pUrlData->name, pUrlData->port,
512 ERR_reason_error_string(ERR_get_error()));
513 ssl_close_client();
514
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -451,11 +451,14 @@
451 ssl_global_init_client();
452 if( pUrlData->useProxy ){
453 int rc;
454 char *connStr = mprintf("%s:%d", g.url.name, pUrlData->port);
455 BIO *sBio = BIO_new_connect(connStr);
456 if( g.fIPv4 ){
457 BIO_set_conn_ip_family(sBio, BIO_FAMILY_IPV4);
458 }
459 fossil_free(connStr);
460 if( BIO_do_connect(sBio)<=0 ){
461 ssl_set_errmsg("SSL: cannot connect to proxy %s:%d (%s)",
462 pUrlData->name, pUrlData->port,
463 ERR_reason_error_string(ERR_get_error()));
464 ssl_close_client();
@@ -503,11 +506,14 @@
506 #endif
507
508 if( !pUrlData->useProxy ){
509 char *connStr = mprintf("%s:%d", pUrlData->name, pUrlData->port);
510 BIO_set_conn_hostname(iBio, connStr);
511 fossil_free(connStr);
512 if( g.fIPv4 ){
513 BIO_set_conn_ip_family(iBio, BIO_FAMILY_IPV4);
514 }
515 if( BIO_do_connect(iBio)<=0 ){
516 ssl_set_errmsg("SSL: cannot connect to host %s:%d (%s)",
517 pUrlData->name, pUrlData->port,
518 ERR_reason_error_string(ERR_get_error()));
519 ssl_close_client();
520

Keyboard Shortcuts

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