Ejemplo n.º 1
0
#                 send_connections_info(node.config['account_addr'], node.config['token'], connections)
#     except Exception as err:
#         print(str(err))
#     time.sleep(5)

if __name__ == "__main__":
    config = None
    if path.exists(CONFIG_DATA_PATH) is True:
        config = json.load(open(CONFIG_DATA_PATH, 'r'))
    else:
        print('ERROR: {} not found.'.format(CONFIG_DATA_PATH))
        exit(1)

    if (len(config['account_addr']) == 0) and (len(sys.argv) > 1):
        PASSWORD = sys.argv[1]
        keystore, account_addr = create_account(PASSWORD)
        if (keystore is not None) and (account_addr is not None):
            keystore_file = open(KEYSTORE_FILE_PATH, 'w')
            keystore_file.writelines(keystore)
            keystore_file.close()

            config['account_addr'] = account_addr
        else:
            print('Error occurred while creating a new account.')
            exit(3)
    elif (len(config['account_addr']) == 42) and (len(sys.argv) == 1):
        pass
    else:
        print(
            'Password is not provided OR `account_addr` in config is incorrect. \
               Please try again after deleting config file.')
Ejemplo n.º 2
0
Archivo: app.py Proyecto: wtyn/sentinel
                                          node.account['token'], _connections)

            send_nodeinfo(node, {'type': 'alive'})
        except Exception as err:
            print(str(err))
        time.sleep(5)


if __name__ == "__main__":
    node = None
    argv_len = len(sys.argv)
    if path.exists(ACCOUNT_DATA_PATH) is True:
        node = Node(resume=True)
    elif argv_len > 1:
        PASSWORD = sys.argv[1]
        create_account(PASSWORD)
        node = Node(resume=True)
    else:
        print('ERROR: {} not found.'.format(ACCOUNT_DATA_PATH))
        exit(1)

    openvpn = OpenVPN()
    if node.account['token'] is None:
        register_node(node)
    openvpn.start()
    send_nodeinfo(node, {'type': 'vpn'})
    start_new_thread(tasks, ())
    while True:
        line = openvpn.vpn_proc.stdout.readline().strip()
        line_len = len(line)
        if line_len > 0: