Exemplo n.º 1
0
 def isCurrentInterfaceActive(self, *args, **kwargs):
     # TODO: not sure about external IP
     # because if you have a white IP it should be the same as your local IP
     loc = strng.to_bin(misc.readLocalIP())
     ext = strng.to_bin(misc.readExternalIP())
     ips = args[0]
     if _Debug:
         lg.args(_DebugLevel, local=loc, external=ext)
     return (loc in ips) or (ext in ips)
Exemplo n.º 2
0
def SendSettings(doAck=False, packetID=None):
    """
    Say what eccmap we are using for recovery info.
    How many suppliers we want (probably same as used by eccmap but just in case).
    Say how much disk we are donating now and home much we need from our suppliers.
    The response should be an Ack packet from Central server and
    also it can sent us a new lsit of suppliers with ListContacts packet.
    """
    if packetID is None:
        packetID = packetid.UniqueID()
    sdict = {}
    sdict['s'] = str(settings.getCentralNumSuppliers())
    # donated = DiskSpace(s=settings.getCentralMegabytesDonated())
    # needed = DiskSpace(s=settings.getCentralMegabytesNeeded())
    # sdict['d'] = str(donated.getValueMb())
    # sdict['n'] = str(needed.getValueMb())
    sdict['d'] = str(diskspace.GetMegaBytesFromString(settings.getCentralMegabytesDonated()))
    sdict['n'] = str(diskspace.GetMegaBytesFromString(settings.getCentralMegabytesNeeded()))
    sdict['e'] = settings.getECC()
    sdict['p'] = str(settings.BasePricePerGBDay())
    sdict['e1'] = str(settings.getEmergencyEmail())
    sdict['e2'] = str(settings.getEmergencyPhone())
    sdict['e3'] = str(settings.getEmergencyFax())
    sdict['e4'] = str(settings.getEmergencyOther()).replace('\n', '<br>')
    sdict['mf'] = settings.getEmergencyFirstMethod()
    sdict['ms'] = settings.getEmergencySecondMethod()
    sdict['ie'] = misc.readExternalIP()
    sdict['il'] = misc.readLocalIP()
    sdict['nm'] = str(settings.uconfig('personal.personal-name'))
    sdict['sn'] = str(settings.uconfig('personal.personal-surname'))
    sdict['nn'] = str(settings.uconfig('personal.personal-nickname'))
    sdict['bt'] = str(settings.uconfig('personal.personal-betatester'))
    i = 0
    for idurl in contacts.getCorrespondentIDs():
        sdict['f%03d' % i] = idurl
        i += 1

    data = dhnio._pack_dict(sdict)
    pid = send2central(commands.Settings(), data, doAck, packetID)
    dhnio.Dprint(4, "central_service.SendSettings PacketID=[%s]" % pid)
    return pid
Exemplo n.º 3
0
 def isCurrentInterfaceActive(self, *args, **kwargs):
     # I am not sure about external IP,
     # because if you have a white IP it should be the same with your local IP
     return (strng.to_bin(misc.readLocalIP()) in args[0]) or (strng.to_bin(misc.readExternalIP()) in args[0])
Exemplo n.º 4
0
 def isCurrentInterfaceActive(self, arg):
     # I am not sure about external IP,
     # because if you have a white IP it should be the same with your local IP
     return (misc.readLocalIP() in arg) or (misc.readExternalIP() in arg)
Exemplo n.º 5
0
def IPisLocal():
    externalip = misc.readExternalIP()
    localip = misc.readLocalIP()
    return localip != externalip
Exemplo n.º 6
0
 def isCurrentInterfaceActive(self, arg):
     # Not sure about external IP, because if we have white IP it is the same to local IP
     return ( misc.readLocalIP() in arg ) or ( misc.readExternalIP() in arg )