def start_tunnel(self, options):
        """
        Main method to startup a tunnel helper and add a signal handler.
        """

        socks5_port = options["socks5"]
        introduce_port = options["introduce"]
        dispersy_port = options["dispersy"]
        crawl_keypair_filename = options["crawl"]

        settings = TunnelSettings()

        # For disabling anonymous downloading, limiting download to hidden services only.
        settings.min_circuits = 0
        settings.max_circuits = 0

        if socks5_port is not None:
            settings.socks_listen_ports = range(socks5_port, socks5_port + 5)
        else:
            settings.socks_listen_ports = [random.randint(1000, 65535) for _ in range(5)]

        settings.become_exitnode = bool(options["exit"])
        if settings.become_exitnode:
            logger.info("Exit-node enabled")
        else:
            logger.info("Exit-node disabled")

        settings.enable_trustchain = bool(options["trustchain"])
        if settings.enable_trustchain:
            logger.info("Trustchain enabled")
        else:
            logger.info("Trustchain disabled")

        tunnel = Tunnel(settings, crawl_keypair_filename, dispersy_port)
        StandardIO(LineHandler(tunnel))

        def stop_tunnel_api():
            if self.tunnel_site:
                return maybeDeferred(self.tunnel_site.stopListening)
            return succeed(None)

        def signal_handler(sig, _):
            msg("Received shut down signal %s" % sig)
            if not self._stopping:
                self._stopping = True
                msg("Setting the tunnel should_run variable to False")
                tunnel.should_run = False
                tunnel.stop().addCallback(lambda _: stop_tunnel_api().addCallback(lambda _: reactor.stop()))

        signal.signal(signal.SIGINT, signal_handler)
        signal.signal(signal.SIGTERM, signal_handler)

        tunnel.start(introduce_port)

        if options["tunnelapi"] > 0:
            self.tunnel_site = self.site = reactor.listenTCP(options["tunnelapi"],
                                                             server.Site(resource=TunnelRootEndpoint(tunnel)))
 def load_communities(self, session, dispersy, crawler=False):
     keypair = dispersy.crypto.generate_key(u"curve25519")
     dispersy_member = dispersy.get_member(private_key=dispersy.crypto.key_to_bin(keypair))
     settings = TunnelSettings(tribler_session=session)
     settings.become_exitnode = True
     if crawler:
         dispersy.define_auto_load(BarterCommunityCrawler, dispersy_member, (session, settings), load=True)
     else:
         dispersy.define_auto_load(BarterCommunity, dispersy_member, (session, settings), load=True)
    def __init__(self, enableExitNode, useTestServer):
        #prototype2 starts in development mode unless specifically told otherwise
        s = Settings()
        rpc = Client('185.99.132.220', '8000')
        wallet = Wallet()

        if enableExitNode:
            print("starting Tribler Exitnode")
            settings = TunnelSettings()

            # For disabling anonymous downloading, limiting download to hidden services only
            settings.min_circuits = 0
            settings.max_circuits = 0
            settings.become_exitnode = True
            crawl_keypair_filename = None
            dispersy_port = -1

            tunnel = Tunnel(settings, crawl_keypair_filename, dispersy_port)
            #StandardIO(LineHandler(tunnel, profile))
            tunnel.start(None)

        try:
            rpc.add('A wallet address')
            thread.start_new_thread(update_rpc_server, ())
        except:
            print("RPC failed to add.")
        bc = Birthchamber()

        if useTestServer:
            #this part works for this version, and since this script is just for doing integration it should be fine
            #i still need to write a dummy vpsbuyer that simply takes these values
            bc.get_child_using_test_server('master', 'prototype2_agentCore.py')
            v = bc.vps

            print("preparing to run protoype2_agentcore on the following server:")
            print("SSHUsername: "******"SSHPassword: "******"SSHIP: "+v.IP)



        else:
            succes = False
            while succes == False:            
                while(wallet.balance()<bc.getChildCost()):
                    print("Not enough bitcoins, waiting for money to arrive")
                    time.sleep(600)
                succes = bc.getChild('master', 'prototype2_agentCore.py')

        print("")
        dt = datetime.now()
        print(dt.strftime("%A, %d. %B %Y %I:%M%p"))
        print("started up agentCore on child, transferring own funds to child")
        v= bc.vps
        ssh = SSH(v.getIP(),v.getSSHUsername(),v.getSSHPassword(),22)
        self.transfer_funds_to_child_wallet(ssh, v)
