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

When using a device instead of IP, -i flag should bind to every IP on that interface, not just the last one #1411

Open
anonhostpi opened this issue Dec 12, 2024 · 1 comment

Comments

@anonhostpi
Copy link

anonhostpi commented Dec 12, 2024

Is your feature request related to a problem? Please describe.
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.

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.

This is particularly problematic when that device's IPs are in different subnets, as the terminal can then only be accessed from one of them.

Describe the solution you'd like
Change the bind behavior of -i to work with multiple IPs assigned to the same interface.

Describe alternatives you've considered
Creating an instance for each IP

Example:

The following system is OpenWRT

# ip a
...
5: br-lan: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
    link/ether 08:00:27:3f:9b:17 brd ff:ff:ff:ff:ff:ff
    inet 192.168.56.1/24 brd 192.168.56.255 scope global br-lan
       valid_lft forever preferred_lft forever
    inet 172.16.1.1/24 brd 172.16.1.255 scope global br-lan
       valid_lft forever preferred_lft forever

# ttyd -i br-lan login

Then with logread (Notice it only binds to 172.16.1.1 and it never binds to 192.168.56.1)

# logread -e ttyd
...
Thu Dec 12 08:26:00 2024 daemon.notice ttyd[11463]: [2024/12/12 08:26:00:4375] N: [vh|1|default|br-lan|br-lan|7681]: lws_socket_bind: source ads 172.16.1.1
Thu Dec 12 08:26:00 2024 daemon.notice ttyd[11463]: [2024/12/12 08:26:00:4376] N: __lws_lc_tag:  ++ [wsi|1|listen|default|br-lan|7681] (2)
Thu Dec 12 08:26:00 2024 daemon.notice ttyd[11463]: [2024/12/12 08:26:00:4376] N:  Listening on port: 7681
Thu Dec 12 08:26:03 2024 daemon.notice ttyd[11463]: [2024/12/12 08:26:03:4677] N: received signal: SIGINT (2), exiting...
Thu Dec 12 08:26:03 2024 daemon.notice ttyd[11463]: [2024/12/12 08:26:03:4678] N: send ^C to force exit.
@anonhostpi anonhostpi changed the title When using a device, instead of IP, -i flag should bind to every IP on that interface, not just the last one When using a device instead of IP, -i flag should bind to every IP on that interface, not just the last one Dec 12, 2024
@anonhostpi
Copy link
Author

image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant