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

[FEATURE] Bind to interface #1

Open
slldev opened this issue Jun 19, 2022 · 1 comment
Open

[FEATURE] Bind to interface #1

slldev opened this issue Jun 19, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@slldev
Copy link

slldev commented Jun 19, 2022

Hello, nice module. Something myself and presumably others would benefit from is being able to bind to specific interface, using

sock.setsockopt(
                socket.SOL_SOCKET,
                socket.SO_BINDTODEVICE,
               {interface}),
            )

I took a look at protocol.py and didn't immediately see a way to implement this. Any guidance?

@slldev slldev added the enhancement New feature or request label Jun 19, 2022
@Amaindex
Copy link
Owner

Hi @slldev, thank you for your issue.

I have thought about this point. Although I haven't solved it, some of my thoughts and discoveries may help you:

  • There is a saying (although I don't know if this is correct) that the SOCKS works at the transport layer, so it should deal with network layer concepts, such as IP addresses, rather than concepts at the lower level, such as interface, etc.
  • In many cases, if you want to force SOCKS to use a particular network interface, you can do this by binding the socket to the ip of the network interface. For asyncio-socks-server, you can specify the host and port parameters of loop.create_server at here and the local_addr parameters of loop.create_connection at here.
  • The asyncio module does not provide an API to set the socket-opt, but it is implemented based on Python's socket object. You can set the socket-opt for the object, but I am not sure if this will bring unpredictable side effects because I do not fully understand the implementation of asyncio🤣.

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

No branches or pull requests

2 participants