Skip to content

Commit

Permalink
Merge branch 'hotfix/#13-restart-network-services' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
ratanakvlun committed Jun 21, 2017
2 parents 69979c5 + 7878631 commit f82a354
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions ltconfig/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
"share_ratio_limit"
]

NETWORK_SERVICES = ["dht", "lsd", "natpmp", "upnp"]


class Core(CorePluginBase):

Expand Down Expand Up @@ -306,6 +308,9 @@ def _set_session_settings(self, session, settings):
self._convert_to_libtorrent_settings(settings, settings_obj, "dht.")
session.set_dht_settings(settings_obj)

self._stop_network_services()
self._start_network_services()


def _normalize_settings(self, settings):

Expand All @@ -332,6 +337,26 @@ def _apply_settings(self, settings):
self._set_session_settings(self._session, settings)


def _start_network_services(self):
config = component.get("PreferencesManager").config

for service in NETWORK_SERVICES:
if config[service]:
method = getattr(self._session, "start_%s" % service, None)
if method:
method()


def _stop_network_services(self):
config = component.get("PreferencesManager").config

for service in NETWORK_SERVICES:
if config[service]:
method = getattr(self._session, "stop_%s" % service, None)
if method:
method()


def _rpc_deregister(self, name):

server = component.get("RPCServer")
Expand Down

0 comments on commit f82a354

Please sign in to comment.