Fossil SCM

Make a best effort to record the IP of the remote host in rcvfrom.

andybradford 2013-08-24 19:02 ssh-test-http
Commit 5627d795c30186c452f5f750b29a99eebad84b31
--- src/http_socket.c
+++ src/http_socket.c
@@ -209,5 +209,22 @@
209209
N -= (size_t)got;
210210
pContent = (void*)&((char*)pContent)[got];
211211
}
212212
return total;
213213
}
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
+}
214231
--- 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
--- src/http_transport.c
+++ src/http_transport.c
@@ -97,10 +97,11 @@
9797
const char *zSsh; /* The base SSH command */
9898
Blob zCmd; /* The SSH command */
9999
char *zHost; /* The host name to contact */
100100
int n; /* Size of prefix string */
101101
102
+ socket_ssh_resolve_addr();
102103
zSsh = db_get("ssh-command", zDefaultSshCmd);
103104
zSshFossilCmd = db_get("ssh-fossil", "fossil");
104105
blob_init(&zCmd, zSsh, -1);
105106
if( g.urlPort!=g.urlDfltPort && g.urlPort ){
106107
#ifdef __MINGW32__
107108
--- 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

Keyboard Shortcuts

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