| 1 |
#include <stdio.h> |
| 2 |
#include <stdlib.h> |
| 3 |
|
| 4 |
/* This is part of the fwknop project, and just returns the source IP of web |
| 5 |
* request made through a webserver. The fwknop client uses this to resolve |
| 6 |
* the external IP of a system that is behind a NAT. The myip executable is |
| 7 |
* accessed here: http://www.cipherdyne.org/cgi-bin/myip |
| 8 |
* |
| 9 |
* Compile with: gcc -Wall -o myip myip.c |
| 10 |
*/ |
| 11 |
|
| 12 |
int main(void) |
| 13 |
{ |
| 14 |
char *ip_str = NULL; |
| 15 |
|
| 16 |
if ((ip_str = getenv("REMOTE_ADDR")) != NULL) |
| 17 |
fprintf(stdout, |
| 18 |
"Pragma: no-cache\r\n" |
| 19 |
"Content-Type: text/plain\r\n\r\n%s\r\n", |
| 20 |
ip_str |
| 21 |
); |
| 22 |
else |
| 23 |
fprintf(stdout, |
| 24 |
"Pragma: no-cache\r\n" |
| 25 |
"Content-Type: text/plain\r\n\r\nNULL\r\n" |
| 26 |
); |
| 27 |
|
| 28 |
return 0; |
| 29 |
} |