Exemplo n.º 1
0
 def reschedule(self):
     nextActionIn = C.curvecpr_client_messager_glib_next_timeout(self.client) / NS
     if self.delayedCall is not None and self.delayedCall.active():
         self.delayedCall.reset(nextActionIn)
     else:
         self.delayedCall = self.reactor.callLater(
             nextActionIn, self._processSendQ)
Exemplo n.º 2
0
    def setupClient(self):
        self.client = ffi.new('struct curvecpr_client_messager_glib *')
        self.setupClientFunctions()

        self.client_cf.pending_maximum = 2 ** 32
        self.client_cf.sendmarkq_maximum = 2 ** 16
        self.client_cf.recvmarkq_maximum = 2 ** 16

        self.client_cf[0].my_extension = self.clientExtension
        self.client_cf[0].my_global_pk = str(self.clientKey.public_key)
        self.client_cf[0].my_global_sk = str(self.clientKey)

        self.client_cf[0].their_extension = self.serverExtension
        self.client_cf[0].their_global_pk = str(self.serverKey)
        C.curvecpr_util_encode_domain_name(self.client_cf[0].their_domain_name, 'example.com')

        C.curvecpr_client_messager_glib_new(self.client, self.client_cf)
Exemplo n.º 3
0
 def reschedule(self):
     nextActionIn = C.curvecpr_client_messager_glib_next_timeout(
         self.client) / NS
     if self.delayedCall is not None and self.delayedCall.active():
         self.delayedCall.reset(nextActionIn)
     else:
         self.delayedCall = self.reactor.callLater(nextActionIn,
                                                   self._processSendQ)
Exemplo n.º 4
0
    def setupClient(self):
        self.client = ffi.new('struct curvecpr_client_messager_glib *')
        self.setupClientFunctions()

        self.client_cf.pending_maximum = 2**32
        self.client_cf.sendmarkq_maximum = 2**16
        self.client_cf.recvmarkq_maximum = 2**16

        self.client_cf[0].my_extension = self.clientExtension
        self.client_cf[0].my_global_pk = str(self.clientKey.public_key)
        self.client_cf[0].my_global_sk = str(self.clientKey)

        self.client_cf[0].their_extension = self.serverExtension
        self.client_cf[0].their_global_pk = str(self.serverKey)
        C.curvecpr_util_encode_domain_name(self.client_cf[0].their_domain_name,
                                           'example.com')

        C.curvecpr_client_messager_glib_new(self.client, self.client_cf)
Exemplo n.º 5
0
 def datagramReceived(self, data, host_port):
     print 'got', len(data), 'bytes'
     C.curvecpr_client_messager_glib_recv(self.client, data, len(data))
     if self.client[0].client.negotiated != CLIENT_PENDING:
         self._processSendQ()
Exemplo n.º 6
0
 def startProtocol(self):
     C.curvecpr_client_messager_glib_connected(self.client)
Exemplo n.º 7
0
 def finished(client, flag):
     print 'finished', flag
     C.curvecpr_client_messager_glib_finish(self.client)
Exemplo n.º 8
0
 def _processSendQ(self):
     if self.client[0].client.negotiated != CLIENT_PENDING:
         C.curvecpr_client_messager_glib_process_sendq(self.client)
     self.reschedule()
Exemplo n.º 9
0
 def write(self, data):
     ret = C.curvecpr_client_messager_glib_send(self.client, data, len(data))
     if ret:
         print os.strerror(-ret)
     self.reschedule()
Exemplo n.º 10
0
 def finished(client, flag):
     print 'finished', flag
     C.curvecpr_client_messager_glib_finish(self.client)
Exemplo n.º 11
0
 def _processSendQ(self):
     if self.client[0].client.negotiated != CLIENT_PENDING:
         C.curvecpr_client_messager_glib_process_sendq(self.client)
     self.reschedule()
Exemplo n.º 12
0
 def write(self, data):
     ret = C.curvecpr_client_messager_glib_send(self.client, data,
                                                len(data))
     if ret:
         print os.strerror(-ret)
     self.reschedule()
Exemplo n.º 13
0
 def datagramReceived(self, data, host_port):
     print 'got', len(data), 'bytes'
     C.curvecpr_client_messager_glib_recv(self.client, data, len(data))
     if self.client[0].client.negotiated != CLIENT_PENDING:
         self._processSendQ()
Exemplo n.º 14
0
 def startProtocol(self):
     C.curvecpr_client_messager_glib_connected(self.client)