[Plugin] IfaceWatch - Watch for IP changes on interface

Suggest, post, or discuss plugins for Deluge
bro
Top Bloke
Top Bloke
Posts: 359
Joined: Sun Aug 28, 2011 6:46 pm
Location: Norway

[Plugin] IfaceWatch - Watch for IP changes on interface

Postby bro » Mon Sep 28, 2015 12:47 pm

IfaceWatch is a plugin to watch for IP changes on specific network interfaces and notify libtorrent to listen on the new IP.

Latest version: 1.1 (2015-09-28)

Current features:

  • Minitor a specific interface for IP changes. Does not handle interfaces with multiple IPs (not tested).
  • Log window containing info on what is going on.
  • Supports Unix based hosts (tested on Linux only).
  • It runs on the daemon, so it will work well in a daemon/thin client setup

Potential (future) features:
  • Command line client
  • Integrate with execute plugin to update routing table rules.

Notes:
  • No WebUI support!
  • Expect to find bugs!
  • Tested with Deluge 1.3.11, on Ubuntu 14.04.

Feel free to suggest features that you'd like to see implemented!

When updating to a new version of IfaceWatch, remember to restart deluge (and the daemon if run separately).

Download: https://github.com/bendikro/deluge-iface-watch/releases
Changelog: https://github.com/bendikro/deluge-ifac ... #changelog
Wiki page: http://dev.deluge-torrent.org/wiki/Plugins/IfaceWatch
When reporting issues, please include any relevant information such as OS (and version), python version (for Windows users this depends on which Deluge installer was used), Deluge version and plugin version.

Kit

Re: [Plugin] IfaceWatch - Watch for IP changes on interface

Postby Kit » Sun Nov 01, 2015 12:53 am

Hello,

I'm currently using the deluge-1.3.12-win32-py2.7-setup version under Windows 7 64 bits. When I try to check the plugin in the GUI, it is automatically unchecked when I Apply, Validate or Recheck plugin. I tried the 1.0 and 1.1 versions, both installed with the GUI or copied in the plugin folder. When I check the plugin, nothing appears but others plugins do (new tab).

bro
Top Bloke
Top Bloke
Posts: 359
Joined: Sun Aug 28, 2011 6:46 pm
Location: Norway

Re: [Plugin] IfaceWatch - Watch for IP changes on interface

Postby bro » Sun Nov 01, 2015 1:01 am

Kit wrote:Hello,

I'm currently using the deluge-1.3.12-win32-py2.7-setup version under Windows 7 64 bits. When I try to check the plugin in the GUI, it is automatically unchecked when I Apply, Validate or Recheck plugin. I tried the 1.0 and 1.1 versions, both installed with the GUI or copied in the plugin folder. When I check the plugin, nothing appears but others plugins do (new tab).


Windows is only supported in thin client mode, i.e. monitoring for IP changes is only supported on Unix based OSes.
When reporting issues, please include any relevant information such as OS (and version), python version (for Windows users this depends on which Deluge installer was used), Deluge version and plugin version.

Sphinxes
New User
New User
Posts: 5
Joined: Sat Nov 21, 2015 12:31 am
Location: Scandinavia

Re: [Plugin] IfaceWatch - Watch for IP changes on interface

Postby Sphinxes » Fri Oct 14, 2016 1:13 am

Hmm, strange this plugin don't have more comments as it's an extremely useful plugin! Loads of thanks for creating it, bro! :)
Though, I seem to have some issues getting it to work with Deluge 1.3.13 running as a systemd service on Ubuntu Server 16.04.

I have entered *tun0* as the Interface it should monitor and activated the plugin. If I manually change the IP in Deluge settings, the IfaceWatch Log says: IP was changed from outside IfaceWatch: 10.x.x.x -> 10.x.x.x.x. So it seem to notice manual changes to the Deluge interface config.

However, if my VPN connection restarts and I get a new IP-address on the tun0 interface, the plugin don't seem to do anything about it.. The only option to get it to work again is to manually edit the IP in the Deluge config.. which kind of destroy the whole point of the plugin.

Anyone else ran into the same issue and know any solution to it? Or will it require an update of the plugin itself to support the new version of Ubuntu or Deluge?

bro
Top Bloke
Top Bloke
Posts: 359
Joined: Sun Aug 28, 2011 6:46 pm
Location: Norway

Re: [Plugin] IfaceWatch - Watch for IP changes on interface

Postby bro » Fri Oct 14, 2016 9:35 am

IFaceWatch will check the IP regularly (the specified interval), so if the VPN interface changes IP, the IP in Deluge settings should be updated automatically on the next interval update. The log window should inform about what is happening. What interval have you specified and how long did you wait after the VPN interface changed IP?
When reporting issues, please include any relevant information such as OS (and version), python version (for Windows users this depends on which Deluge installer was used), Deluge version and plugin version.

