summaryrefslogtreecommitdiff
path: root/src/libexec
diff options
context:
space:
mode:
authorEpoch Qwert <epoch@53flpnlls43fcguy.onion>2015-01-11 03:01:37 -0600
committerEpoch Qwert <epoch@53flpnlls43fcguy.onion>2015-01-11 03:01:37 -0600
commit42d9771ba0c2e3491025e24956c995a7db56372c (patch)
tree58bdbd0473d0789a59864063410b9ef5a9a1bcb6 /src/libexec
parent3f6b64304a8a11f0505e91681384327696983928 (diff)
downloadmisc-42d9771ba0c2e3491025e24956c995a7db56372c.tar.gz
misc-42d9771ba0c2e3491025e24956c995a7db56372c.zip
fuck if I know. I was just going to add the gateway. >_>
Diffstat (limited to 'src/libexec')
-rw-r--r--src/libexec/httpd.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/libexec/httpd.c b/src/libexec/httpd.c
index 812e051..41339ae 100644
--- a/src/libexec/httpd.c
+++ b/src/libexec/httpd.c
@@ -5,6 +5,9 @@
#include <unistd.h>
#include <syslog.h>
#include <sys/wait.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <netinet/in.h>
#define VHOST_ROOT "/var/www/vhosts"
#define SITES_ROOT "/var/www/sites"
@@ -26,8 +29,12 @@ int main(int argc,char *argv[]) {
char *get_param;
char line[getpagesize()];
fgets(line,sizeof(line)-1,stdin);
-// syslog(LOG_INFO,"ADDRESS did a LINE");
-// syslog(LOG_WARNING,"httpd syslog test\n");
+ struct sockaddr_in6 sa6;
+ unsigned int sl=sizeof(sa6);
+ char h[NI_MAXHOST];
+ if(getpeername(0,(struct sockaddr *)&sa6,&sl) == -1) syslog(LOG_WARNING,"getpeername: %m");
+ getnameinfo((struct sockaddr *)&sa6,sl,h,sizeof(h),0,0,NI_NUMERICHOST);
+ setenv("REMOTE_ADDR",h,1);
if(!strchr(line,'\n')) {
printf("HTTP/1.1 413 Entity Too Large\r\n");
standard_headers();
@@ -36,6 +43,7 @@ int main(int argc,char *argv[]) {
return 0;
}
if(strchr(line,'\r')) *strchr(line,'\r')=0;
+ syslog(LOG_WARNING,"%s %s\n",h,line);
method=strdup(line);
if((page=strchr(method,' '))) {
*page=0;