예제 #1
0
파일: stream.py 프로젝트: sajith/txi2p
 def startListening(self):
     if cmpSAM(self.session.samVersion, '3.2') >= 0:
         active = 8
     else:
         active = 1
     for i in range(0, active):
         self.openAccept()
예제 #2
0
 def sendDestGenerate(self, samVersion, sigType=None):
     msg = 'DEST GENERATE'
     if cmpSAM(samVersion, '3.1') >= 0:
         msg += ' SIGNATURE_TYPE=%s' % (sigType and sigType
                                        or 'EdDSA_SHA512_Ed25519')
     msg += '\n'
     self.transport.write(msg.encode('utf-8'))
예제 #3
0
 def startListening(self):
     if cmpSAM(self.session.samVersion, '3.2') >= 0:
         active = 8
     else:
         active = 1
     for i in range(0, active):
         self.openAccept()
예제 #4
0
 def postLookup(self, dest):
     # Help keep the session open
     if cmpSAM(self.factory.samVersion, '3.2') >= 0:
         self.startPinging()
     else:
         try:
             self.sender.transport.setTcpKeepAlive(1)
         except AttributeError as e:
             eprint(e)
     self.factory.sessionCreated(self, dest)
예제 #5
0
파일: session.py 프로젝트: str4d/txi2p
 def postLookup(self, dest):
     # Help keep the session open
     if cmpSAM(self.factory.samVersion, '3.2') >= 0:
         self.startPinging()
     else:
         try:
             self.sender.transport.setTcpKeepAlive(1)
         except AttributeError as e:
             eprint(e)
     self.factory.sessionCreated(self, dest)
예제 #6
0
파일: session.py 프로젝트: str4d/txi2p
 def sendSessionCreate(self, samVersion, style, id, privKey=None, localPort=None, options={}, sigType=None):
     msg = 'SESSION CREATE'
     msg += ' STYLE=%s' % style
     msg += ' ID=%s' % id
     msg += ' DESTINATION=%s' % (privKey if privKey else 'TRANSIENT')
     if cmpSAM(samVersion, '3.1') >= 0 and not privKey:
         msg += ' SIGNATURE_TYPE=%s' % (sigType and sigType or c.DEFAULT_SIGTYPE)
     if localPort:
         msg += ' FROM_PORT=%d' % localPort
     for key in options:
         msg += ' %s=%s' % (key, options[key])
     msg += '\n'
     self.transport.write(msg)
예제 #7
0
    def destGenerated(self, result=None, pub=None, priv=None, message=None):
        if result:
            # If the user didn't specify a SigType, try falling back
            if cmpSAM(self.factory.samVersion, '3.1') >= 0 and \
                    message.startswith('SIGNATURE_TYPE') and \
                    not self.factory.sigType:
                fallback = 'ECDSA_SHA256_P256' in message and 'DSA_SHA1' or 'ECDSA_SHA256_P256'
                eprint('Warning: %s, falling back to %s' % (message, fallback))
                self.sender.sendDestGenerate(self.factory.samVersion, fallback)
            else:
                self.factory.resultNotOK(result, message)
            return

        self.factory.destGenerated(pub, priv)
        self.sender.transport.loseConnection()
예제 #8
0
파일: session.py 프로젝트: str4d/txi2p
    def destGenerated(self, result=None, pub=None, priv=None, message=None):
        if result:
            # If the user didn't specify a SigType, try falling back
            if cmpSAM(self.factory.samVersion, '3.1') >= 0 and \
                    message.startswith('SIGNATURE_TYPE') and \
                    not self.factory.sigType:
                fallback = 'ECDSA_SHA256_P256' in message and 'DSA_SHA1' or 'ECDSA_SHA256_P256'
                eprint('Warning: %s, falling back to %s' % (message, fallback))
                self.sender.sendDestGenerate(
                    self.factory.samVersion,
                    fallback)
            else:
                self.factory.resultNotOK(result, message)
            return

        self.factory.destGenerated(pub, priv)
        self.sender.transport.loseConnection()
예제 #9
0
    def create(self, result, destination=None, message=None):
        if result != c.RESULT_OK:
            # If the user didn't specify a SigType, try falling back
            if cmpSAM(self.factory.samVersion, '3.1') >= 0 and \
                    message.startswith('SIGNATURE_TYPE') and \
                    not self.factory.sigType:
                fallback = 'ECDSA_SHA256_P256' in message and 'DSA_SHA1' or 'ECDSA_SHA256_P256'
                eprint('Warning: %s, falling back to %s' % (message, fallback))
                self.sender.sendSessionCreate(self.factory.samVersion,
                                              self.factory.style,
                                              self.factory.nickname,
                                              self.factory.privKey,
                                              self.factory.localPort,
                                              self.factory.options, fallback)
            else:
                self.factory.resultNotOK(result, message)
            return

        self.factory.privKey = destination
        self.sender.sendNamingLookup('ME')
        self.currentRule = 'State_naming'
예제 #10
0
 def sendSessionCreate(self,
                       samVersion,
                       style,
                       id,
                       privKey=None,
                       localPort=None,
                       options={},
                       sigType=None):
     msg = 'SESSION CREATE'
     msg += ' STYLE=%s' % style
     msg += ' ID=%s' % id
     msg += ' DESTINATION=%s' % (privKey if privKey else 'TRANSIENT')
     if cmpSAM(samVersion, '3.1') >= 0 and not privKey:
         msg += ' SIGNATURE_TYPE=%s' % (sigType and sigType
                                        or c.DEFAULT_SIGTYPE)
     if localPort:
         msg += ' FROM_PORT=%d' % localPort
     for key in options:
         msg += ' %s=%s' % (key, options[key])
     msg += '\n'
     self.transport.write(msg.encode('utf-8'))
예제 #11
0
파일: session.py 프로젝트: str4d/txi2p
    def create(self, result, destination=None, message=None):
        if result != c.RESULT_OK:
            # If the user didn't specify a SigType, try falling back
            if cmpSAM(self.factory.samVersion, '3.1') >= 0 and \
                    message.startswith('SIGNATURE_TYPE') and \
                    not self.factory.sigType:
                fallback = 'ECDSA_SHA256_P256' in message and 'DSA_SHA1' or 'ECDSA_SHA256_P256'
                eprint('Warning: %s, falling back to %s' % (message, fallback))
                self.sender.sendSessionCreate(
                    self.factory.samVersion,
                    self.factory.style,
                    self.factory.nickname,
                    self.factory.privKey,
                    self.factory.localPort,
                    self.factory.options,
                    fallback)
            else:
                self.factory.resultNotOK(result, message)
            return

        self.factory.privKey = destination
        self.sender.sendNamingLookup('ME')
        self.currentRule = 'State_naming'
예제 #12
0
파일: session.py 프로젝트: str4d/txi2p
 def sendDestGenerate(self, samVersion, sigType=None):
     msg = 'DEST GENERATE'
     if cmpSAM(samVersion, '3.1') >= 0:
         msg += ' SIGNATURE_TYPE=%s' % (sigType and sigType or 'EdDSA_SHA512_Ed25519')
     msg += '\n'
     self.transport.write(msg)