示例#1
0
 def __init__(self, config, doneflag, errorfunc, listen_fail_ok=False):
     self.dht = None
     self.config = config
     self.errorfunc = errorfunc
     self.rawserver = RawServer(doneflag, config, errorfunc=errorfunc,
                                tos=config['peer_socket_tos'])
     set_zurllib_rawserver(self.rawserver)
     add_unsafe_thread()
     self.nattraverser = NatTraverser(self.rawserver, logfunc=errorfunc)
     self.singleport_listener = SingleportListener(self.rawserver,
                                                   self.nattraverser)
     self.ratelimiter = RateLimiter(self.rawserver.add_task)
     self.ratelimiter.set_parameters(config['max_upload_rate'],
                                     config['upload_unit_size'])
     self._find_port(listen_fail_ok)
     self.filepool = FilePool(config['max_files_open'])
     set_filesystem_encoding(config['filesystem_encoding'],
                                              errorfunc)
示例#2
0
    try:
        config, args = configfile.parse_configuration_and_args(defaults,
                                        'bittorrent', sys.argv[1:], 0, None)
        if debug:
            config['upnp'] = False
            config['one_connection_per_ip'] = False

    except BTFailure, e:
        print unicode(e.args[0])
        sys.exit(1)

    config = Preferences().initWithDict(config)
    # bug set in DownloadInfoFrame

    rawserver = RawServer(config)
    zurllib.set_zurllib_rawserver(rawserver)
    rawserver.install_sigint_handler()

    ipc = ipc_interface(rawserver, config, "controlsocket")

    # make sure we clean up the ipc when everything is done
    atexit_threads.register_verbose(ipc.stop)

    # this could be on the ipc object
    ipc_master = True
    try:
        if not config['use_factory_defaults']:
            ipc.create()
    except BTFailure, e:
        ipc_master = False
        try:
示例#3
0
    try:
        config, args = configfile.parse_configuration_and_args(
            defaults, 'bittorrent', sys.argv[1:], 0, None)
        if debug:
            config['upnp'] = False
            config['one_connection_per_ip'] = False

    except BTFailure, e:
        print unicode(e.args[0])
        sys.exit(1)

    config = Preferences().initWithDict(config)
    # bug set in DownloadInfoFrame

    rawserver = RawServer(config)
    zurllib.set_zurllib_rawserver(rawserver)
    rawserver.install_sigint_handler()

    ipc = ipc_interface(rawserver, config, "controlsocket")

    # make sure we clean up the ipc when everything is done
    atexit_threads.register_verbose(ipc.stop)

    # this could be on the ipc object
    ipc_master = True
    try:
        if not config['use_factory_defaults']:
            ipc.create()
    except BTFailure, e:
        ipc_master = False
        try: