mirror of
https://github.com/bol-van/zapret.git
synced 2024-12-02 14:40:52 +03:00
tpws: connect-bind-addr link local ifname delayed resolution
This commit is contained in:
parent
e86fc2e7b5
commit
700de59241
@ -74,6 +74,7 @@ struct params_s
|
|||||||
|
|
||||||
struct sockaddr_in connect_bind4;
|
struct sockaddr_in connect_bind4;
|
||||||
struct sockaddr_in6 connect_bind6;
|
struct sockaddr_in6 connect_bind6;
|
||||||
|
char connect_bind6_ifname[IF_NAMESIZE];
|
||||||
|
|
||||||
int debug;
|
int debug;
|
||||||
|
|
||||||
|
@ -797,7 +797,13 @@ void parse_params(int argc, char *argv[])
|
|||||||
else if (inet_pton(AF_INET6, optarg, ¶ms.connect_bind6.sin6_addr))
|
else if (inet_pton(AF_INET6, optarg, ¶ms.connect_bind6.sin6_addr))
|
||||||
{
|
{
|
||||||
params.connect_bind6.sin6_family = AF_INET6;
|
params.connect_bind6.sin6_family = AF_INET6;
|
||||||
if (p && *p) params.connect_bind6.sin6_scope_id=if_nametoindex(p);
|
if (p && *p)
|
||||||
|
{
|
||||||
|
// copy interface name for delayed resolution
|
||||||
|
strncpy(params.connect_bind6_ifname,p,sizeof(params.connect_bind6_ifname));
|
||||||
|
params.connect_bind6_ifname[sizeof(params.connect_bind6_ifname)-1]=0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -403,6 +403,17 @@ static int connect_remote(const struct sockaddr *remote_addr, bool bApplyConnect
|
|||||||
}
|
}
|
||||||
else if(remote_addr->sa_family == params.connect_bind6.sin6_family)
|
else if(remote_addr->sa_family == params.connect_bind6.sin6_family)
|
||||||
{
|
{
|
||||||
|
if (*params.connect_bind6_ifname && !params.connect_bind6.sin6_scope_id)
|
||||||
|
{
|
||||||
|
params.connect_bind6.sin6_scope_id=if_nametoindex(params.connect_bind6_ifname);
|
||||||
|
if (!params.connect_bind6.sin6_scope_id)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "interface name not found : %s\n", params.connect_bind6_ifname);
|
||||||
|
close(remote_fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (bind(remote_fd, (struct sockaddr *)¶ms.connect_bind6, sizeof(struct sockaddr_in6)) == -1)
|
if (bind(remote_fd, (struct sockaddr *)¶ms.connect_bind6, sizeof(struct sockaddr_in6)) == -1)
|
||||||
{
|
{
|
||||||
perror("bind on connect");
|
perror("bind on connect");
|
||||||
|
Loading…
Reference in New Issue
Block a user