phantun icon indicating copy to clipboard operation
phantun copied to clipboard

Phantun Client Will Never Reconnect if it didn't Know the Connection was Broken. (eg. Upstream Router Died Unexpectedly)

Open Shiroiame-Kusu opened this issue 1 year ago • 8 comments

Server

 INFO  server > Remote address is: 127.0.0.1:65535
 INFO  server > 2 cores available
 INFO  server > Created TUN device tun0
 INFO  server > Listening on 65534
 INFO  fake_tcp > Sent SYN + ACK to client
 INFO  fake_tcp > Connection from client:38841 established
 INFO  server   > New connection: (Fake TCP connection from 192.168.201.2:65534 to client:38841)
 INFO  fake_tcp > Connection (Fake TCP connection from 192.168.201.2:65534 to client:38841) reset by peer
 INFO  fake_tcp > Fake TCP connection to (Fake TCP connection from 192.168.201.2:65534 to client:38841) closed
 INFO  server   > No traffic seen in the last 180s, closing connection

But Client,

 INFO  client   > New UDP client from 127.0.0.1:37300
 INFO  fake_tcp > Sent SYN to server
 INFO  fake_tcp > Connection to remoteserver:65534 established

Adding a TCP KeepAlive Detection should be able to solve this problem, but as far as I see, the PR #93 , is still opening and waiting for merge.

Shiroiame-Kusu avatar Jun 21 '25 13:06 Shiroiame-Kusu

I'll try contact the author through mail. Phantun's dependencies have been outdated for several months, and latest rust toolchain fails build process. I wish the author still cares about this project :-(

handsomexdd1024 avatar Jul 23 '25 15:07 handsomexdd1024

Hey @handsomexdd1024,

I still definitely care about the project! Reason why it has not been releasing often is because Phantun has been running very stable for me for almost a year on my server, and that makes me not having to think about it often :( that's my bad

I will do a quick check and fix master.

In terms of TCP KeepAlive support, personally I did not ran into this kind of issue presumably because I'm using routers/firewalls that RSTs dead TCP connection. Since it appears that the demand for TCP Keepalive is not isolated, I will give another look at https://github.com/dndx/phantun/pull/93 and see if I can get it merged and release a new version that sends TCP Keepalive heartbeats.

dndx avatar Aug 22 '25 13:08 dndx

Master dependencies has been bumped to latest and build has been fixed in https://github.com/dndx/phantun/pull/222. However I will wait until some real feature is merged before tagging a new release.

dndx avatar Aug 22 '25 15:08 dndx

Master dependencies has been bumped to latest and build has been fixed in #222. However I will wait until some real feature is merged before tagging a new release.

Hmmm..... what about adding authentication while establishing a connection? This would make the server safer.

Shiroiame-Kusu avatar Aug 22 '25 15:08 Shiroiame-Kusu

Master dependencies has been bumped to latest and build has been fixed in #222. However I will wait until some real feature is merged before tagging a new release.

Hmmm..... what about adding authentication while establishing a connection? This would make the server safer.

Why not just use https://www.wireguard.com/ inside Phantun? It is much safer (and probably performant) than anything we can do in this project.

dndx avatar Aug 22 '25 16:08 dndx

Master dependencies has been bumped to latest and build has been fixed in #222. However I will wait until some real feature is merged before tagging a new release.

Hmmm..... what about adding authentication while establishing a connection? This would make the server safer.

Why not just use https://www.wireguard.com/ inside Phantun? It is much safer (and probably performant) than anything we can do in this project.

I'm already using WireGuard inside Phantun, I just don't want others to be able to connect to my Phantun Server, it looks "unsafe", or kind of annoying. However, If you believe this is only a minor issue, nvm. :)

Shiroiame-Kusu avatar Aug 28 '25 12:08 Shiroiame-Kusu

Master dependencies has been bumped to latest and build has been fixed in #222. However I will wait until some real feature is merged before tagging a new release.

Hmmm..... what about adding authentication while establishing a connection? This would make the server safer.

Why not just use https://www.wireguard.com/ inside Phantun? It is much safer (and probably performant) than anything we can do in this project.

I'm already using WireGuard inside Phantun, I just don't want others to be able to connect to my Phantun Server, it looks "unsafe", or kind of annoying. However, If you believe this is only a minor issue, nvm. :)

It's nowhere unsafe since WireGuard silently drops invalid packets. Just make sure you add robust encryption and keep private keys safe. WireGuard implementation itself is hard to crack.

handsomexdd1024 avatar Sep 03 '25 23:09 handsomexdd1024

Is there any progress? I really need this feature.

In a home environment, the IP address changes dynamically, but the connection isn't cut off after the main router changes, causing my WireGuard tunnel to fail. And this isn't an uncommon problem; it's a common one.

daminit avatar Dec 16 '25 11:12 daminit