Fossil SCM
Make a best effort to record the IP of the remote host in rcvfrom.
Commit
5627d795c30186c452f5f750b29a99eebad84b31
Parent
f64c003d1341f74…
2 files changed
+17
+1
+17
| --- src/http_socket.c | ||
| +++ src/http_socket.c | ||
| @@ -209,5 +209,22 @@ | ||
| 209 | 209 | N -= (size_t)got; |
| 210 | 210 | pContent = (void*)&((char*)pContent)[got]; |
| 211 | 211 | } |
| 212 | 212 | return total; |
| 213 | 213 | } |
| 214 | + | |
| 215 | +/* | |
| 216 | +** Attempt to resolve g.urlName to IP and setup g.zIpAddr so rcvfrom gets | |
| 217 | +** populated. For hostnames with more than one IP (or if overridden in | |
| 218 | +** ~/.ssh/config) the rcvfrom may not match the host to which we connect. | |
| 219 | +*/ | |
| 220 | +void socket_ssh_resolve_addr(void){ | |
| 221 | + struct hostent *pHost; /* Used to make best effort for rcvfrom */ | |
| 222 | + struct sockaddr_in addr; | |
| 223 | + | |
| 224 | + memset(&addr, 0, sizeof(addr)); | |
| 225 | + pHost = gethostbyname(g.urlName); | |
| 226 | + if( pHost!=0 ){ | |
| 227 | + memcpy(&addr.sin_addr,pHost->h_addr_list[0],pHost->h_length); | |
| 228 | + g.zIpAddr = mprintf("%s", inet_ntoa(addr.sin_addr)); | |
| 229 | + } | |
| 230 | +} | |
| 214 | 231 |
| --- src/http_socket.c | |
| +++ src/http_socket.c | |
| @@ -209,5 +209,22 @@ | |
| 209 | N -= (size_t)got; |
| 210 | pContent = (void*)&((char*)pContent)[got]; |
| 211 | } |
| 212 | return total; |
| 213 | } |
| 214 |
| --- src/http_socket.c | |
| +++ src/http_socket.c | |
| @@ -209,5 +209,22 @@ | |
| 209 | N -= (size_t)got; |
| 210 | pContent = (void*)&((char*)pContent)[got]; |
| 211 | } |
| 212 | return total; |
| 213 | } |
| 214 | |
| 215 | /* |
| 216 | ** Attempt to resolve g.urlName to IP and setup g.zIpAddr so rcvfrom gets |
| 217 | ** populated. For hostnames with more than one IP (or if overridden in |
| 218 | ** ~/.ssh/config) the rcvfrom may not match the host to which we connect. |
| 219 | */ |
| 220 | void socket_ssh_resolve_addr(void){ |
| 221 | struct hostent *pHost; /* Used to make best effort for rcvfrom */ |
| 222 | struct sockaddr_in addr; |
| 223 | |
| 224 | memset(&addr, 0, sizeof(addr)); |
| 225 | pHost = gethostbyname(g.urlName); |
| 226 | if( pHost!=0 ){ |
| 227 | memcpy(&addr.sin_addr,pHost->h_addr_list[0],pHost->h_length); |
| 228 | g.zIpAddr = mprintf("%s", inet_ntoa(addr.sin_addr)); |
| 229 | } |
| 230 | } |
| 231 |
+1
| --- src/http_transport.c | ||
| +++ src/http_transport.c | ||
| @@ -97,10 +97,11 @@ | ||
| 97 | 97 | const char *zSsh; /* The base SSH command */ |
| 98 | 98 | Blob zCmd; /* The SSH command */ |
| 99 | 99 | char *zHost; /* The host name to contact */ |
| 100 | 100 | int n; /* Size of prefix string */ |
| 101 | 101 | |
| 102 | + socket_ssh_resolve_addr(); | |
| 102 | 103 | zSsh = db_get("ssh-command", zDefaultSshCmd); |
| 103 | 104 | zSshFossilCmd = db_get("ssh-fossil", "fossil"); |
| 104 | 105 | blob_init(&zCmd, zSsh, -1); |
| 105 | 106 | if( g.urlPort!=g.urlDfltPort && g.urlPort ){ |
| 106 | 107 | #ifdef __MINGW32__ |
| 107 | 108 |
| --- src/http_transport.c | |
| +++ src/http_transport.c | |
| @@ -97,10 +97,11 @@ | |
| 97 | const char *zSsh; /* The base SSH command */ |
| 98 | Blob zCmd; /* The SSH command */ |
| 99 | char *zHost; /* The host name to contact */ |
| 100 | int n; /* Size of prefix string */ |
| 101 | |
| 102 | zSsh = db_get("ssh-command", zDefaultSshCmd); |
| 103 | zSshFossilCmd = db_get("ssh-fossil", "fossil"); |
| 104 | blob_init(&zCmd, zSsh, -1); |
| 105 | if( g.urlPort!=g.urlDfltPort && g.urlPort ){ |
| 106 | #ifdef __MINGW32__ |
| 107 |
| --- src/http_transport.c | |
| +++ src/http_transport.c | |
| @@ -97,10 +97,11 @@ | |
| 97 | const char *zSsh; /* The base SSH command */ |
| 98 | Blob zCmd; /* The SSH command */ |
| 99 | char *zHost; /* The host name to contact */ |
| 100 | int n; /* Size of prefix string */ |
| 101 | |
| 102 | socket_ssh_resolve_addr(); |
| 103 | zSsh = db_get("ssh-command", zDefaultSshCmd); |
| 104 | zSshFossilCmd = db_get("ssh-fossil", "fossil"); |
| 105 | blob_init(&zCmd, zSsh, -1); |
| 106 | if( g.urlPort!=g.urlDfltPort && g.urlPort ){ |
| 107 | #ifdef __MINGW32__ |
| 108 |