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.
Commit
cf94d5a0ff2b2716e611c70fbd555deb6f22dd6e075eded8ff67b8bced59e0f2
Parent
9979edbdef54f54…
1 file changed
+7
+7
| --- src/cgi.c | ||
| +++ src/cgi.c | ||
| @@ -1386,19 +1386,26 @@ | ||
| 1386 | 1386 | ** |
| 1387 | 1387 | ** The string is held in a static buffer that is overwritten on |
| 1388 | 1388 | ** each call. |
| 1389 | 1389 | */ |
| 1390 | 1390 | char *cgi_remote_ip(int fd){ |
| 1391 | +#if 0 | |
| 1391 | 1392 | static char zIp[100]; |
| 1392 | 1393 | struct sockaddr_in6 addr; |
| 1393 | 1394 | socklen_t sz = sizeof(addr); |
| 1394 | 1395 | if( getpeername(fd, &addr, &sz) ) return 0; |
| 1395 | 1396 | zIp[0] = 0; |
| 1396 | 1397 | if( inet_ntop(AF_INET6, &addr, zIp, sizeof(zIp))==0 ){ |
| 1397 | 1398 | return 0; |
| 1398 | 1399 | } |
| 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 | |
| 1400 | 1407 | } |
| 1401 | 1408 | |
| 1402 | 1409 | /* |
| 1403 | 1410 | ** This routine handles a single HTTP request which is coming in on |
| 1404 | 1411 | ** g.httpIn and which replies on g.httpOut |
| 1405 | 1412 |
| --- 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 |