aMule Forum
English => Feature requests => Topic started by: FreeToGo on September 20, 2008, 05:13:20 PM
-
It takes me ages to finally see that amule works with upnp. But unlike other applications, amule doesn't support
random port. It is needed because we never know which port is still available.
Is there any chances that this little feature(random TCP/UDP port) could be added?
-
Below is the patch needed to trigger amule to assign random port whenever upnp are enabled. I need this feature because my router always lock those ports that amule used previously. I don't know any clever way to release those port so that amule could reuse it.
jc@ubuntu:~/Desktop/temp/amule/amule-cvs$ diff -u src/amule.cpp.old src/amule.cpp
--- src/amule.cpp.old 2008-09-15 04:22:55.000000000 +0800
+++ src/amule.cpp 2008-09-22 19:43:45.000000000 +0800
@@ -871,7 +871,19 @@
{
bool ok = true;
static bool firstTime = true;
-
+#ifdef ENABLE_UPNP
+ if (thePrefs::GetUPnPEnabled()) {
+ uint16 randport = 0;
+ while ( randport < 1024 ) {
+ randport = (uint16)rand();
+ }
+ uint16 udpport = randport +5;
+ uint16 ecport = randport + 6;
+ thePrefs::SetUDPPort( udpport );
+ thePrefs::SetECPort( ecport );
+ thePrefs::SetPort( randport );
+ }
+#endif
if (!firstTime) {
// TODO: Destroy previously created sockets
}
jc@ubuntu:~/Desktop/temp/amule/amule-cvs$
-
Randomizing ports is bad, very bad. It means every time you restart your client people won't be able to contacts you anymore if they have you in their queues as a source, and also that you lost your places in other people's queues even if you restarted with enough time to be kept in them (less than a statistic median of 10 minutes). It also mean you will be published to the servers as a different user, and you can even be marked as a hash stealer by some zealous leecher protection features on some mods.
-
Randomizing ports is bad,
Thank u for your information. How about to implement a try and catch mechanism so that
if old port cannot be open, amule will try connect again using a random port.
-
Shouldn't we instead try to focus on the cause of the problem? Could you explain better how your router locks the ports?
-
Here is my scenario.
I am currently connecting my hp notebook to d-link router through wifi and upnp. Very often, due to the act of Gods, the wireless connection will be disconnected and then reconnected again automatically every two hours or so. Most of the applications will survive and be back to normal in no time except amule. Amule will either become disconnected or reconnected with a low-id. If I restart amule, it will remain connected with a low-id. I must manually change the TCP and UDP port numbers before amule could get a high id again.
-
OK, so we have two problems:
1. Your wireless connection drops and is not reconnected immediately.
2. aMule has a problem to open the ports using UPnP when there's already a lease on the ports.
Helping you to resolve your wireless problems is out of scope here (Have you asked at your distribution's forums?), but we can see what we can do about the second problem. I see the following options:
- Use a shorter lease time, maybe 60 minutes and try to obtain a lease / renew the lease every hour. Also reconnect if a lease could be successfully obtained and prior status was low-id.
- Try to force the lease. (Some routers with a bad UPnP implementation allow a lease override.)
- Try different ports when lease fails.
I'll speak to phoenix to see what he thinks about this, his knowledge about this topic is better than mine.
-
Hi folks,
Sorry for beeing away, I am having some personal problems, but I will try to address this issue.
FreeToGo,
I need you to enable UPnP debug logging in aMule preferences, then send me a log big enough as to contain the problem.
Do you have an idea of what happens to the state of your router when you connect/disconnect? Is it loosing the port forward setting? This information would help.
One other thing, when the connection comes back, do you get the same IP as before?
Cheers!
-
I think the problem is that the router is rebooting, then when it comes up, the port forwarding via UPnP has been lost, therefore it gets lowID.
Regards.
-
If that is the case, there's not much we can do. It is not reasonable to keep recreating the translations every time because one router is misbehaving.
What could be done, is to make aMule much more UPnP smart and make it check whether the port forward rules are still on the router every, say, 1 hour. But that might be tricky, and we might run into compatibility problems among routers.
Anyway, lets not get ahead of ourselves, lets see the logs first.
-
Even without UPnP aMule doesn't react sane if the Internet connection breaks down for a while. Just caught it yesterday sitting there dumb and disconnected even though the router was working fine again and automatic reconnect was enabled.
-
It has a retry limit. If you wamt it to retry more, add more retries.
-
Hi ,
Here is the log.
Hi folks,
Sorry for beeing away, I am having some personal problems, but I will try to address this issue.
FreeToGo,
I need you to enable UPnP debug logging in aMule preferences, then send me a log big enough as to contain the problem.
Do you have an idea of what happens to the state of your router when you connect/disconnect? Is it loosing the port forward setting? This information would help.
One other thing, when the connection comes back, do you get the same IP as before?
Cheers!
-
Is this a log from one single session? Just to make sure, it seems heavily edited.