10000 Added support to for SO_BINDTODEVICE on listening socket by Mario-Klebsch · Pull Request #494 · tinyproxy/tinyproxy · GitHub
[go: up one dir, main page]

Skip to content

Added support to for SO_BINDTODEVICE on listening socket #494

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
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Mario-Klebsch
Copy link
Contributor

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.

@deba12
Copy link
deba12 commented Jun 12, 2023

It's good to have such feature see #248
@rofl0r can you please take a look when is convenient for you?

@Gabriel85
Copy link

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.

{
int listenfd;
int ret;
int ipv6=1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int ipv6=1;
int ipv6 = 1;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8C7A

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));

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

Successfully merging this pull request may close these issues.

5 participants
0