Sphinxes
New User
New User
Posts: 5
Joined: Sat Nov 21, 2015 12:31 am
Location: Scandinavia

Re: [Plugin] IfaceWatch - Watch for IP changes on interface

Postby Sphinxes » Fri Oct 14, 2016 6:45 pm

bro wrote:IFaceWatch will check the IP regularly (the specified interval), so if the VPN interface changes IP, the IP in Deluge settings should be updated automatically on the next interval update. The log window should inform about what is happening. What interval have you specified and how long did you wait after the VPN interface changed IP?

I had the interval set at 10 (I assume it's seconds?). I've waited couple minutes without any new entry in the log window and no IP update in the Deluge settings.

I just tried to set the interval to 3 (in case it would be minutes), restarted Deluge Daemon (don't know if it's necessary, but I guess it can't hurt), and then restarted my VPN connection so the tun0 interface got a new IP. I waited 5+ minutes and still no change in Deluge and the IfaceWatch log window is totally empty.

Previous IP on tun0 before VPN restart: 10.129.0.8
New IP on tun0 after VPN restart: 10.128.0.53

IfaceWatch settings after Deluge Daemon restart and waited 5+ minutes: http://i.imgur.com/FkXHYbI.png
IfaceWatch settings after manually changing the IP: http://i.imgur.com/KScRCFN.png

However, I noticed the following errors in /var/log/syslog and /var/log/deluge/daemon.log. Could this be of any use to you? Might there be a issue related to permissions, that the deluge user (which the Daemon is ran as) do not have permissions to do something? These errors only show up when the IfaceWatch plugin is enabled, so it seem to be related to the plugin somehow.

Code: Select all

root@localhost:/var/log# cat syslog
Oct 14 20:28:50 localhost systemd[1]: Stopping Deluge Bittorrent Client Daemon...
Oct 14 20:28:51 localhost systemd[1]: Stopped Deluge Bittorrent Client Daemon.
Oct 14 20:28:51 localhost systemd[1]: Started Deluge Bittorrent Client Daemon.
Oct 14 20:28:51 localhost deluged[1554]: Unhandled error in Deferred:
Oct 14 20:28:51 localhost deluged[1554]: Traceback (most recent call last):
Oct 14 20:28:51 localhost deluged[1554]:   File "/usr/lib/python2.7/dist-packages/deluge/main.py", line 238, in start_daemon
Oct 14 20:28:51 localhost deluged[1554]:     Daemon(options, args)
Oct 14 20:28:51 localhost deluged[1554]:   File "/usr/lib/python2.7/dist-packages/deluge/core/daemon.py", line 167, in __init__
Oct 14 20:28:51 localhost deluged[1554]:     component.start("PreferencesManager")
Oct 14 20:28:51 localhost deluged[1554]:   File "/usr/lib/python2.7/dist-packages/deluge/component.py", line 296, in start
Oct 14 20:28:51 localhost deluged[1554]:     deferreds.append(self.components[name]._component_start())
Oct 14 20:28:51 localhost deluged[1554]:   File "/usr/lib/python2.7/dist-packages/deluge/component.py", line 124, in _component_start
Oct 14 20:28:51 localhost deluged[1554]:     d = maybeDeferred(self.start)
Oct 14 20:28:51 localhost deluged[1554]: --- <exception caught here> ---
Oct 14 20:28:51 localhost deluged[1554]:   File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 150, in maybeDeferred
Oct 14 20:28:51 localhost deluged[1554]:     result = f(*args, **kw)
Oct 14 20:28:51 localhost deluged[1554]:   File "/usr/lib/python2.7/dist-packages/deluge/core/preferencesmanager.py", line 160, in start
Oct 14 20:28:51 localhost deluged[1554]:     self._on_set_listen_ports)
Oct 14 20:28:51 localhost deluged[1554]:   File "/usr/lib/python2.7/dist-packages/deluge/config.py", line 312, in register_set_function
Oct 14 20:28:51 localhost deluged[1554]:     function(key, self.__config[key])
Oct 14 20:28:51 localhost deluged[1554]:   File "/usr/lib/python2.7/dist-packages/deluge/core/preferencesmanager.py", line 254, in _on_set_listen_ports
Oct 14 20:28:51 localhost deluged[1554]:     self.session.listen_on(value[0], value[1], str(self.config["listen_interface"]).strip())
Oct 14 20:28:51 localhost deluged[1554]: exceptions.RuntimeError: Cannot assign requested address



root@localhost:/var/log/deluge# cat daemon.log
[ERROR   ] 20:28:51 component:118 [Failure instance: Traceback: <type 'exceptions.RuntimeError'>: Cannot assign requested address
/usr/lib/python2.7/dist-packages/deluge/main.py:238:start_daemon
/usr/lib/python2.7/dist-packages/deluge/core/daemon.py:167:__init__
/usr/lib/python2.7/dist-packages/deluge/component.py:296:start
/usr/lib/python2.7/dist-packages/deluge/component.py:124:_component_start
--- <exception caught here> ---
/usr/lib/python2.7/dist-packages/twisted/internet/defer.py:150:maybeDeferred
/usr/lib/python2.7/dist-packages/deluge/core/preferencesmanager.py:160:start
/usr/lib/python2.7/dist-packages/deluge/config.py:312:register_set_function
/usr/lib/python2.7/dist-packages/deluge/core/preferencesmanager.py:254:_on_set_listen_ports
]
[ERROR   ] 20:28:51 component:118 [Failure instance: Traceback: <type 'exceptions.RuntimeError'>: Cannot assign requested address
/usr/lib/python2.7/dist-packages/deluge/main.py:238:start_daemon
/usr/lib/python2.7/dist-packages/deluge/core/daemon.py:175:__init__
/usr/lib/python2.7/dist-packages/deluge/component.py:296:start
/usr/lib/python2.7/dist-packages/deluge/component.py:124:_component_start
--- <exception caught here> ---
/usr/lib/python2.7/dist-packages/twisted/internet/defer.py:150:maybeDeferred
/usr/lib/python2.7/dist-packages/deluge/core/preferencesmanager.py:160:start
/usr/lib/python2.7/dist-packages/deluge/config.py:312:register_set_function
/usr/lib/python2.7/dist-packages/deluge/core/preferencesmanager.py:254:_on_set_listen_ports
]


Thanks!

Edit: Looking in /usr/lib/python2.7/dist-packages/deluge/ shows root being the owner, and file permissions are set to -rw-r--r-- on every file. Feels weird though that none of these files got the executable permission, shouldn't the python scripts be executable?

bro
Top Bloke
Top Bloke
Posts: 359
Joined: Sun Aug 28, 2011 6:46 pm
Location: Norway

Re: [Plugin] IfaceWatch - Watch for IP changes on interface

Postby bro » Fri Oct 14, 2016 7:18 pm

Ahh, I think I know the problem. The wiki page had a formatting error in *eth0*. You should only enter tun0 in the interface field.

Edit: Looking in /usr/lib/python2.7/dist-packages/deluge/ shows root being the owner, and file permissions are set to -rw-r--r-- on every file. Feels weird though that none of these files got the executable permission, shouldn't the python scripts be executable?

The python source code is read by the the python interpreter, so they don't have to be executable.

P.S.
I believe the interval is in minutes.
When reporting issues, please include any relevant information such as OS (and version), python version (for Windows users this depends on which Deluge installer was used), Deluge version and plugin version.

Sphinxes
New User
New User
Posts: 5
Joined: Sat Nov 21, 2015 12:31 am
Location: Scandinavia

Re: [Plugin] IfaceWatch - Watch for IP changes on interface

Postby Sphinxes » Fri Oct 14, 2016 7:48 pm

Ah okay :)
I entered only tun0 now (without the *) but it seems like it's still not working, unfortunately. I also get the exact same errors as before in the log files. I tried changing the IfaceWatch settings to eth0 (which is the name for my ethernet interface) just to see if it would make any difference, but that didn't work either.