Beispiel #4
0
            def load_community(session):
                keypair = dispersy.crypto.generate_key(u"curve25519")
                dispersy_member = dispersy.get_member(private_key=dispersy.crypto.key_to_bin(keypair))
                settings = TunnelSettings(tribler_session=session)
                if not crypto_enabled:
                    settings.crypto = NoCrypto()
                settings.become_exitnode = become_exit_node

                return dispersy.define_auto_load(HiddenTunnelCommunity,
                                                 dispersy_member,
                                                 (session, settings),
                                                 load=True)[0]
Beispiel #5
0
            def load_community(session):
                keypair = dispersy.crypto.generate_key(u"curve25519")
                dispersy_member = dispersy.get_member(
                    private_key=dispersy.crypto.key_to_bin(keypair))
                settings = TunnelSettings(tribler_session=session)
                if not crypto_enabled:
                    settings.crypto = NoCrypto()
                settings.become_exitnode = become_exit_node

                return dispersy.define_auto_load(HiddenTunnelCommunity,
                                                 dispersy_member,
                                                 (session, settings),
                                                 load=True)[0]
Beispiel #6
0
 def load_communities(self, session, dispersy, crawler=False):
     keypair = dispersy.crypto.generate_key(u"curve25519")
     dispersy_member = dispersy.get_member(
         private_key=dispersy.crypto.key_to_bin(keypair))
     settings = TunnelSettings(tribler_session=session)
     settings.become_exitnode = True
     if crawler:
         dispersy.define_auto_load(BarterCommunityCrawler,
                                   dispersy_member, (session, settings),
                                   load=True)
     else:
         dispersy.define_auto_load(BarterCommunity,
                                   dispersy_member, (session, settings),
                                   load=True)
Beispiel #7
0
    def load_tunnel_community_in_session(self, session, exitnode=False):
        """
        Load the tunnel community in a given session. We are using our own tunnel community here instead of the one
        used in Tribler.
        """
        dispersy = session.get_dispersy_instance()
        keypair = dispersy.crypto.generate_key(u"curve25519")
        dispersy_member = dispersy.get_member(private_key=dispersy.crypto.key_to_bin(keypair))
        settings = TunnelSettings(tribler_session=session)
        if not self.crypto_enabled:
            settings.crypto = NoCrypto()
        settings.become_exitnode = exitnode

        return dispersy.define_auto_load(HiddenTunnelCommunityTests, dispersy_member, (session, settings), load=True)[0]
Beispiel #8
0
def main(argv):
    parser = argparse.ArgumentParser(description='Anonymous Tunnel CLI interface')

    try:
        parser.add_argument('-p', '--socks5', help='Socks5 port')
        parser.add_argument('-x', '--exit', help='Allow being an exit-node')
        parser.add_argument('-i', '--introduce', help='Introduce the dispersy port of another tribler instance')
        parser.add_argument('-d', '--dispersy', help='Dispersy port')
        parser.add_argument('-c', '--crawl', help='Enable crawler and use the keypair specified in the given filename')
        parser.add_argument('-j', '--json', help='Enable JSON api, which will run on the provided port number ' +
                                                 '(only available if the crawler is enabled)', type=int)
        parser.add_argument('-y', '--yappi', help="Profiling mode, either 'wall' or 'cpu'")
        parser.add_help = True
        args = parser.parse_args(sys.argv[1:])

    except argparse.ArgumentError:
        parser.print_help()
        sys.exit(2)

    socks5_port = int(args.socks5) if args.socks5 else None
    introduce_port = int(args.introduce) if args.introduce else None
    dispersy_port = int(args.dispersy) if args.dispersy else -1
    crawl_keypair_filename = args.crawl
    profile = args.yappi if args.yappi in ['wall', 'cpu'] else None

    if profile:
        yappi.set_clock_type(profile)
        yappi.start(builtins=True)
        logger.error("Profiling using %s time" % yappi.get_clock_type()['type'])

    if crawl_keypair_filename and not os.path.exists(crawl_keypair_filename):
        logger.error("Could not find keypair filename", crawl_keypair_filename)
        sys.exit(1)

    settings = TunnelSettings()

    # For disbling anonymous downloading, limiting download to hidden services only
    settings.min_circuits = 0
    settings.max_circuits = 0

    if socks5_port is not None:
        settings.socks_listen_ports = range(socks5_port, socks5_port + 5)
    else:
        settings.socks_listen_ports = [random.randint(1000, 65535) for _ in range(5)]

    settings.become_exitnode = True if args.exit in ['true'] else False
    if settings.become_exitnode:
        logger.info("Exit-node enabled")
    else:
        logger.info("Exit-node disabled")

    tunnel = Tunnel(settings, crawl_keypair_filename, dispersy_port)
    StandardIO(LineHandler(tunnel, profile))
    tunnel.start(introduce_port)

    if crawl_keypair_filename and args.json > 0:
        cherrypy.config.update({'server.socket_host': '0.0.0.0', 'server.socket_port': args.json})
        cherrypy.quickstart(tunnel)
    else:
        while True:
            time.sleep(1)
