INNER CODE UNIT · Python

get_iface

ab77/netflix-proxy · auth/auth.py:59

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'
        web.debug('WARNING: get_iface() failed, guessing iface=%s' % iface)
        
    return iface

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…