Fossil SCM

Do not try to resolve the IP from the hostname when syncing using ssh:// protocol. Ssh may use the provided name as an alias defined in ~/.ssh/config which may not be resolvable or even resolve to an unrelated ip. This change can potentially avoid long timeout during name resolution failure.

mgagnon 2023-01-06 21:33 trunk
Commit e5c5622d4becd78698ac6476c8c9b5d74116a967200466e2e6bf0b3aebd9e088
--- src/http_socket.c
+++ src/http_socket.c
@@ -232,33 +232,5 @@
232232
N -= (size_t)got;
233233
pContent = (void*)&((char*)pContent)[got];
234234
}
235235
return total;
236236
}
237
-
238
-/*
239
-** Attempt to resolve pUrlData->name to an IP address and setup g.zIpAddr
240
-** so rcvfrom gets populated. For hostnames with more than one IP (or
241
-** if overridden in ~/.ssh/config) the rcvfrom may not match the host
242
-** to which we connect.
243
-*/
244
-void socket_ssh_resolve_addr(UrlData *pUrlData){
245
- struct addrinfo *ai = 0;
246
- struct addrinfo hints;
247
- char zRemote[NI_MAXHOST];
248
- memset(&hints, 0, sizeof(hints));
249
- hints.ai_family = AF_UNSPEC;
250
- hints.ai_socktype = SOCK_STREAM;
251
- hints.ai_protocol = IPPROTO_TCP;
252
- fossil_free(g.zIpAddr);
253
- g.zIpAddr = 0;
254
- if( getaddrinfo(pUrlData->name, NULL, &hints, &ai)==0
255
- && ai!=0
256
- && getnameinfo(ai->ai_addr, ai->ai_addrlen, zRemote,
257
- sizeof(zRemote), 0, 0, NI_NUMERICHOST)==0 ){
258
- g.zIpAddr = mprintf("%s (%s)", zRemote, pUrlData->name);
259
- }
260
- if( ai ) freeaddrinfo(ai);
261
- if( g.zIpAddr==0 ){
262
- g.zIpAddr = mprintf("%s", pUrlData->name);
263
- }
264
-}
265237
--- src/http_socket.c
+++ src/http_socket.c
@@ -232,33 +232,5 @@
232 N -= (size_t)got;
233 pContent = (void*)&((char*)pContent)[got];
234 }
235 return total;
236 }
237
238 /*
239 ** Attempt to resolve pUrlData->name to an IP address and setup g.zIpAddr
240 ** so rcvfrom gets populated. For hostnames with more than one IP (or
241 ** if overridden in ~/.ssh/config) the rcvfrom may not match the host
242 ** to which we connect.
243 */
244 void socket_ssh_resolve_addr(UrlData *pUrlData){
245 struct addrinfo *ai = 0;
246 struct addrinfo hints;
247 char zRemote[NI_MAXHOST];
248 memset(&hints, 0, sizeof(hints));
249 hints.ai_family = AF_UNSPEC;
250 hints.ai_socktype = SOCK_STREAM;
251 hints.ai_protocol = IPPROTO_TCP;
252 fossil_free(g.zIpAddr);
253 g.zIpAddr = 0;
254 if( getaddrinfo(pUrlData->name, NULL, &hints, &ai)==0
255 && ai!=0
256 && getnameinfo(ai->ai_addr, ai->ai_addrlen, zRemote,
257 sizeof(zRemote), 0, 0, NI_NUMERICHOST)==0 ){
258 g.zIpAddr = mprintf("%s (%s)", zRemote, pUrlData->name);
259 }
260 if( ai ) freeaddrinfo(ai);
261 if( g.zIpAddr==0 ){
262 g.zIpAddr = mprintf("%s", pUrlData->name);
263 }
264 }
265
--- src/http_socket.c
+++ src/http_socket.c
@@ -232,33 +232,5 @@
232 N -= (size_t)got;
233 pContent = (void*)&((char*)pContent)[got];
234 }
235 return total;
236 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
--- src/http_transport.c
+++ src/http_transport.c
@@ -117,11 +117,12 @@
117117
** to talk to the remote machine.
118118
*/
119119
Blob zCmd; /* The SSH command */
120120
char *zHost; /* The host name to contact */
121121
122
- socket_ssh_resolve_addr(pUrlData);
122
+ fossil_free(g.zIpAddr);
123
+ g.zIpAddr = mprintf("%s", pUrlData->name);
123124
transport_ssh_command(&zCmd);
124125
if( pUrlData->port!=pUrlData->dfltPort && pUrlData->port ){
125126
blob_appendf(&zCmd, " -p %d", pUrlData->port);
126127
}
127128
blob_appendf(&zCmd, " -T --"); /* End of switches */
128129
--- src/http_transport.c
+++ src/http_transport.c
@@ -117,11 +117,12 @@
117 ** to talk to the remote machine.
118 */
119 Blob zCmd; /* The SSH command */
120 char *zHost; /* The host name to contact */
121
122 socket_ssh_resolve_addr(pUrlData);
 
