コード例 #1
0
ファイル: dustSocksServer.py プロジェクト: blanu/Dust
def handshake(conn):
  ekeypair=createEphemeralKeypair()

  epub=yield conn.read(KEY_SIZE)
  esession=makeEphemeralSession(ekeypair, epub).bytes
  print('esssion: '+encode(esession))
  coder=lite_socket(esession.bytes)
  yield conn.write(ekeypair.public.bytes)

  yield Return(coder)
コード例 #2
0
def handshake(conn):
    ekeypair = createEphemeralKeypair()

    epub = yield conn.read(KEY_SIZE)
    esession = makeEphemeralSession(ekeypair, epub).bytes
    print('esssion: ' + encode(esession))
    coder = lite_socket(esession.bytes)
    yield conn.write(ekeypair.public.bytes)

    yield Return(coder)
コード例 #3
0
ファイル: dust_transport.py プロジェクト: blanu/py-obfsproxy
    def receivedUpstream(self, data):
        """
        This is the callback method which is called by the framework when bytes have been received on the upstream socket.
        In the Dust protocol, the upstream handshake is read, and then the protocol is switched to STREAM mode, at which point all bytes received from upstream are encrypted and sent downstream.
        """

        if self.state == HANDSHAKE:
            self.epub = self.read(self.upstreamConnection, self.epub, HANDSHAKE_SIZE)
            if self.checkTransition(self.epub, HANDSHAKE_SIZE, STREAM):
                esession = makeEphemeralSession(self.ekeypair, self.epub)
                self.coder = lite_socket(esession)

                data = self.downstreamConnection.read_some()
                if data:
                    self.upstreamConnection.write(self.coder.encode(data))

                data = self.upstreamConnection.read_some()
                if data:
                    self.downstreamConnection.write(self.coder.decode(data))
        else:
            data = self.upstreamConnection.read_some()
            if data:
                self.downstreamConnection.write(self.coder.decode(data))
コード例 #4
0
    def receivedUpstream(self, data):
        """
        This is the callback method which is called by the framework when bytes have been received on the upstream socket.
        In the Dust protocol, the upstream handshake is read, and then the protocol is switched to STREAM mode, at which point all bytes received from upstream are encrypted and sent downstream.
        """

        if self.state == HANDSHAKE:
            self.epub = self.read(self.upstreamConnection, self.epub,
                                  HANDSHAKE_SIZE)
            if self.checkTransition(self.epub, HANDSHAKE_SIZE, STREAM):
                esession = makeEphemeralSession(self.ekeypair, self.epub)
                self.coder = lite_socket(esession)

                data = self.downstreamConnection.read_some()
                if data:
                    self.upstreamConnection.write(self.coder.encode(data))

                data = self.upstreamConnection.read_some()
                if data:
                    self.downstreamConnection.write(self.coder.decode(data))
        else:
            data = self.upstreamConnection.read_some()
            if data:
                self.downstreamConnection.write(self.coder.decode(data))