Fossil SCM

Add the --ipv6 option to "fossil clone" to force the use of IPv6.

drh 2025-12-19 12:17 trunk
Commit 6f55dbd00bb21c1bb619ad0b5b9ce8a079584545bd9489746c40ddd58231e6b2
+2 -1
--- src/http.c
+++ src/http.c
@@ -843,11 +843,12 @@
843843
}
844844
if( find_option("xfer",0,0)!=0 ){
845845
mHttpFlags |= HTTP_USE_LOGIN;
846846
mHttpFlags &= ~HTTP_GENERIC;
847847
}
848
- if( find_option("ipv4",0,0) ) g.fIPv4 = 1;
848
+ if( find_option("ipv4",0,0) ) g.eIPvers = 1;
849
+ if( find_option("ipv6",0,0) ) g.eIPvers = 2;
849850
zSubpath = find_option("subpath",0,1);
850851
verify_all_options();
851852
if( g.argc<3 || g.argc>5 ){
852853
usage("URL ?PAYLOAD? ?OUTPUT?");
853854
}
854855
--- src/http.c
+++ src/http.c
@@ -843,11 +843,12 @@
843 }
844 if( find_option("xfer",0,0)!=0 ){
845 mHttpFlags |= HTTP_USE_LOGIN;
846 mHttpFlags &= ~HTTP_GENERIC;
847 }
848 if( find_option("ipv4",0,0) ) g.fIPv4 = 1;
 
