Ticket #2137: announce_ip.patch

File announce_ip.patch, 7.9 KB (added by gkuenning, 12 years ago)

Patch to add announce_ip support

  • docs/man/deluged.1

    old new  
    4848.TP 
    4949.I -q --quiet 
    5050Sets the log level to 'none', this is the same as `\-L none` 
     51.TP 
     52.I -T NAME=VALUE, --libtorrent=NAME=VALUE, --lib-torrent=NAME=VALUE 
     53Sets the libtorrent option NAME to the given value. 
     54For example, `\-T announce_ip=10.0.0.1' causes deluged to announce itself with the given IP address. 
     55For a complete list of options, see the libtorrent documentation. 
    5156 
    5257.SH SEE ALSO 
    5358.B Homepage: 
  • libtorrent/docs/manual.html

    old new  
    30583058        int inactivity_timeout; 
    30593059        int unchoke_interval; 
    30603060        int optimistic_unchoke_multiplier; 
    3061         address announce_ip; 
     3061        string announce_ip; 
    30623062        int num_want; 
    30633063        int initial_picker_threshold; 
    30643064        int allowed_fast_set_size; 
  • libtorrent/docs/manual.rst

    old new  
    30243024                int inactivity_timeout; 
    30253025                int unchoke_interval; 
    30263026                int optimistic_unchoke_multiplier; 
    3027                 address announce_ip; 
     3027                string announce_ip; 
    30283028                int num_want; 
    30293029                int initial_picker_threshold; 
    30303030                int allowed_fast_set_size; 
  • libtorrent/src/http_tracker_connection.cpp

    old new  
    160160                        url += "&numwant="; 
    161161                        url += to_string((std::min)(tracker_req().num_want, 999)).elems; 
    162162 
    163                         if (m_settings.announce_ip != address()) 
    164                         { 
    165                                 error_code ec; 
    166                                 std::string ip = m_settings.announce_ip.to_string(ec); 
    167                                 if (!ec) url += "&ip=" + ip; 
    168                         } 
     163                        if (m_settings.announce_ip != "") 
     164                                url += "&ip=" + m_settings.announce_ip; 
    169165 
    170166#ifndef TORRENT_DISABLE_ENCRYPTION 
    171167                        url += "&supportcrypto=1"; 
  • libtorrent/src/udp_tracker_connection.cpp

    old new  
    506506                detail::write_int64(req.uploaded, out); // uploaded 
    507507                detail::write_int32(req.event, out); // event 
    508508                // ip address 
    509                 if (m_settings.announce_ip != address() && m_settings.announce_ip.is_v4()) 
    510                         detail::write_uint32(m_settings.announce_ip.to_v4().to_ulong(), out); 
     509                if (m_settings.announce_ip != "") 
     510                { 
     511                        address announce_ip = address::from_string(m_settings.announce_ip); 
     512                        if (announce_ip.is_v4()) 
     513                                detail::write_uint32(announce_ip.to_v4().to_ulong(), out); 
     514                        else 
     515                                detail::write_int32(0, out); 
     516                } 
    511517                else 
    512518                        detail::write_int32(0, out); 
    513519                detail::write_int32(req.key, out); // key 
  • libtorrent/bindings/python/src/session_settings.cpp

    old new  
    3838        .def_readwrite("inactivity_timeout", &session_settings::inactivity_timeout) 
    3939        .def_readwrite("unchoke_interval", &session_settings::unchoke_interval) 
    4040        .def_readwrite("optimistic_unchoke_multiplier", &session_settings::optimistic_unchoke_multiplier) 
     41        .def_readwrite("announce_ip", &session_settings::announce_ip) 
    4142        .def_readwrite("num_want", &session_settings::num_want) 
    4243        .def_readwrite("initial_picker_threshold", &session_settings::initial_picker_threshold) 
    4344        .def_readwrite("allowed_fast_set_size", &session_settings::allowed_fast_set_size) 
  • libtorrent/include/libtorrent/session_settings.hpp

    old new  
    109109                        , inactivity_timeout(600) 
    110110                        , unchoke_interval(15) 
    111111                        , optimistic_unchoke_multiplier(4) 
     112                        , announce_ip() 
    112113                        , num_want(200) 
    113114                        , initial_picker_threshold(4) 
    114115                        , allowed_fast_set_size(10) 
     
    287288 
    288289                // if this is set, this IP will be reported do the 
    289290                // tracker in the ip= parameter. 
    290                 address announce_ip; 
     291                std::string announce_ip; 
    291292 
    292293                // the num want sent to trackers 
    293294                int num_want; 
  • deluge/core/daemon.py

    old new  
    4747import deluge.error 
    4848 
    4949class Daemon(object): 
    50     def __init__(self, options=None, args=None, classic=False): 
     50    def __init__(self, parser, options=None, args=None, classic=False): 
    5151        # Check for another running instance of the daemon 
    5252        if os.path.isfile(deluge.configmanager.get_config_dir("deluged.pid")): 
    5353            # Get the PID and the port of the supposedly running daemon 
     
    138138        else: 
    139139            listen_interface = "" 
    140140 
     141        # Handle any libtorrent settings 
     142        settings_dict = {} 
     143        if options and options.libtorrent_settings: 
     144            for setting in options.libtorrent_settings: 
     145                opt = setting.split('=', 1) 
     146                if len(opt) != 2: 
     147                    parser.error('--libtorrent requires name=value') 
     148                settings_dict[opt[0]] = opt[1] 
     149 
    141150        from deluge.core.core import Core 
    142151        # Start the core as a thread and join it until it's done 
    143         self.core = Core(listen_interface=listen_interface) 
     152        self.core = Core(listen_interface=listen_interface, 
     153          settings=settings_dict) 
    144154 
    145155        port = self.core.config["daemon_port"] 
    146156        if options and options.port: 
  • deluge/core/core.py

    old new  
    7272from deluge.core.rpcserver import export 
    7373 
    7474class Core(component.Component): 
    75     def __init__(self, listen_interface=None): 
     75    def __init__(self, listen_interface=None, settings={}): 
    7676        log.debug("Core init..") 
    7777        component.Component.__init__(self, "Core") 
    7878 
     
    9393        self.settings = lt.session_settings() 
    9494        self.settings.user_agent = "Deluge %s" % deluge.common.get_version() 
    9595 
    96         # Set session settings 
     96        # Set other default settings 
    9797        self.settings.send_redundant_have = True 
     98 
     99        # Set passed settings 
     100        for key in settings.keys(): 
     101            if hasattr(self.settings, key): 
     102                setattr(self.settings, key, settings[key]) 
     103            else: 
     104                log.error("Illegal settings key %s" % key) 
     105                raise KeyError 
     106 
     107        # Set session settings 
    98108        if deluge.common.windows_check(): 
    99109            self.settings.disk_io_write_mode = \ 
    100110                lt.io_buffer_mode_t.disable_os_cache 
  • deluge/main.py

    old new  
    164164        help="Set the log level: none, info, warning, error, critical, debug", action="store", type="str") 
    165165    parser.add_option("-q", "--quiet", dest="quiet", 
    166166        help="Sets the log level to 'none', this is the same as `-L none`", action="store_true", default=False) 
     167    parser.add_option("-T", "--libtorrent", "--lib-torrent", 
     168        dest="libtorrent_settings", action="append", metavar="NAME=VALUE", 
     169        help="Sets the libtorrent option NAME to VALUE") 
    167170    parser.add_option("--profile", dest="profile", action="store_true", default=False, 
    168171        help="Profiles the daemon") 
    169172 
     
    223226        hsp.start() 
    224227    try: 
    225228        from deluge.core.daemon import Daemon 
    226         Daemon(options, args) 
     229        Daemon(parser, options, args) 
    227230    except deluge.error.DaemonRunningError, e: 
    228231        log.error(e) 
    229232        log.error("You cannot run multiple daemons with the same config directory set.")