Ejemplo n.º 1
0
    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' )
Ejemplo n.º 2
0
 def _initServerSock(self):
     host = self.link[1].get('host')
     port = self.link[1].get('port')
     sock = s_socket.listen((host, port), relay=self)
     if sock != None:
         self.link[1]['port'] = sock.getsockname()[1]
     return sock
Ejemplo n.º 3
0
 def _initServerSock(self):
     host = self.link[1].get('host')
     port = self.link[1].get('port')
     sock = s_socket.listen((host,port),relay=self)
     if sock != None:
         self.link[1]['port'] = sock.getsockname()[1]
     return sock
Ejemplo n.º 4
0
    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')