Open sss123next opened 7 years ago
Isn't having a single port better?
single is ok too.
# Port range to use for listening. (port_range)
network.port_range.set = 62820-62820
# Set whether the client should try to connect to UDP trackers (It can cause various problems if it's enabled, if you experience any with this option enabled then disable it.)
trackers.use_udp.set = 1
# Enable DHT support for trackerless torrents or when all trackers are down. May be set to "disable" (completely disable DHT), "off" (do not start DHT),
# "auto" (start and stop DHT as needed), or "on" (start DHT immediately). The default is "off". For DHT to work, a session directory must be defined.
dht.mode.set = auto
# UDP port to use for DHT
dht.port.set = 62882
this is listen port, i am talking about outgoing port.
Oh .... Sorry, my bad ...
There is currently no posix or l/unix compliant ways of selecting the source port range.
We can however select random source ports in a range and try binding them until something succeeds, and the new feature-bind code should make that easy to add. However it is not a priority so you'd have to do it yourself.
There is currently no posix or l/unix compliant ways of selecting the source port range.
Any TCP / UDP connection explicitly needs a source port number to bind to as well as a destination port. This does not depend on Unix nor POSIX, but a property of network / sockets programming and how connections work. In order to establish a connection, both a source and destination port is needed on both client and server.
memset(&server_addr, '\0', sizeof(server_addr));
server_addr.sin_family = AF_INET;
// you set it here
server_addr.sin_port = htons(port);
server_addr.sin_addr.s_addr = inet_addr(ip);
The tricky part is selecting a random port, but that's because passing 0
to server_adr.sin_port
, which is the short hand way of making the runtime select a random port, is not supported on all platforms.
Irrespective of that, you can ensure that port
is randomly chosen between two configurable values and then passed to server_adr.sin_port
.
it would be good to have possibility to set port range for outgoing connections it will simplify firewall/traffic shaping setup