123 transport_ssh_command(&zCmd);
124 if( pUrlData->port!=pUrlData->dfltPort && pUrlData->port ){
125 blob_appendf(&zCmd, " -p %d", pUrlData->port);
126 }
127 blob_appendf(&zCmd, " -T --"); /* End of switches */
128
--- src/http_transport.c
+++ src/http_transport.c
@@ -117,11 +117,12 @@
117 ** to talk to the remote machine.
118 */
119 Blob zCmd; /* The SSH command */
120 char *zHost; /* The host name to contact */
121
122 fossil_free(g.zIpAddr);
123 g.zIpAddr = mprintf("%s", pUrlData->name);
124 transport_ssh_command(&zCmd);
125 if( pUrlData->port!=pUrlData->dfltPort && pUrlData->port ){
126 blob_appendf(&zCmd, " -p %d", pUrlData->port);
127 }
128 blob_appendf(&zCmd, " -T --"); /* End of switches */
129
+1 -1
--- src/xfer.c
+++ src/xfer.c
@@ -2857,11 +2857,11 @@
28572857
}
28582858
28592859
fossil_force_newline();
28602860
if( g.zHttpCmd==0 ){
28612861
fossil_print(
2862
- "%s done, wire bytes sent: %lld received: %lld ip: %s\n",
2862
+ "%s done, wire bytes sent: %lld received: %lld remote: %s\n",
28632863
zOpType, nSent, nRcvd, g.zIpAddr);
28642864
}
28652865
if( syncFlags & SYNC_VERBOSE ){
28662866
fossil_print(
28672867
"Uncompressed payload sent: %lld received: %lld\n", nUncSent, nUncRcvd);
28682868
--- src/xfer.c
+++ src/xfer.c
@@ -2857,11 +2857,11 @@
2857 }
2858
2859 fossil_force_newline();
2860 if( g.zHttpCmd==0 ){
2861 fossil_print(
2862 "%s done, wire bytes sent: %lld received: %lld ip: %s\n",
2863 zOpType, nSent, nRcvd, g.zIpAddr);
2864 }
2865 if( syncFlags & SYNC_VERBOSE ){
2866 fossil_print(
2867 "Uncompressed payload sent: %lld received: %lld\n", nUncSent, nUncRcvd);
2868
--- src/xfer.c
+++ src/xfer.c
@@ -2857,11 +2857,11 @@
2857 }
2858
2859 fossil_force_newline();
2860 if( g.zHttpCmd==0 ){
2861 fossil_print(
2862 "%s done, wire bytes sent: %lld received: %lld remote: %s\n",
2863 zOpType, nSent, nRcvd, g.zIpAddr);
2864 }
2865 if( syncFlags & SYNC_VERBOSE ){
2866 fossil_print(
2867 "Uncompressed payload sent: %lld received: %lld\n", nUncSent, nUncRcvd);
2868

Keyboard Shortcuts

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