Added support to for SO_BINDTODEVICE on listening socket#494
Open
Mario-Klebsch wants to merge 1 commit intotinyproxy:masterfrom
Open
Added support to for SO_BINDTODEVICE on listening socket#494Mario-Klebsch wants to merge 1 commit intotinyproxy:masterfrom
Mario-Klebsch wants to merge 1 commit intotinyproxy:masterfrom
Conversation
|
Yes that would be very useful, especially for VPNs! Like you could easily turn one off an on in selective applications or use several at once. |
BlankEclair
reviewed
Nov 26, 2024
| { | ||
| int listenfd; | ||
| int ret; | ||
| int ipv6=1; |
There was a problem hiding this comment.
Suggested change
| int ipv6=1; | |
| int ipv6 = 1; |
Contributor
There was a problem hiding this comment.
@BlankEclair: please refrain on suggesting whitespace changes on random PRs you absolutely are not involved with. if i want such changes, i will ask for them myself.
There was a problem hiding this comment.
Sorry--I overzealously commented on the inconsistency
It won't happen again
| log_message(LOG_ERR, "socket() failed: %s", strerror(errno)); | ||
| return -1; | ||
| } | ||
| ipv6=0; |
There was a problem hiding this comment.
Suggested change
| ipv6=0; | |
| ipv6 = 0; |
|
|
||
| strncpy(ifr.ifr_name, interface, sizeof(ifr.ifr_name)); | ||
| if (setsockopt(listenfd, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(ifr)) < 0) { | ||
| log_message(LOG_ERR, "setsockopt(SO_BINDTODEVICE,%s) failed: %s", interface, strerror (errno)); |
There was a problem hiding this comment.
I have not read the surrounding tinyproxy code, but I think it should be
Suggested change
| log_message(LOG_ERR, "setsockopt(SO_BINDTODEVICE,%s) failed: %s", interface, strerror (errno)); | |
| log_message(LOG_ERR, "setsockopt(SO_BINDTODEVICE,%s) failed: %s", interface, strerror(errno)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I added support to bind the listen statement to an interface, not an IP address. The backgroubnd is IPv6, where I have trouble binding to all IPv6 adresses of an inferface on boot, because the IPv6 adresses are not usabel, yet.
With this pull-request the listen-statement in the config file accepts an interface name and tinyproxy does setsockopt(SO_BINDTODEVICE) on the interface to bind the socket to an interface.