Пример #1
0
def create_tor():
    # ----------------------------------------------
    #                 Test Tor
    # ----------------------------------------------
    with yaspin(text="Testing Tor", color="cyan") as spinner:
        tor = test_tor()
        if tor['status']:
            logging.info(success("Tor Connected"))
            spinner.ok("✅ ")
            spinner.write(success("    Tor Connected [Success]"))
            print("")
            return (tor)
        else:
            logging.error(error("Could not connect to Tor"))
            spinner.fail("💥 ")
            spinner.write(warning("    Tor NOT connected [ERROR]"))
            print(
                error(
                    "    Could not connect to Tor. WARden requires Tor to run. Quitting..."
                ))
            print(
                info(
                    "    Download Tor at: https://www.torproject.org/download/"
                ))
            print("")
            exit()
Пример #2
0
def create_tor():
    from ansi_management import (warning, success, error, info, clear_screen,
                                 bold, muted, yellow, blue)
    from config import Config
    # ----------------------------------------------
    #                 Test Tor
    # ----------------------------------------------
    with yaspin(text="Testing Tor", color="cyan") as spinner:
        from connections import test_tor
        tor = test_tor()
        if tor['status']:
            logging.info(success("Tor Connected"))
            spinner.ok("✅ ")
            spinner.text = success("    Tor Connected [Success]")
            print("")
            return (tor)
        else:
            logging.error(error("Could not connect to Tor"))
            spinner.fail("💥 ")
            spinner.text = warning("    Tor NOT connected [ERROR]")
            print(error("    Could not connect to Tor."))

            print(
                info(
                    "    [i] If you have a Tor Browser installed try opening (leave it running) and try again."
                ))

            print(
                info("    [i] If you are running Linux try the command: ") +
                yellow('service tor start'))
            print(
                info(
                    "    or download Tor at: https://www.torproject.org/download/"
                ))
            print("")
Пример #3
0
def data_tor(tor=None):
    from node_warden import load_config
    config = load_config(quiet=True)
    if not tor:
        tor = test_tor()

    import socket
    try:
        local_ip = socket.gethostbyname(socket.gethostname())
    except Exception:
        local_ip = 'Error getting local IP'

    if not config['MAIN'].getboolean('hide_private_info'):
        tor_string = f""" ✅ {success('TOR Connected')}
    Running on port {info(bold(tor['port']))}
    Tor IP Address {warning(tor['post_proxy']['origin'])}
    Ping Time {tor['post_proxy_ping']}
    Global IP Address {warning(tor['pre_proxy']['origin'])}
    Ping Time {muted(tor['pre_proxy_ping'])}
    Local IP Address {warning(local_ip)}
    """
    else:
        tor_string = f""" ✅ {success('TOR Connected')}
    Running on port {info(bold(tor['port']))}
    Tor IP Address {yellow('** HIDDEN **')}
    Ping Time {tor['post_proxy_ping']}
    Global IP Address {yellow('** HIDDEN **')}
    Ping Time {muted(tor['pre_proxy_ping'])}
    Local IP Address {yellow('** HIDDEN **')}
    """
    return (tor_string)
Пример #4
0
def data_tor(tor=None):
    if not tor:
        tor = test_tor()

    import socket
    local_ip = socket.gethostbyname(socket.gethostname())
    tor_string = f""" ✅ {success('TOR Connected')}
 Running on port {info(bold(tor['port']))}
 Tor IP Address {warning(tor['post_proxy']['origin'])}
 Ping Time {tor['post_proxy_ping']}
 Global IP Address {warning(tor['pre_proxy']['origin'])}
 Ping Time {muted(tor['pre_proxy_ping'])}
 Local IP Address {warning(local_ip)}
 """
    return (tor_string)
