def test_sock_xform(self): class Xor(s_socket.SockXform): def send(self, byts): return xor(0x56,byts) def recv(self, byts): return xor(0x56,byts) lisn = s_socket.listen( ('127.0.0.1',0) ) sockaddr = lisn.getsockname() sock1 = s_socket.connect(sockaddr) sock2,addr = lisn.accept() sock1.sendall(b'woot') self.assertEqual( sock2.recvall(4), b'woot' ) xform = Xor() sock1.addSockXform(xform) sock2.addSockXform(xform) sock1.sendall(b'woot') self.assertEqual( sock2.recvall(4), b'woot' )
def test_sock_xform(self): class Xor(s_socket.SockXform): def send(self, byts): return xor(0x56, byts) def recv(self, byts): return xor(0x56, byts) lisn = s_socket.listen(('127.0.0.1', 0)) sockaddr = lisn.getsockname() sock1 = s_socket.connect(sockaddr) sock2, addr = lisn.accept() sock1.sendall(b'woot') self.assertEqual(sock2.recvall(4), b'woot') xform = Xor() sock1.addSockXform(xform) sock2.addSockXform(xform) sock1.sendall(b'woot') self.assertEqual(sock2.recvall(4), b'woot')
def _initClientSock(self): host = self.link[1].get('host') port = self.link[1].get('port') sock = s_socket.connect((host, port), relay=self) return sock
def _initClientSock(self): host = self.link[1].get('host') port = self.link[1].get('port') sock = s_socket.connect((host,port),relay=self) return sock