File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55import json
66import html
77import urllib
8+ import socket
89
910import gevent
1011
@@ -83,7 +84,16 @@ def route(self, path):
8384
8485 # Check if host allowed to do request
8586 if not self .isHostAllowed (self .env .get ("HTTP_HOST" )):
86- return self .error403 ("Invalid host: %s" % self .env .get ("HTTP_HOST" ), details = False )
87+ ret_error = next (self .error403 ("Invalid host: %s" % self .env .get ("HTTP_HOST" ), details = False ))
88+
89+ http_get = self .env ["PATH_INFO" ]
90+ if self .env ["QUERY_STRING" ]:
91+ http_get += "?{0}" .format (self .env ["QUERY_STRING" ])
92+ self_host = self .env ["HTTP_HOST" ].split (":" )[0 ]
93+ self_ip = self .env ["HTTP_HOST" ].replace (self_host , socket .gethostbyname (self_host ))
94+ link = "http://{0}{1}" .format (self_ip , http_get )
95+ ret_link = """<h4>Access via ip: <a href="{0}">{0}</a>""" .format (html .escape (link )).encode ("utf8" )
96+ return iter ([ret_error , ret_link ])
8797
8898 # Prepend .bit host for transparent proxy
8999 if self .server .site_manager .isDomain (self .env .get ("HTTP_HOST" )):
You can’t perform that action at this time.
0 commit comments