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)
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)
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)
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)
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()
def startProtocol(self): C.curvecpr_client_messager_glib_connected(self.client)
def finished(client, flag): print 'finished', flag C.curvecpr_client_messager_glib_finish(self.client)
def _processSendQ(self): if self.client[0].client.negotiated != CLIENT_PENDING: C.curvecpr_client_messager_glib_process_sendq(self.client) self.reschedule()
def write(self, data): ret = C.curvecpr_client_messager_glib_send(self.client, data, len(data)) if ret: print os.strerror(-ret) self.reschedule()