Пример #1
0
def main():
    desc = 'Convert between [integer, hexadecimal, IPv4 address] <-> proquint representations. '\
        'See https://arxiv.org/html/0901.4016'

    parser = argparse.ArgumentParser(description=desc)
    parser.add_argument('-n', '--uint', action='store_true',
                        help='convert from proquint to 32-bit integer', required=False)
    parser.add_argument('-x', '--hex', action='store_true',
                        help='convert from proquint to hexadecimal', required=False)
    parser.add_argument('-i', '--ip', action='store_true',
                        help='convert from proquint to IPv4', required=False)
    parser.add_argument('val', nargs='?', type=str, default=None,
                        help='value to convert (if not specified, ' \
                        'IP address of the current host is printed)')

    args = parser.parse_args()

    target = None
    if args.uint:
        target = 'uint'
    elif args.hex:
        target = 'hex'
    elif args.ip:
        target = 'ip'

    try:
        if args.val is None:
            res = convert(get_my_ip())
        else:
            res = convert(args.val, target)
    except ValueError as e:
        print('{}'.format(str(e)))
    else:
        print('{}'.format(res))
Пример #2
0
    def init(self):
        """
        Intializing Scanner
        """
        self.router_ip = conf.route.route("0.0.0.0")[2]
        self.router_mac = GLOBAL_MAC

        self.my_ip = get_my_ip()
        self.my_mac = good_mac(Ether().src)
        
        self.perfix = self.router_ip.rsplit(".", 1)[0]
        self.generate_ips()

        self.add_me()
        self.add_router()
Пример #3
0
def main():
    desc = 'Convert between [integer, hexadecimal, IPv4 address] <-> proquint representations. '\
        'See https://arxiv.org/html/0901.4016'

    parser = argparse.ArgumentParser(description=desc)
    parser.add_argument('-n',
                        '--uint',
                        action='store_true',
                        help='convert from proquint to 32-bit integer',
                        required=False)
    parser.add_argument('-x',
                        '--hex',
                        action='store_true',
                        help='convert from proquint to hexadecimal',
                        required=False)
    parser.add_argument('-i',
                        '--ip',
                        action='store_true',
                        help='convert from proquint to IPv4',
                        required=False)
    parser.add_argument('val', nargs='?', type=str, default=None,
                        help='value to convert (if not specified, ' \
                        'IP address of the current host is printed)')

    args = parser.parse_args()

    target = None
    if args.uint:
        target = 'uint'
    elif args.hex:
        target = 'hex'
    elif args.ip:
        target = 'ip'

    try:
        if args.val is None:
            res = convert(get_my_ip())
        else:
            res = convert(args.val, target)
    except ValueError as e:
        print('{}'.format(str(e)))
    else:
        print('{}'.format(res))
Пример #4
0
def case_committee():
    global committee

    my_ip = get_my_ip() 

    generator = input("Input your generator: ")
    keypair = create_keypair(generator)
    committee = Committee(keypair[0], keypair[1], (my_ip, PORT))
    logger.info(f"Started as -> {short_key(keypair[1])}")

    # Add your ip to the peers-list
    add_as_public()

    peers = get_public_peers()
    logger.info(f"Found {len(peers)} peers: {peers}")

    #Connect to other peers
    logger.info("Found peers: ({})".format( peers ))
    committee.peers = peers
    
    # Perform an initial sync upon node startup
    for peer in committee.peers: 
        # Ask for new blocks
        try:
            blocks_sync = send_message((peer, PORT), "sync", committee.blocks[-1].signature, True)
            for missing_block in blocks_sync["data"]:
                committee.handle_block(missing_block, schedule=False)
        except:
            pass

        # Ask for other peers
        try:
            other_peers = send_message((peer, PORT), "peers", committee.peers, True)
            committee.new_peers(other_peers["data"])
        except:
            pass
            
    # Finally, after the node is synced and ready, start producing blocks yourself and serving requests
    committee.schedule_next_block()

    # Start server thread
    server_thread = threading.Thread(target=serve, name="server")
    server_thread.start()
Пример #5
0
    def __init__(self, my_name, is_moderator, comm_port):
        """ CommunicationModule manages the sending and receiving
        messages.

        Args:
            my_ip (str): IPv4 address of the user
            my_name (str): Username of the user
            comm_port (str): Communication port
        """
        self.my_ip = utils.get_my_ip()
        self.my_name = my_name
        self.port = comm_port
        self.database = Database()
        self.database_lock = threading.Lock(
        )  # will be used by tcp and udp listeners
        self.is_requesting = False if is_moderator else True
        self.is_moderator = is_moderator

        self.udp_server_thread = None
        self.tcp_server_thread = None
        self.app = None