I enabled debug logging, perhaps it will show something useful. The following are all related output from the log file:
10.128.0.39 is the old IP on tun0 interface. The current IP on the interface is 10.128.0.70.

Code: Select all

[DEBUG   ] 21:54:25 preferencesmanager:253 listen port range set to 44444-44444
[ERROR   ] 21:54:25 component:118 [Failure instance: Traceback: <type 'exceptions.RuntimeError'>: Cannot assign requested address
/usr/lib/python2.7/dist-packages/deluge/main.py:238:start_daemon
/usr/lib/python2.7/dist-packages/deluge/core/daemon.py:167:__init__
/usr/lib/python2.7/dist-packages/deluge/component.py:296:start
/usr/lib/python2.7/dist-packages/deluge/component.py:124:_component_start
--- <exception caught here> ---
/usr/lib/python2.7/dist-packages/twisted/internet/defer.py:150:maybeDeferred
/usr/lib/python2.7/dist-packages/deluge/core/preferencesmanager.py:160:start
/usr/lib/python2.7/dist-packages/deluge/config.py:312:register_set_function
/usr/lib/python2.7/dist-packages/deluge/core/preferencesmanager.py:254:_on_set_listen_ports
]
[DEBUG   ] 21:54:25 alertmanager:124 listen_failed_alert: listening on 10.128.0.39:0 failed: [bind] [TCP] Cannot assign requested address
[DEBUG   ] 21:54:25 alertmanager:124 listen_failed_alert: listening on 10.128.0.39:0 failed: [bind] [TCP/SSL] Cannot assign requested address
[DEBUG   ] 21:54:25 alertmanager:124 listen_failed_alert: listening on 10.128.0.39:44444 failed: [bind] [TCP] Cannot assign requested address
[DEBUG   ] 21:54:25 config:304 Registering function for torrentfiles_location key..
[DEBUG   ] 21:54:25 config:304 Registering function for listen_ports key..
[DEBUG   ] 21:54:25 preferencesmanager:253 listen port range set to 44444-44444
[ERROR   ] 21:54:25 component:118 [Failure instance: Traceback: <type 'exceptions.RuntimeError'>: Cannot assign requested address
/usr/lib/python2.7/dist-packages/deluge/main.py:238:start_daemon
/usr/lib/python2.7/dist-packages/deluge/core/daemon.py:175:__init__
/usr/lib/python2.7/dist-packages/deluge/component.py:296:start
/usr/lib/python2.7/dist-packages/deluge/component.py:124:_component_start
--- <exception caught here> ---
/usr/lib/python2.7/dist-packages/twisted/internet/defer.py:150:maybeDeferred
/usr/lib/python2.7/dist-packages/deluge/core/preferencesmanager.py:160:start
/usr/lib/python2.7/dist-packages/deluge/config.py:312:register_set_function
/usr/lib/python2.7/dist-packages/deluge/core/preferencesmanager.py:254:_on_set_listen_ports

<snip>

[DEBUG   ] 21:54:25 rpcserver:396 Registering method: ifacewatch.get_config
[DEBUG   ] 21:54:25 rpcserver:396 Registering method: ifacewatch.get_ip
[DEBUG   ] 21:54:25 rpcserver:396 Registering method: ifacewatch.save_config
[DEBUG   ] 21:54:25 pluginbase:57 CorePlugin initialized..
[DEBUG   ] 21:54:25 config:304 Registering function for listen_interface key..
[INFO    ] 21:54:25 logger:38 IfaceWatch.core:48: IP was changed from outside IfaceWatch: None -> 10.128.0.39
[DEBUG   ] 21:54:25 configmanager:111 Getting config 'ifacewatch.conf'
[DEBUG   ] 21:54:25 config:197 Setting 'interface' to  of <type 'str'>
[DEBUG   ] 21:54:25 config:197 Setting 'active' to True of <type 'bool'>
[DEBUG   ] 21:54:25 config:197 Setting 'update_interval' to 10 of <type 'int'>
[DEBUG   ] 21:54:25 config:391 Config /var/lib/deluge/.config/deluge/ifacewatch.conf version: 1.1 loaded: {'active': True, 'interface': u'tun0', 'update_interval': 1}
[INFO    ] 21:54:25 logger:38 IfaceWatch.core:62: Enabled Iface Watch 1.2
[INFO    ] 21:54:25 logger:38 IfaceWatch.core:80: Scheduling watch with interval 1.
[INFO    ] 21:54:25 pluginmanagerbase:158 Plugin IfaceWatch enabled..

<snip>

[DEBUG   ] 21:54:26 alertmanager:124 listen_failed_alert: listening on 10.128.0.39:0 failed: [bind] [TCP] Cannot assign requested address
[DEBUG   ] 21:54:26 alertmanager:124 listen_failed_alert: listening on 10.128.0.39:0 failed: [bind] [TCP/SSL] Cannot assign requested address
[DEBUG   ] 21:54:26 alertmanager:124 listen_failed_alert: listening on 10.128.0.39:44444 failed: [bind] [TCP] Cannot assign requested address

bro
Top Bloke
Top Bloke
Posts: 359
Joined: Sun Aug 28, 2011 6:46 pm
Location: Norway

Re: [Plugin] IfaceWatch - Watch for IP changes on interface

Postby bro » Fri Oct 14, 2016 8:40 pm

Hmm...trying it out now it can't get it to work. I wonder what I've been doing...
When reporting issues, please include any relevant information such as OS (and version), python version (for Windows users this depends on which Deluge installer was used), Deluge version and plugin version.

bro
Top Bloke
Top Bloke
Posts: 359
Joined: Sun Aug 28, 2011 6:46 pm
Location: Norway

Re: [Plugin] IfaceWatch - Watch for IP changes on interface

Postby bro » Sat Oct 15, 2016 8:06 am

I presume you are running LInux kernel >= 3.3? If so, this is the reason it doesn't work: https://github.com/ftao/python-ifcfg/bl ... t__.py#L37
When reporting issues, please include any relevant information such as OS (and version), python version (for Windows users this depends on which Deluge installer was used), Deluge version and plugin version.


Return to “Plugins”

Who is online

Users browsing this forum: No registered users and 2 guests