-
Notifications
You must be signed in to change notification settings - Fork 9
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
The example tries to create an infinite numbers of TCP connections. #12
Comments
From your argument, you seem to be using a Linux environment, right? First, to make the example run successfully, you need to determine what the routing rules of your system are. There is a problem. If the system sets the utun interface as the default route, if forward does nothing, the data packet will be sent from the utun device, which will cause a routing loop. In order to solve this problem, it is necessary to let forward bind to the network card device that can actually send data before sending it out, which will not cause the data packet to enter the forward again to form a loop, or use data packet mark and other technologies. Here, it is just a simple binding interface to simplify the example. The final problem is whether the device bound to forward is the utun device created by forward itself. Since forward uses a guessing method for simplicity, you need to test whether the interface option is the same as utun to ensure that the guessed device is correct. The device needs to be a network interface card that can actually send data. If the guess is wrong, you need to provide the interface data sending device option yourself, or adjust the guessing logic. |
@cavivie Yes, I'm on Linux. I haven't created any routes nor changed my default route (I did try the option with routes to the same effect, but let's ignore it for now). From your comment it sounds like the --interface option is for the interface to use for actual network connections. But since 3a7e0b9 it's also used to determine the tun device name, which seems to be the reason for the infinite loop: |
OK, thanks for your careful observation! |
If you run the example and execute
curl 1.1.1.1 --interface utun8
as suggested in the comment in forward.rs, it goes into an infinite loop opening connections to 1.1.1.1:80.I might be missing something, but the problem seems to be that new_tcp_stream binds outgoing connections to the same tun interface used to receive packets from the OS, resulting in an infinite "recursion". Commenting out this line seems to work as a fix.
The text was updated successfully, but these errors were encountered: