Fossil SCM

Attempts to obtain the IPv6 address of the peer do not seem to work. Fallback to getting the IPv4 address until we figure this out.

drh 2018-07-13 18:40 trunk
Commit cf94d5a0ff2b2716e611c70fbd555deb6f22dd6e075eded8ff67b8bced59e0f2
1 file changed +7
+7
--- src/cgi.c
+++ src/cgi.c
@@ -1386,19 +1386,26 @@
13861386
**
13871387
** The string is held in a static buffer that is overwritten on
13881388
** each call.
13891389
*/
13901390
char *cgi_remote_ip(int fd){
1391
+#if 0
13911392
static char zIp[100];
13921393
struct sockaddr_in6 addr;
13931394
socklen_t sz = sizeof(addr);
13941395
if( getpeername(fd, &addr, &sz) ) return 0;
13951396
zIp[0] = 0;
13961397
if( inet_ntop(AF_INET6, &addr, zIp, sizeof(zIp))==0 ){
13971398
return 0;
13981399
}
13991400
return zIp;
1401
+#else
1402
+ struct sockaddr_in remoteName;
1403
+ socklen_t size = sizeof(struct sockaddr_in);
1404
+ if( getpeername(fd, (struct sockaddr*)&remoteName, &size) ) return 0;
1405
+ return inet_ntoa(remoteName.sin_addr);
1406
+#endif
14001407
}
14011408
14021409
/*
14031410
** This routine handles a single HTTP request which is coming in on
14041411
** g.httpIn and which replies on g.httpOut
14051412
--- src/cgi.c
+++ src/cgi.c
@@ -1386,19 +1386,26 @@
1386 **
1387 ** The string is held in a static buffer that is overwritten on
1388 ** each call.
1389 */
1390 char *cgi_remote_ip(int fd){
 
1391 static char zIp[100];
1392 struct sockaddr_in6 addr;
1393 socklen_t sz = sizeof(addr);
1394 if( getpeername(fd, &addr, &sz) ) return 0;
1395 zIp[0] = 0;
1396 if( inet_ntop(AF_INET6, &addr, zIp, sizeof(zIp))==0 ){
1397 return 0;
1398 }
1399 return zIp;
 
 
 
 
 
 
1400 }
1401
1402 /*
1403 ** This routine handles a single HTTP request which is coming in on
1404 ** g.httpIn and which replies on g.httpOut
1405
--- src/cgi.c
+++ src/cgi.c
@@ -1386,19 +1386,26 @@
1386 **
1387 ** The string is held in a static buffer that is overwritten on
1388 ** each call.
1389 */
1390 char *cgi_remote_ip(int fd){
1391 #if 0
1392 static char zIp[100];
1393 struct sockaddr_in6 addr;
1394 socklen_t sz = sizeof(addr);
1395 if( getpeername(fd, &addr, &sz) ) return 0;
1396 zIp[0] = 0;
1397 if( inet_ntop(AF_INET6, &addr, zIp, sizeof(zIp))==0 ){
1398 return 0;
1399 }
1400 return zIp;
1401 #else
1402 struct sockaddr_in remoteName;
1403 socklen_t size = sizeof(struct sockaddr_in);
1404 if( getpeername(fd, (struct sockaddr*)&remoteName, &size) ) return 0;
1405 return inet_ntoa(remoteName.sin_addr);
1406 #endif
1407 }
1408
1409 /*
1410 ** This routine handles a single HTTP request which is coming in on
1411 ** g.httpIn and which replies on g.httpOut
1412

Keyboard Shortcuts

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