How to use the sshuttle.helpers.islocal function in sshuttle

To help you get started, we’ve selected a few sshuttle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sshuttle / sshuttle / tests / client / test_helpers.py View on Github external
def test_islocal(mock_bind):
    bind_error = socket.error(errno.EADDRNOTAVAIL)
    mock_bind.side_effect = [None, bind_error, None, bind_error]

    assert sshuttle.helpers.islocal("127.0.0.1", AF_INET)
    assert not sshuttle.helpers.islocal("192.0.2.1", AF_INET)
    assert sshuttle.helpers.islocal("::1", AF_INET6)
    assert not sshuttle.helpers.islocal("2001:db8::1", AF_INET6)
github sshuttle / sshuttle / tests / client / test_helpers.py View on Github external
def test_islocal(mock_bind):
    bind_error = socket.error(errno.EADDRNOTAVAIL)
    mock_bind.side_effect = [None, bind_error, None, bind_error]

    assert sshuttle.helpers.islocal("127.0.0.1", AF_INET)
    assert not sshuttle.helpers.islocal("192.0.2.1", AF_INET)
    assert sshuttle.helpers.islocal("::1", AF_INET6)
    assert not sshuttle.helpers.islocal("2001:db8::1", AF_INET6)
github sshuttle / sshuttle / tests / client / test_helpers.py View on Github external
def test_islocal(mock_bind):
    bind_error = socket.error(errno.EADDRNOTAVAIL)
    mock_bind.side_effect = [None, bind_error, None, bind_error]

    assert sshuttle.helpers.islocal("127.0.0.1", AF_INET)
    assert not sshuttle.helpers.islocal("192.0.2.1", AF_INET)
    assert sshuttle.helpers.islocal("::1", AF_INET6)
    assert not sshuttle.helpers.islocal("2001:db8::1", AF_INET6)
github sshuttle / sshuttle / tests / client / test_helpers.py View on Github external
def test_islocal(mock_bind):
    bind_error = socket.error(errno.EADDRNOTAVAIL)
    mock_bind.side_effect = [None, bind_error, None, bind_error]

    assert sshuttle.helpers.islocal("127.0.0.1", AF_INET)
    assert not sshuttle.helpers.islocal("192.0.2.1", AF_INET)
    assert sshuttle.helpers.islocal("::1", AF_INET6)
    assert not sshuttle.helpers.islocal("2001:db8::1", AF_INET6)
github sshuttle / sshuttle / sshuttle / client.py View on Github external
debug1('Rejected incoming connection: too many open files!\n')
            # free up an fd so we can eat the connection
            os.close(_extra_fd)
            try:
                sock, srcip = listener.accept()
                sock.close()
            finally:
                _extra_fd = os.open(os.devnull, os.O_RDONLY)
            return
        else:
            raise

    dstip = method.get_tcp_dstip(sock)
    debug1('Accept TCP: %s:%r -> %s:%r.\n' % (srcip[0], srcip[1],
                                              dstip[0], dstip[1]))
    if dstip[1] == sock.getsockname()[1] and islocal(dstip[0], sock.family):
        debug1("-- ignored: that's my address!\n")
        sock.close()
        return
    chan = mux.next_channel()
    if not chan:
        log('warning: too many open channels.  Discarded connection.\n')
        sock.close()
        return
    mux.send(chan, ssnet.CMD_TCP_CONNECT, b'%d,%s,%d' %
             (sock.family, dstip[0].encode("ASCII"), dstip[1]))
    outwrap = MuxWrapper(mux, chan)
    handlers.append(Proxy(SockWrapper(sock, sock), outwrap))
    expire_connections(time.time(), mux)