Beispiel #9
0
from Birthchamber import Birthchamber
from ZappiehostBuyer import ZappiehostBuyer
from Wallet import Wallet
from time import sleep
from Tribler.community.tunnel.tunnel_community import TunnelSettings
from twisted.internet.stdio import StandardIO


wallet = Wallet()

settings = TunnelSettings()

# For disabling anonymous downloading, limiting download to hidden services only
settings.min_circuits = 0
settings.max_circuits = 0
settings.become_exitnode = True
crawl_keypair_filename = None
dispersy_port = -1 

tunnel = Tunnel(settings, crawl_keypair_filename, dispersy_port)
#StandardIO(LineHandler(tunnel, profile))
tunnel.start(None)



print("successful instantiation")

#prepare the possibility to get a child
bc = Birthchamber()

#this should actually compare with the current necessary bitcoins plus a small margin
Beispiel #10
0
def main(argv):
    parser = argparse.ArgumentParser(
        description='Anonymous Tunnel CLI interface')

    try:
        parser.add_argument('-p', '--socks5', help='Socks5 port')
        parser.add_argument('-x', '--exit', help='Allow being an exit-node')
        parser.add_argument(
            '-i',
            '--introduce',
            help='Introduce the dispersy port of another tribler instance')
        parser.add_argument('-d', '--dispersy', help='Dispersy port')
        parser.add_argument(
            '-c',
            '--crawl',
            help=
            'Enable crawler and use the keypair specified in the given filename'
        )
        parser.add_argument(
            '-j',
            '--json',
            help='Enable JSON api, which will run on the provided port number '
            + '(only available if the crawler is enabled)',
            type=int)
        parser.add_argument('-y',
                            '--yappi',
                            help="Profiling mode, either 'wall' or 'cpu'")
        parser.add_help = True
        args = parser.parse_args(sys.argv[1:])

    except argparse.ArgumentError:
        parser.print_help()
        sys.exit(2)

    socks5_port = int(args.socks5) if args.socks5 else None
    introduce_port = int(args.introduce) if args.introduce else None
    dispersy_port = int(args.dispersy) if args.dispersy else -1
    crawl_keypair_filename = args.crawl
    profile = args.yappi if args.yappi in ['wall', 'cpu'] else None

    if profile:
        yappi.set_clock_type(profile)
        yappi.start(builtins=True)
        logger.error("Profiling using %s time" %
                     yappi.get_clock_type()['type'])

    if crawl_keypair_filename and not os.path.exists(crawl_keypair_filename):
        logger.error("Could not find keypair filename", crawl_keypair_filename)
        sys.exit(1)

    settings = TunnelSettings()

    # For disbling anonymous downloading, limiting download to hidden services only
    settings.min_circuits = 0
    settings.max_circuits = 0

    if socks5_port is not None:
        settings.socks_listen_ports = range(socks5_port, socks5_port + 5)
    else:
        settings.socks_listen_ports = [
            random.randint(1000, 65535) for _ in range(5)
        ]

    settings.become_exitnode = True if args.exit in ['true'] else False
    if settings.become_exitnode:
        logger.info("Exit-node enabled")
    else:
        logger.info("Exit-node disabled")

    tunnel = Tunnel(settings, crawl_keypair_filename, dispersy_port)
    StandardIO(LineHandler(tunnel, profile))
    tunnel.start(introduce_port)

    if crawl_keypair_filename and args.json > 0:
        cherrypy.config.update({
            'server.socket_host': '0.0.0.0',
            'server.socket_port': args.json
        })
        cherrypy.quickstart(tunnel)
    else:
        while True:
            time.sleep(1)