Page 1 of 1

how to grep (or something else) for current random port.

Posted: Fri Nov 21, 2008 6:48 pm
by schmick
I'm using deluge 1.0.5 and would like to know how (if there is any way) to know which random port numper is deluge using.
I want to do a script/crontab for filtering RST packets that my isp is known to use, to drop it's clients bittorrent connections.
As the port is random, I got stuck on the <iptables..... --dport ?????>.
I've got a _not_very_nice_ solution grepping netstat, but I'm quite sure deluge must write down it's port somewhere, am I right?
Regards

Re: how to grep (or something else) for current random port.

Posted: Fri Nov 21, 2008 7:51 pm
by danii
Well you can monitor the deluged.log file when the port is changed or you enable random port assignment you get something like:

Code: Select all

[DEBUG   ] 19:46:32 core:749 random port value set to True
[DEBUG   ] 19:46:32 core:763 listen port range set to 50228-50238
[DEBUG   ] 19:46:32 core:716 config_value_changed signal emitted
[DEBUG   ] 19:46:32 alertmanager:101 listen_succeeded_alert: successfully listening on 0.0.0.0:50228
[DEBUG   ] 19:46:32 alertmanager:101 listen_succeeded_alert: successfully listening on [::]:50228
I think it's enough for your scripting needs

Re: how to grep (or something else) for current random port.

Posted: Fri Nov 21, 2008 7:58 pm
by mvoncken

Code: Select all

#!/usr/bin/env python
import logging
logging.disable(logging.INFO)
from deluge.ui.client import sclient
sclient.set_core_uri()
print sclient.get_listen_port()