예제 #1
0
파일: agent.py 프로젝트: Tefx/Thinkpol
class Agent(object):
	def __init__(self, addr):
		sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		sock.connect(addr)
		self.port = Port(sock)

	def list(self):
		self.port.write("?")
		return json.loads(self.port.read())

	def fetch(self, want="*"):
		if want == "*":
			req = "*"
		else:
			req = json.dumps(want)
		self.port.write(req)
		return json.loads(self.port.read())
예제 #2
0
파일: tools.py 프로젝트: Tefx/Littlefinger
	def listen(self, host):
		sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		sock.connect((host, SERVICE_PORT))
		port = Port(sock)
		port.write(self.subs)
		while True:
			res = port.read()
			if res:
				self.queue.put(res)
예제 #3
0
파일: miniture.py 프로젝트: Tefx/Thinkpol
 def listen_telescreens(self, listen_port):
     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     sock.bind(("", listen_port))
     sock.listen(10000)
     while True:
         client_sock, _ = sock.accept()
         port = Port(client_sock)
         uuid = port.read()
         self.telescreens[uuid] = port