Add IP commandline argument
This commit is contained in:
parent
ccac19df6c
commit
ecc73b49de
@ -24,10 +24,8 @@ import threading
|
|||||||
import queue
|
import queue
|
||||||
|
|
||||||
bufferSize = 1000 # buffer size in bytes
|
bufferSize = 1000 # buffer size in bytes
|
||||||
serverAddr = ("127.0.0.1",12000)
|
|
||||||
connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
|
||||||
|
|
||||||
class stdoutThread(threading.Thread):
|
class stdoutThread(threading.Thread):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
@ -57,11 +55,15 @@ def makePayload(lst):
|
|||||||
return cmdBytes
|
return cmdBytes
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
global serverAddr
|
||||||
|
serverAddr = sys.argv[1].rsplit(":",1)
|
||||||
|
serverAddr[1] = int(serverAddr[1])
|
||||||
|
serverAddr = tuple(serverAddr)
|
||||||
connection.settimeout(15)
|
connection.settimeout(15)
|
||||||
connection.connect(serverAddr)
|
connection.connect(serverAddr)
|
||||||
connection.sendall(makePayload(sys.argv[1:]))
|
connection.sendall(makePayload(sys.argv[2:]))
|
||||||
|
|
||||||
if sys.argv[1] == "watch":
|
if sys.argv[2] == "watch":
|
||||||
stdoutThr = stdoutThread()
|
stdoutThr = stdoutThread()
|
||||||
stdoutThr.start()
|
stdoutThr.start()
|
||||||
while True:
|
while True:
|
||||||
@ -69,7 +71,7 @@ def main():
|
|||||||
if data == b"": return
|
if data == b"": return
|
||||||
stdoutThr.queue.put(data)
|
stdoutThr.queue.put(data)
|
||||||
|
|
||||||
if sys.argv[1] == "broadcast":
|
if sys.argv[2] == "broadcast":
|
||||||
while True:
|
while True:
|
||||||
data = sys.stdin.buffer.read(bufferSize)
|
data = sys.stdin.buffer.read(bufferSize)
|
||||||
connection.sendall(data)
|
connection.sendall(data)
|
||||||
|
Loading…
Reference in New Issue
Block a user