Пример #6
0
else:
    LOGGING_CONFIG_FILE = CONFIGS_ROOT+"logging.conf"

"""
Specification of the debug and the quiet settings for the Home Server
Debug setting works to give or not exception stack like responses when an error
occurs instead of only the response error code.
Quiet setting works to enable/disable proxy logging to terminal.
"""
DEBUG = False
QUIET = True

"""
Specification of the IP address and port for the Proxy and the CoAP server
"""
PROXY_ADDR = utils.get_my_ip(public=True)
PROXY_PORT = 8080

COAP_ADDR = utils.get_my_ip()
COAP_PORT = 5683
COAP_MULTICAST = False

HOME_SERVER_TIMEOUT = 40
HOME_SERVER_TIMEOUT_GUARD = 10

"""
Specification of the default timeouts for the requests between the proxy and the
CoAP Server and for the monitoring of devices by the Home Server. All timeouts
are values on seconds.
"""
COMM_TIMEOUT = 5
Пример #7
0
    # utils.get_my_ip() would work fine in this case (the machine has only 1 NIC)
    # but this assignment is still here as a piece of legacy code
    
if  utils.get_hostname() == 'COSMICi':     # Dell Precision T3400 on Mike's desk in APCR-DRDL lab.
    MY_IP = "192.168.0.2"       # The static private IP address that is assigned to the central
                                # server node in our wireless router's DHCP config.
                                
#elif  utils.get_hostname() == 'Linux-PC':   # This was the Acer, but it's now no longer 
#    MY_IP = "192.168.0.4"                   # in use as a server.

    # The below is commented out because get_my_ip() works fine on this machine instead.
#elif  utils.get_hostname() == 'Theo':    # Mike's home office desktop.
    #MY_IP = '192.168.0.102'   # This is Theo's IP address when using my router at home.

else:
    MY_IP = utils.get_my_ip()   # Would this work in the above cases too?  Need to test.

            #|=================================================================
            #|
            #|  GPS_ANT_LOC                             [global constant]
            #|
            #|      Location of this site's main GPS antenna, as an
            #|      EarthCoords object.  (Latitude in degrees North,
            #|      longitude in degrees East, altitude in meters.)
            #|
            #|vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

GPS_ANT_LOC = earth_coords.EarthCoords(30.428236, -84.285, 40)
    # - These are the estimated coordinates of the GPS antenna in
    #   the middle of the windowsill of the Westernmost window in
    #   the Astroparticle & Cosmic Radiation Detector Research &
Пример #8
0
# but this assignment is still here as a piece of legacy code

if utils.get_hostname(
) == 'COSMICi':  # Dell Precision T3400 on Mike's desk in APCR-DRDL lab.
    MY_IP = "192.168.0.2"  # The static private IP address that is assigned to the central
    # server node in our wireless router's DHCP config.

#elif  utils.get_hostname() == 'Linux-PC':   # This was the Acer, but it's now no longer
#    MY_IP = "192.168.0.4"                   # in use as a server.

# The below is commented out because get_my_ip() works fine on this machine instead.
#elif  utils.get_hostname() == 'Theo':    # Mike's home office desktop.
#MY_IP = '192.168.0.102'   # This is Theo's IP address when using my router at home.

else:
    MY_IP = utils.get_my_ip(
    )  # Would this work in the above cases too?  Need to test.

    #|=================================================================
    #|
    #|  GPS_ANT_LOC                             [global constant]
    #|
    #|      Location of this site's main GPS antenna, as an
    #|      EarthCoords object.  (Latitude in degrees North,
    #|      longitude in degrees East, altitude in meters.)
    #|
    #|vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

GPS_ANT_LOC = earth_coords.EarthCoords(30.428236, -84.285, 40)
# - These are the estimated coordinates of the GPS antenna in
#   the middle of the windowsill of the Westernmost window in
#   the Astroparticle & Cosmic Radiation Detector Research &
Пример #9
0
 def __init__(self, alias, ip_address=None):
     assert type(alias) is str
     if not alias or alias.isspace():
         alias = "N/A"
     self._ip = get_my_ip() if ip_address is None else ip_address
     self._alias = alias