From dfe6679c5750b577ae3e923ecbd140d935628864 Mon Sep 17 00:00:00 2001 From: Michael Rash Date: Tue, 14 Aug 2012 21:51:00 -0400 Subject: [PATCH] Added the extras/myip/ directory for client IP resolution code The myip.c file is deployed at http://www.cipherdyne.org/cgi-bin/myip for fwknop client IP resolution. --- extras/myip/myip.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 extras/myip/myip.c diff --git a/extras/myip/myip.c b/extras/myip/myip.c new file mode 100644 index 00000000..8546ef2a --- /dev/null +++ b/extras/myip/myip.c @@ -0,0 +1,22 @@ +#include +#include + +/* This is part of the fwknop project, and just returns the source IP of web + * request made through a webserver. The fwknop client uses this to resolve + * the external IP of a system that is behind a NAT. The myip executable is + * accessed here: http://www.cipherdyne.org/cgi-bin/myip + * + * Compile with: gcc -Wall -o myip myip.c +*/ + +int main(void) +{ + char *ip_str = NULL; + + if ((ip_str = getenv("REMOTE_ADDR")) != NULL) + printf("Content-Type: text/html;\r\n\r\n%s\r\n", ip_str); + else + printf("Content-Type: text/html;\r\n\r\nNULL\r\n"); + + return 0; +}