Make pipe/tcp tools accept IPs
This commit is contained in:
parent
48375013b1
commit
bf8505554f
@ -24,12 +24,6 @@ import queue
|
|||||||
|
|
||||||
def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs)
|
def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs)
|
||||||
|
|
||||||
serverAddr = ("127.0.0.1",61921)
|
|
||||||
serverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
||||||
eprint("Opening socket...")
|
|
||||||
serverSocket.bind(serverAddr)
|
|
||||||
serverSocket.listen(1)
|
|
||||||
|
|
||||||
connection = False
|
connection = False
|
||||||
connectionLock = threading.Lock()
|
connectionLock = threading.Lock()
|
||||||
|
|
||||||
@ -50,6 +44,22 @@ class pipeThread(threading.Thread):
|
|||||||
connection = False
|
connection = False
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
|
def stringToAddressTuple(addr):
|
||||||
|
rtn = addr.rsplit(":",1)
|
||||||
|
rtn[1] = int(rtn[1])
|
||||||
|
rtn = tuple(rtn)
|
||||||
|
return rtn
|
||||||
|
|
||||||
|
def addressTupleToString(addr):
|
||||||
|
return ":".join(map(str,list(addr)))
|
||||||
|
|
||||||
|
serverAddr = stringToAddressTuple(sys.argv[1])
|
||||||
|
serverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
eprint("Opening socket...")
|
||||||
|
serverSocket.bind(serverAddr)
|
||||||
|
eprint("Serving on " +addressTupleToString(serverAddr)+ "!")
|
||||||
|
serverSocket.listen(1)
|
||||||
|
|
||||||
pThread = pipeThread()
|
pThread = pipeThread()
|
||||||
pThread.start()
|
pThread.start()
|
||||||
|
|
||||||
|
@ -22,10 +22,20 @@ import socket
|
|||||||
|
|
||||||
def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs)
|
def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs)
|
||||||
|
|
||||||
serverAddr = ("127.0.0.1",61921)
|
def stringToAddressTuple(addr):
|
||||||
|
rtn = addr.rsplit(":",1)
|
||||||
|
rtn[1] = int(rtn[1])
|
||||||
|
rtn = tuple(rtn)
|
||||||
|
return rtn
|
||||||
|
|
||||||
|
def addressTupleToString(addr):
|
||||||
|
return ":".join(map(str,list(addr)))
|
||||||
|
|
||||||
|
serverAddr = stringToAddressTuple(sys.argv[1])
|
||||||
serverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
serverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
eprint("Opening socket...")
|
eprint("Opening socket...")
|
||||||
serverSocket.bind(serverAddr)
|
serverSocket.bind(serverAddr)
|
||||||
|
eprint("Serving on " +addressTupleToString(serverAddr)+ "!")
|
||||||
serverSocket.listen(1)
|
serverSocket.listen(1)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
Loading…
Reference in New Issue
Block a user