INNER CODE UNIT · Python

get_lan_ip

blokadaorg/blokada · common/websocket.py:6

def get_lan_ip():
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    try:
        # doesn't even have to be reachable
        s.connect(('8.8.8.8', 1))
        IP = s.getsockname()[0]
    except Exception:
        IP = '127.0.0.1'
    finally:
        s.close()
    return IP

async def echo(websocket, path):
    while True:
        command = input("$ ")
        await websocket.send(command)

async def main():

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…