Пример #5
0
def background_specter_update():
    # clean old messages
    app.message_handler.clean_category('Background Job')
    ts = time.time()
    message = Message(
        category='Background Job',
        message_txt="<span class='text-info'>Starting Background Update</span>"
    )
    app.message_handler.add_message(message)

    # Test: CHECK TOR
    from connections import test_tor
    app.tor = test_tor()
    if app.tor:
        message = Message(
            category='Background Job',
            message_txt="<span class='text-success'>✅ Tor Running</span>",
            notes="")
    else:
        message = Message(
            category='Background Job',
            message_txt=
            "<span class='text-danger'>Tor is down - Check Connections</span>",
            notes="")
    app.message_handler.add_message(message)

    # Authenticate
    try:
        app.specter.init_session()
        app.specter.specter_auth = True
        message = Message(
            category='Background Job',
            message_txt=
            "<span class='text-success'>Authentication credentials ok to Specter Server</span>"
        )
    except Exception as e:
        app.specter.specter_auth = False
        message = Message(
            category='Background Job',
            message_txt=
            f"<span class='text-danger'>Error authenticating to Specter: {e}</span>"
        )
    # Write message
    app.message_handler.add_message(message)

    # Get Gome data from specter
    metadata = app.specter.home_parser(load=False)

    # Log Home data
    if metadata['alias_list']:
        message = Message(
            category='Background Job',
            message_txt='Basic Info',
            notes=
            f"Found the following wallets:<br><span class='text-info'>{metadata['alias_list']}</span>"
        )
    else:
        message = Message(
            category='Background Job',
            message_txt='Basic Info',
            notes=
            "<span class='text-warning'>Could not get wallet info -  check Specter Server</span>"
        )

    app.message_handler.add_message(message)
    message = Message(
        category='Background Job',
        message_txt='Basic Info',
        notes=
        f"<span class='text-info'>Bitcoin Core is at block {metadata['bitcoin_core_data']['Blocks count']}</span>"
    )
    app.message_handler.add_message(message)
    #  End log
    ts_t = time.time()
    txs = app.specter.refresh_txs(load=False)
    te_t = time.time()
    # Log Home data

    message = Message(
        category='Background Job',
        message_txt=
        "<span class='text-success'>✅ Finished Transaction Refresh</span>",
        notes=
        f"<span class='text-info'>Loaded {len(txs['txlist'])} Transactions in {round((te_t - ts_t), 2)} seconds.</span>"
    )
    app.message_handler.add_message(message)
    #  End log

    # Check wallets
    wallets = app.specter.wallet_alias_list(load=True)
    if wallets is None:
        app.specter.specter_reached = False
        specter_message = 'Having trouble finding Specter transactions. Check Specter Server'
        flash(specter_message, 'warning')

    else:
        for wallet in wallets:
            ts_a = time.time()
            app.specter.wallet_info(wallet_alias=wallet, load=False)
            rescan = app.specter.rescan_progress(wallet_alias=wallet,
                                                 load=True)
            te_a = time.time()
            message = Message(
                category='Background Job',
                message_txt=
                f"<span class='text-success'>Loaded wallet {wallet} </span>",
                notes=
                f"Time to load: {round((te_a - ts_a), 2)} seconds. Rescan Info: {rescan} "
            )
            app.message_handler.add_message(message)

    # Other checks and tests
    specter_dict, specter_messages = specter_test()
    if specter_messages:
        if 'Read timed out' in str(specter_messages):
            app.specter.specter_reached = False
            flash(
                "Having trouble connecting to Specter. Connection timed out. Data may be outdated.",
                "warning")

        if 'Connection refused' in str(specter_messages):
            app.specter.specter_reached = False
            if app.specter.base_url:
                flash(
                    'Having some difficulty reaching Specter Server. ' +
                    f'Please make sure it is running at {app.specter.base_url}. Using cached data. Last Update: '
                    + app.specter.home_parser()['last_update'], 'warning')

        if 'Unauthorized Login' in str(specter_messages):
            app.specter.specter_reached = False
            app.specter.specter_auth = False
            flash(
                "Could not login to Specter Server [Unauthorized]. Check username and password."
            )

    # Success
    app.message_handler.clean_category('Specter Import')
    te = time.time()
    message = Message(
        category='Specter Import',
        message_txt=
        "<span class='text-success'>Background Job for Specter Done</span>",
        notes=f"Previous job took {round((te - ts), 2)} seconds to complete")
    app.message_handler.add_message(message)
    app.downloading = False
Пример #6
0
def testtor():
    from connections import test_tor
    return json.dumps(test_tor())