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

bind to specific interface for tcp listener #567

Open
GlenDC opened this issue Feb 19, 2025 · 5 comments
Open

bind to specific interface for tcp listener #567

GlenDC opened this issue Feb 19, 2025 · 5 comments
Milestone

Comments

@GlenDC
Copy link
Contributor

GlenDC commented Feb 19, 2025

Correct me if I'm wrong, but currently it does not seem to be possible to bind a tcp listener (server), e.g. as used by a sni or http proxy, to a specific (network) interface. With escapers this is possible via bind_interface. Given you already have all the socks support under the hoodit should be trivial to add, but I would like to know your input on this and whether or not I am missing something here.

Alternatives options:

  • do not do it
  • bind to a specific address (e.g. instead of binding to 0.0.0.0 or [::] one could bind to the address within the network interface
    • this is less ideal however as now you would need to know the IP that "you" have on that network interface.
@zh-jq-b
Copy link
Member

zh-jq-b commented Feb 19, 2025

I haven't tried this but it seems to be useful, so I'm OK to merge the PR.

One question here: will bind_interface conflict with bind address?

@GlenDC
Copy link
Contributor Author

GlenDC commented Feb 19, 2025

One question here: will bind_interface conflict with bind address?

Yes. But of course besides the interface there are other socket options that are not conflicting.
So it could be something like:

bind: str | map

as map would be something like:

bind:
   interface: str
   .. opther options

where bind: str and interface: str could be either an address or a a network interface, don't think there is ambiguity there

Dunno what you think about that or how you see it.

@zh-jq-b
Copy link
Member

zh-jq-b commented Feb 19, 2025

Looks good. Only one suggestion for the map format:

bind:
   interface: <ifname> # only parse as interface name
   address: <addr str> # this is already existed and parsed as socket address string
   .. opther options

@GlenDC
Copy link
Contributor Author

GlenDC commented Feb 19, 2025

What to do if both interface and address are defined? Error? Or one over another?

@zh-jq
Copy link
Collaborator

zh-jq commented Feb 19, 2025

I think they can be set separately. There may be some cases that one want to listen on an interface but also with one fixed port, such as listen on eth0 and port 80. I'm not sure whether this is possible, can you do some test?

@zh-jq-b zh-jq-b added this to the g3proxy v1.12 milestone Feb 21, 2025
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

3 participants