INNER CODE UNIT · Python
get_client_public_ip
ab77/netflix-proxy · auth/auth.py:55
def get_client_public_ip():
return web.ctx.env.get('HTTP_X_FORWARDED_FOR') or web.ctx.get('ip', None)
def get_iface():
cmd = "ip route | grep default | awk '{print $5}' | head -n 1"
web.debug('DEBUG: getting public iface name cmd=%s' % cmd)
p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=True)
output, err = p.communicate()
rc = p.returncode
web.debug('DEBUG: get_iface()=%s' % [rc, err, output])
if rc == 0:
try:
iface = output.rstrip().decode()
except:
iface = output.rstrip()
else:
iface = 'eth0'