mirror of
https://github.com/sshuttle/sshuttle.git
synced 2024-11-29 11:23:09 +01:00
c403a83ab8
Just use a plain list instead. Technically probably slightly worse asymptotic behaviour, but it's not like we'll have a million sockets anyway.
38 lines
652 B
Python
38 lines
652 B
Python
import sys, os
|
|
|
|
logprefix = ''
|
|
verbose = 0
|
|
|
|
def log(s):
|
|
try:
|
|
sys.stdout.flush()
|
|
sys.stderr.write(logprefix + s)
|
|
sys.stderr.flush()
|
|
except IOError:
|
|
# this could happen if stderr gets forcibly disconnected, eg. because
|
|
# our tty closes. That sucks, but it's no reason to abort the program.
|
|
pass
|
|
|
|
def debug1(s):
|
|
if verbose >= 1:
|
|
log(s)
|
|
|
|
def debug2(s):
|
|
if verbose >= 2:
|
|
log(s)
|
|
|
|
def debug3(s):
|
|
if verbose >= 3:
|
|
log(s)
|
|
|
|
|
|
class Fatal(Exception):
|
|
pass
|
|
|
|
|
|
def list_contains_any(l, sub):
|
|
for i in sub:
|
|
if i in l:
|
|
return True
|
|
return False
|