8000 lws_create_context: iface option issue · Issue #3365 · warmcat/libwebsockets · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

lws_create_context: iface option issue #3365

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

Open
anonhostpi opened this issue Apr 8, 2025 · 4 comments
Open

lws_create_context: iface option issue #3365

anonhostpi opened this issue Apr 8, 2025 · 4 comments

Comments

@anonhostpi
Copy link

When attempting to implement ttyd on OpenWRT on my router, I noticed there were issues with getting ttyd running correctly, and it appears that they may be rooted in a limitation/problem with this library.

I'd like to reiterate that:

A commonly forgotten feature of Linux networking is that Linux allows you to listen to multiple IP addresses on the same interface without bridges or virtual adapters.

From the core issue:

The problem this seems to cause, is that ttyd is only binding to one IP addresses when specifying a device even if that device has more than one IP address.

Which seems to be caused by libwebsockets here:

Workaround:

A possible workaround for now, is to have ttyd check the interface first for all assigned IPs when creating the websockets

@lws-team
Copy link
Member
lws-team commented Apr 9, 2025

Theories about how things "should" be treated - especially for free - often lead to disappointment.

The code you looked at just shows that we pass -i arg into lws context creation, there's nothing wrong or interesting about that, even if it supported what you want, it would look the same.

The situation is a bit more sophisticated than you are imagining, on unix we use getifaddrs() and do walk the results, scoring the "best" IP, eg, we look for a global scope ipv6 to bind to, over link-local.

lws_interface_to_sa(int ipv6, const char *ifname, struct sockaddr_in *addr,

In lws, a vhost may have exactly two sockets associated (for ipv4 and ipv6) and they are bound individually to "the best" ipv4 and ipv6 addresses it finds at the network interface, if you ask for it to be bound there. So as far as it goes, "multiple" addresses on a network interface binding are supported in the case n = 2 and it's the usual case of ipv4 + ipv6. Unix socket and specific IP address binding (not the netdev name) are also supported.

The actual business is happening here

lws_socket_bind(struct lws_vhost *vhost, struct lws *wsi,

AFAIK bind() is not cumulative, it's a one-shot thing on the socket filtering the socket's view to a single address. So supporting your use-case means we would need do the work to select n "best" ipv4 and ipv6 from getifaddrs() and allow as many listen sockets as needed on the vhost.

@anonhostpi
Copy link
Author
anonhostpi commented Apr 9, 2025

I don't see how you could be describing this as a theory. If I tell a program to bind to an interface as opposed to a singular IP, I expect it to bind to the entire interface, not partially bind to it. As in, if I don't instruct it to bind to a singular, why is it trying to circumvent what I told it to?

Additionally, I don't see how any program could reasonably deduce what IP is best on an interface, so why is it even trying?

Even in high-level langs and architecture, dns checks are often considered the only universally reliable way of determining reliable source IPs, and even then we all know there's several problems with that and is just an approximation at best.

@lws-team
Copy link
Member
lws-team commented Apr 9, 2025

Your suggestion this "should" be treated like a bug is your theory. Others are going to treat it according to their own ideas about what they want to do with their time, for free.

Additionally, I don't see how any program could reasonably deduce what IP is best on an interface

For example, I don't see any value arguing about that with you.

I gave you a detailed answer about the actual situation in lws that leads to the outcome you don't like, you're welcome to look into it and propose a way forward (preferably with patches).

@anonhostpi
Copy link
Author
anonhostpi commented Apr 9, 2025

I don't understand your point. Whether it's officially or personally labelled as a bug doesn't guarantee change either. There's nothing stopping anyone from stalling or idling the issue regardless of whether it has been officiated. That's a well-known and well-documented problem in development.

I will say I do appreciate your work and help, if that's what you're bothered about.

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
0