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

General support for problems installing or using Deluge
Post Reply
schmick
New User
New User
Posts: 9
Joined: Sun Oct 12, 2008 6:50 pm

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

Post 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
danii
Seeder
Seeder
Posts: 123
Joined: Tue Oct 23, 2007 10:29 pm
Location: Braga, Portugal

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

Post 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
mvoncken
Developer
Developer
Posts: 225
Joined: Mon Sep 03, 2007 9:38 pm

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

Post 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()
dev: webui, core, labels | irc:vonck7 |
Post Reply