Exemple #1
0
    def _stuned(ip):
        if stun.getUDPClient() is None:
            print 'UDP CLIENT IS NONE - EXIT'
            reactor.stop()
            return

        print '+++++ EXTERNAL UDP ADDRESS IS', stun.getUDPClient().externalAddress
        
        if sys.argv[1] == 'listen':
            print '+++++ START LISTENING'
            return
        
        if sys.argv[1] == 'connect':
            print '+++++ CONNECTING TO REMOTE MACHINE'
            _try2connect()
            return

        lid = misc.getLocalIdentity()
        udp_contact = 'udp://'+stun.getUDPClient().externalAddress[0]+':'+str(stun.getUDPClient().externalAddress[1])
        lid.setProtoContact('udp', udp_contact)
        lid.sign()
        misc.setLocalIdentity(lid)
        misc.saveLocalIdentity()
        
        print '+++++ UPDATE IDENTITY', str(lid.contacts)
        _send_servers().addBoth(_id_sent)
Exemple #2
0
def test1():
    """
    Some tests.
    """
    myidentity=misc.getLocalIdentity()
    print 'getIP =', myidentity.getIP()
    if myidentity.Valid():
        print "myidentity is Valid!!!!"
    else:
        print "myidentity is not Valid"
        misc.saveLocalIdentity()            # sign and save
        raise Exception("myidentity is not Valid")
    print "myidentity.contacts"
    print myidentity.contacts
    print "len myidentity.contacts "
    print len (myidentity.contacts)
    print "len myidentity.contacts[0] "
    print myidentity.contacts[0]
    con=myidentity.getContact()
    print "con:", con, type(con)
    protocol, machine, port, filename = nameurl.UrlParse(con)
    print protocol, machine, port, filename
    print "identity.main serialize:\n", myidentity.serialize()
    for index in range(myidentity.getContactsNumber()):
        proto, host, port, filename = myidentity.getContactParts(index)
        print '[%s] [%s] [%s] [%s]' % (proto, host, port, filename)
Exemple #3
0
def update():
    """
    A good way to check all things - load and sign again.
    """
    dhnio.init()
    settings.init()
    src = dhnio.ReadTextFile(settings.LocalIdentityFilename())
    misc.setLocalIdentity(identity(xmlsrc=src))
    misc.getLocalIdentity().sign()
    misc.saveLocalIdentity()
    print misc.getLocalIdentity().serialize()    
Exemple #4
0
def main():
    """
    This should print a current identity or create a new one.
    """
    misc.loadLocalIdentity()
    if misc.isLocalIdentityReady():
        misc.getLocalIdentity().sign()
        print misc.getLocalIdentity().serialize()
        print 'Valid is: ', misc.getLocalIdentity().Valid()
    else:
        misc.setLocalIdentity(makeDefaultIdentity(sys.argv[1]))
        misc.saveLocalIdentity()
        print misc.getLocalIdentity().serialize()
        print 'Valid is: ', misc.getLocalIdentity().Valid()
        misc._LocalIdentity = None
        misc.loadLocalIdentity()