849 zSubpath = find_option("subpath",0,1);
850 verify_all_options();
851 if( g.argc<3 || g.argc>5 ){
852 usage("URL ?PAYLOAD? ?OUTPUT?");
853 }
854
--- src/http.c
+++ src/http.c
@@ -843,11 +843,12 @@
843 }
844 if( find_option("xfer",0,0)!=0 ){
845 mHttpFlags |= HTTP_USE_LOGIN;
846 mHttpFlags &= ~HTTP_GENERIC;
847 }
848 if( find_option("ipv4",0,0) ) g.eIPvers = 1;
849 if( find_option("ipv6",0,0) ) g.eIPvers = 2;
850 zSubpath = find_option("subpath",0,1);
851 verify_all_options();
852 if( g.argc<3 || g.argc>5 ){
853 usage("URL ?PAYLOAD? ?OUTPUT?");
854 }
855
--- src/http_socket.c
+++ src/http_socket.c
@@ -153,11 +153,15 @@
153153
char zRemote[NI_MAXHOST];
154154
155155
socket_global_init();
156156
socket_close();
157157
memset(&hints, 0, sizeof(struct addrinfo));
158
- hints.ai_family = g.fIPv4 ? AF_INET : AF_UNSPEC;
158
+ switch( g.eIPvers ){
159
+ default: hints.ai_family = AF_UNSPEC; break;
160
+ case 1: hints.ai_family = AF_INET; break;
161
+ case 2: hints.ai_family = AF_INET6; break;
162
+ }
159163
hints.ai_socktype = SOCK_STREAM;
160164
hints.ai_protocol = IPPROTO_TCP;
161165
sqlite3_snprintf(sizeof(zPort),zPort,"%d", pUrlData->port);
162166
rc = getaddrinfo(pUrlData->name, zPort, &hints, &ai);
163167
if( rc ){
164168
--- src/http_socket.c
+++ src/http_socket.c
@@ -153,11 +153,15 @@
153 char zRemote[NI_MAXHOST];
154
155 socket_global_init();
156 socket_close();
157 memset(&hints, 0, sizeof(struct addrinfo));
158 hints.ai_family = g.fIPv4 ? AF_INET : AF_UNSPEC;
 
 
 
 
159 hints.ai_socktype = SOCK_STREAM;
160 hints.ai_protocol = IPPROTO_TCP;
161 sqlite3_snprintf(sizeof(zPort),zPort,"%d", pUrlData->port);
162 rc = getaddrinfo(pUrlData->name, zPort, &hints, &ai);
163 if( rc ){
164
--- src/http_socket.c
+++ src/http_socket.c
@@ -153,11 +153,15 @@
153 char zRemote[NI_MAXHOST];
154
155 socket_global_init();
156 socket_close();
157 memset(&hints, 0, sizeof(struct addrinfo));
158 switch( g.eIPvers ){
159 default: hints.ai_family = AF_UNSPEC; break;
160 case 1: hints.ai_family = AF_INET; break;
161 case 2: hints.ai_family = AF_INET6; break;
162 }
163 hints.ai_socktype = SOCK_STREAM;
164 hints.ai_protocol = IPPROTO_TCP;
165 sqlite3_snprintf(sizeof(zPort),zPort,"%d", pUrlData->port);
166 rc = getaddrinfo(pUrlData->name, zPort, &hints, &ai);
167 if( rc ){
168
+28 -6
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -456,16 +456,27 @@
456456
ssl_global_init_client();
457457
if( pUrlData->useProxy ){
458458
int rc;
459459
char *connStr = mprintf("%s:%d", g.url.name, pUrlData->port);
460460
BIO *sBio = BIO_new_connect(connStr);
461
- if( g.fIPv4 ){
461
+ switch( g.eIPvers ){
462
+ default: /* Any available protocol */
463
+ break;
464
+ case 1: /* IPv4 only */
462465
#ifdef BIO_FAMILY_IPV4
463
- BIO_set_conn_ip_family(sBio, BIO_FAMILY_IPV4);
466
+ BIO_set_conn_ip_family(sBio, BIO_FAMILY_IPV4);
467
+#else
468
+ fossil_warning("The --ipv4 option is not supported in this build\n");
469
+#endif
470
+ break;
471
+ case 2: /* IPv6 only */
472
+#ifdef BIO_FAMILY_IPV6
473
+ BIO_set_conn_ip_family(sBio, BIO_FAMILY_IPV6);
464474
#else
465
- fossil_warning("The --ipv4 option is not supported in this build\n");
475
+ fossil_warning("The --ipv6 option is not supported in this build\n");
466476
#endif
477
+ break;
467478
}
468479
fossil_free(connStr);
469480
if( BIO_do_connect(sBio)<=0 ){
470481
ssl_set_errmsg("SSL: cannot connect to proxy %s:%d (%s)",
471482
pUrlData->name, pUrlData->port,
@@ -516,16 +527,27 @@
516527
517528
if( !pUrlData->useProxy ){
518529
char *connStr = mprintf("%s:%d", pUrlData->name, pUrlData->port);
519530
BIO_set_conn_hostname(iBio, connStr);
520531
fossil_free(connStr);
521
- if( g.fIPv4 ){
532
+ switch( g.eIPvers ){
533
+ default: /* Any available protocol */
534
+ break;
535
+ case 1: /* IPv4 only */
522536
#ifdef BIO_FAMILY_IPV4
523
- BIO_set_conn_ip_family(iBio, BIO_FAMILY_IPV4);
537
+ BIO_set_conn_ip_family(iBio, BIO_FAMILY_IPV4);
538
+#else
539
+ fossil_warning("The --ipv4 option is not supported in this build\n");
540
+#endif
541
+ break;
542
+ case 2: /* IPv6 only */
543
+#ifdef BIO_FAMILY_IPV6
544
+ BIO_set_conn_ip_family(iBio, BIO_FAMILY_IPV6);
524545
#else
525
- fossil_warning("The --ipv4 option is not supported in this build\n");
546
+ fossil_warning("The --ipv6 option is not supported in this build\n");
526547
#endif
548
+ break;
527549
}
528550
if( BIO_do_connect(iBio)<=0 ){
529551
ssl_set_errmsg("SSL: cannot connect to host %s:%d (%s)",
530552
pUrlData->name, pUrlData->port,
531553
ERR_reason_error_string(ERR_get_error()));
532554
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -456,16 +456,27 @@
456 ssl_global_init_client();
457 if( pUrlData->useProxy ){
458 int rc;
459 char *connStr = mprintf("%s:%d", g.url.name, pUrlData->port);
460 BIO *sBio = BIO_new_connect(connStr);
461 if( g.fIPv4 ){
 
 
 
462 #ifdef BIO_FAMILY_IPV4
463 BIO_set_conn_ip_family(sBio, BIO_FAMILY_IPV4);
 
 
 
 
 
 
 
464 #else
465 fossil_warning("The --ipv4 option is not supported in this build\n");
466 #endif
 
467 }
468 fossil_free(connStr);
469 if( BIO_do_connect(sBio)<=0 ){
470 ssl_set_errmsg("SSL: cannot connect to proxy %s:%d (%s)",
471 pUrlData->name, pUrlData->port,
@@ -516,16 +527,27 @@
516
517 if( !pUrlData->useProxy ){
518 char *connStr = mprintf("%s:%d", pUrlData->name, pUrlData->port);
519 BIO_set_conn_hostname(iBio, connStr);
520 fossil_free(connStr);
521 if( g.fIPv4 ){
 
 
 
522 #ifdef BIO_FAMILY_IPV4
523 BIO_set_conn_ip_family(iBio, BIO_FAMILY_IPV4);
 
 
 
 
 
 
 
524 #else
525 fossil_warning("The --ipv4 option is not supported in this build\n");
526 #endif
 
527 }
528 if( BIO_do_connect(iBio)<=0 ){
529 ssl_set_errmsg("SSL: cannot connect to host %s:%d (%s)",
530 pUrlData->name, pUrlData->port,
531 ERR_reason_error_string(ERR_get_error()));
532
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -456,16 +456,27 @@
456 ssl_global_init_client();
457 if( pUrlData->useProxy ){
458 int rc;
459 char *connStr = mprintf("%s:%d", g.url.name, pUrlData->port);
460 BIO *sBio = BIO_new_connect(connStr);
461 switch( g.eIPvers ){
462 default: /* Any available protocol */
463 break;
464 case 1: /* IPv4 only */
465 #ifdef BIO_FAMILY_IPV4
466 BIO_set_conn_ip_family(sBio, BIO_FAMILY_IPV4);
467 #else
468 fossil_warning("The --ipv4 option is not supported in this build\n");
469 #endif
470 break;
471 case 2: /* IPv6 only */
472 #ifdef BIO_FAMILY_IPV6
473 BIO_set_conn_ip_family(sBio, BIO_FAMILY_IPV6);
474 #else
475 fossil_warning("The --ipv6 option is not supported in this build\n");
476 #endif
477 break;
478 }
479 fossil_free(connStr);
480 if( BIO_do_connect(sBio)<=0 ){
481 ssl_set_errmsg("SSL: cannot connect to proxy %s:%d (%s)",
482 pUrlData->name, pUrlData->port,
@@ -516,16 +527,27 @@
527
528 if( !pUrlData->useProxy ){
529 char *connStr = mprintf("%s:%d", pUrlData->name, pUrlData->port);
530 BIO_set_conn_hostname(iBio, connStr);
531 fossil_free(connStr);
532 switch( g.eIPvers ){
533 default: /* Any available protocol */
534 break;
535 case 1: /* IPv4 only */
536 #ifdef BIO_FAMILY_IPV4
537 BIO_set_conn_ip_family(iBio, BIO_FAMILY_IPV4);
538 #else
539 fossil_warning("The --ipv4 option is not supported in this build\n");
540 #endif
541 break;
542 case 2: /* IPv6 only */
543 #ifdef BIO_FAMILY_IPV6
544 BIO_set_conn_ip_family(iBio, BIO_FAMILY_IPV6);
545 #else
546 fossil_warning("The --ipv6 option is not supported in this build\n");
547 #endif
548 break;
549 }
550 if( BIO_do_connect(iBio)<=0 ){
551 ssl_set_errmsg("SSL: cannot connect to host %s:%d (%s)",
552 pUrlData->name, pUrlData->port,
553 ERR_reason_error_string(ERR_get_error()));
554
+1 -1
--- src/main.c
+++ src/main.c
@@ -188,11 +188,11 @@
188188
int fSshClient; /* HTTP client flags for SSH client */
189189
int fNoHttpCompress; /* Do not compress HTTP traffic (for debugging) */
190190
char *zSshCmd; /* SSH command string */
191191
const char *zHttpCmd; /* External program to do HTTP requests */
192192
int fNoSync; /* Do not do an autosync ever. --nosync */
193
- int fIPv4; /* Use only IPv4, not IPv6. --ipv4 */
193
+ int eIPvers; /* 0: any 1: ipv4-only 2: ipv6-only */
194194
char *zPath; /* Name of webpage being served (may be NULL) */
195195
char *zExtra; /* Extra path information past the webpage name */
196196
char *zBaseURL; /* Full text of the URL being served */
197197
char *zHttpsURL; /* zBaseURL translated to https: */
198198
char *zTop; /* Parent directory of zPath */
199199
--- src/main.c
+++ src/main.c
@@ -188,11 +188,11 @@
188 int fSshClient; /* HTTP client flags for SSH client */
189 int fNoHttpCompress; /* Do not compress HTTP traffic (for debugging) */
190 char *zSshCmd; /* SSH command string */
191 const char *zHttpCmd; /* External program to do HTTP requests */
192 int fNoSync; /* Do not do an autosync ever. --nosync */
193 int fIPv4; /* Use only IPv4, not IPv6. --ipv4 */
194 char *zPath; /* Name of webpage being served (may be NULL) */
195 char *zExtra; /* Extra path information past the webpage name */
196 char *zBaseURL; /* Full text of the URL being served */
197 char *zHttpsURL; /* zBaseURL translated to https: */
198 char *zTop; /* Parent directory of zPath */
199
--- src/main.c
+++ src/main.c
@@ -188,11 +188,11 @@
188 int fSshClient; /* HTTP client flags for SSH client */
189 int fNoHttpCompress; /* Do not compress HTTP traffic (for debugging) */
190 char *zSshCmd; /* SSH command string */
191 const char *zHttpCmd; /* External program to do HTTP requests */
192 int fNoSync; /* Do not do an autosync ever. --nosync */
193 int eIPvers; /* 0: any 1: ipv4-only 2: ipv6-only */
194 char *zPath; /* Name of webpage being served (may be NULL) */
195 char *zExtra; /* Extra path information past the webpage name */
196 char *zBaseURL; /* Full text of the URL being served */
197 char *zHttpsURL; /* zBaseURL translated to https: */
198 char *zTop; /* Parent directory of zPath */
199
+4 -1
--- src/url.c
+++ src/url.c
@@ -547,20 +547,23 @@
547547
** network-related options:
548548
**
549549
** --nosync Temporarily disable "autosync"
550550
**
551551
** --ipv4 Disallow IPv6. Use only IPv4.
552
+**
553
+** --ipv6 Disallow IPv4. Use only IPv6.
552554
**
553555
** --accept-any-cert Disable server SSL cert validation. Accept
554556
** any SSL cert that the server provides.
555557
** WARNING: this option opens you up to
556558
** forged-DNS and man-in-the-middle attacks!
557559
*/
558560
void url_proxy_options(void){
559561
zProxyOpt = find_option("proxy", 0, 1);
560562
if( find_option("nosync",0,0) ) g.fNoSync = 1;
561
- if( find_option("ipv4",0,0) ) g.fIPv4 = 1;
563
+ if( find_option("ipv4",0,0) ) g.eIPvers = 1;
564
+ if( find_option("ipv6",0,0) ) g.eIPvers = 2;
562565
#ifdef FOSSIL_ENABLE_SSL
563566
if( find_option("accept-any-cert",0,0) ){
564567
ssl_disable_cert_verification();
565568
}
566569
#endif /* FOSSIL_ENABLE_SSL */
567570
--- src/url.c
+++ src/url.c
@@ -547,20 +547,23 @@
547 ** network-related options:
548 **
549 ** --nosync Temporarily disable "autosync"
550 **
551 ** --ipv4 Disallow IPv6. Use only IPv4.
 
 
552 **
553 ** --accept-any-cert Disable server SSL cert validation. Accept
554 ** any SSL cert that the server provides.
555 ** WARNING: this option opens you up to
556 ** forged-DNS and man-in-the-middle attacks!
557 */
558 void url_proxy_options(void){
559 zProxyOpt = find_option("proxy", 0, 1);
560 if( find_option("nosync",0,0) ) g.fNoSync = 1;
561 if( find_option("ipv4",0,0) ) g.fIPv4 = 1;
 
562 #ifdef FOSSIL_ENABLE_SSL
563 if( find_option("accept-any-cert",0,0) ){
564 ssl_disable_cert_verification();
565 }
566 #endif /* FOSSIL_ENABLE_SSL */
567
--- src/url.c
+++ src/url.c
@@ -547,20 +547,23 @@
547 ** network-related options:
548 **
549 ** --nosync Temporarily disable "autosync"
550 **
551 ** --ipv4 Disallow IPv6. Use only IPv4.
552 **
553 ** --ipv6 Disallow IPv4. Use only IPv6.
554 **
555 ** --accept-any-cert Disable server SSL cert validation. Accept
556 ** any SSL cert that the server provides.
557 ** WARNING: this option opens you up to
558 ** forged-DNS and man-in-the-middle attacks!
559 */
560 void url_proxy_options(void){
561 zProxyOpt = find_option("proxy", 0, 1);
562 if( find_option("nosync",0,0) ) g.fNoSync = 1;
563 if( find_option("ipv4",0,0) ) g.eIPvers = 1;
564 if( find_option("ipv6",0,0) ) g.eIPvers = 2;
565 #ifdef FOSSIL_ENABLE_SSL
566 if( find_option("accept-any-cert",0,0) ){
567 ssl_disable_cert_verification();
568 }
569 #endif /* FOSSIL_ENABLE_SSL */
570

Keyboard Shortcuts

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