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

Using send() on UDP socket -- is it intended? #292

Open
SkyArbor opened this issue May 13, 2022 · 1 comment
Open

Using send() on UDP socket -- is it intended? #292

SkyArbor opened this issue May 13, 2022 · 1 comment

Comments

@SkyArbor
Copy link

Hi, I noticed speederv2_wepoll.exe using send() when sending packet to remote server, and using sendto() when sending packet to local OpenVPN server, and I'm wondering the reason behind it.
屏幕截图 2022-05-13 191406
(calling sendto()

屏幕截图 2022-05-13 191430

(calling `send()`)

Calling send() introduces a special behaviour on my Windows OS. After OpenVPN changes the route table, the socket itself ignores the change and uses original route. Say, I used client side config in this guide without additional changes to my route table, and my OpenVPN server pushed redirect-gateway def1 option to client. It still worked perfectly.

A simple script can be used to reproduce this behaviour:

import os
import socket
from time import sleep

if __name__ == "__main__":
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
    s.connect(('8.8.8.8', 10086))
    while True:
        s.send(b'abcd')
        sleep(1)

Run the script and then connect OpenVPN, OpenVPN won't be able to catch its traffic. Packets still fly to 8.8.8.8, and bypasses the OpenVPN server.

In a word, Using send() strangely avoids OpenVPN hijacking UDPspeeder 's traffic. Is it the reason of using send()? Whether or not, I suggest adding comment to source code. I can't find documentation about this behaviour. It may be changed in the future.

@wangyu-
Copy link
Owner

wangyu- commented Feb 7, 2023

In a word, Using send() strangely avoids OpenVPN hijacking UDPspeeder 's traffic. Is it the reason of using send()?

No that's not the reason.   I suggest always adding routing exceptions to avoid openvpn hijacking UDPspeeder's traffic, instead of relying on this behavior.

The reason I use send (or connected socket) for some codes is to make the programming a bit easier for me.

Some other codes are forced to use sendto, since that's needed for communicate with multiple remote points.

Theoretically I can always use sendto.

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

2 participants