Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How could I hide the remotePort in the TCP packet? #3

Open
gregoiregentil opened this issue Nov 10, 2022 · 1 comment
Open

How could I hide the remotePort in the TCP packet? #3

gregoiregentil opened this issue Nov 10, 2022 · 1 comment

Comments

@gregoiregentil
Copy link

Thank you for this code. It's short so it's readable.

First, in NatSession, I would recommend to rename remoteAddress to remoteIP for consistency.

Secondly, this line is not "very good":
https://github.com/DrBrad/JTun2Socks/blob/master/app/src/main/java/jtun2socks/shadowrouter/org/jtun2socks/VPN/Proxy.java#L90

I think that it would be better to use session.remoteAddress. I have a C-implementation of proxy.java and I initially did getsockname for java "socket.getInetAddress().getAddress()" but it was giving me 10.8.0.2. I had to use getpeername.

To continue my point, remoteAddress is not used in proxy.java because you are putting the IP address into the source IP header. So you are duplicating information and remoteAddress is not used. Not a bug but it was confusing a little bit.

Now, as I'm doing a C-implementation of proxy.java, it's very difficult to go back from JNI to JAVA to get the NatSessionManager.getSession((short) socket.getPort()) because the class is started by a service (I could explain this more but that's not the point of the issue). My point is that if remotePort was hidden somewhere else in the socket, it could be retrieved from C without JAVA and without even the NATSession.

So, how could I hide the remotePort to retrieve it without java? Couldn't it be put where the port key is put?

@gregoiregentil
Copy link
Author

A solution would consist of storing port key and remotePort in C from NatSessionManager.createSession. Because remotePort is the only information missing. I'm still confused: the port I'm getting from getpeername, is it the key port? Couldn't it be the remotePort and then get entirely rid of NATSession?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant