Added the extras/myip/ directory for client IP resolution code
authorMichael Rash <mbr@cipherdyne.org>
Wed, 15 Aug 2012 01:51:00 +0000 (21:51 -0400)
committerMichael Rash <mbr@cipherdyne.org>
Wed, 15 Aug 2012 01:51:00 +0000 (21:51 -0400)
The myip.c file is deployed at http://www.cipherdyne.org/cgi-bin/myip
for fwknop client IP resolution.

extras/myip/myip.c [new file with mode: 0644]

diff --git a/extras/myip/myip.c b/extras/myip/myip.c
new file mode 100644 (file)
index 0000000..8546ef2
--- /dev/null
@@ -0,0 +1,22 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+/* 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;
+}