Re-fix #5: Always provide IP-address to all users, not just for active clients.
Signed-off-by: Jan Vidar Krey <janvidar@extatic.org>
This commit is contained in:
parent
2edafeba4e
commit
3aecd67134
45
src/inf.c
45
src/inf.c
@ -188,50 +188,35 @@ static int check_required_login_flags(struct user* user, struct adc_message* cmd
|
|||||||
*/
|
*/
|
||||||
int check_network(struct user* user, struct adc_message* cmd)
|
int check_network(struct user* user, struct adc_message* cmd)
|
||||||
{
|
{
|
||||||
int want_ipv4 = 0;
|
const char* address = ip_convert_to_string(&user->ipaddr);
|
||||||
int want_ipv6 = 0;
|
|
||||||
int nat_override = 0;
|
|
||||||
const char* address = 0;
|
|
||||||
|
|
||||||
/* Add correct/verified IP addresses instead (if requested/stripped) */
|
/* Check for NAT override address */
|
||||||
address = (char*) net_get_peer_address(user->sd);
|
if (acl_is_ip_nat_override(user->hub->acl, address))
|
||||||
if (address)
|
|
||||||
{
|
|
||||||
if (strchr(address, '.'))
|
|
||||||
{
|
|
||||||
adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_IPV6_ADDR);
|
|
||||||
adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_IPV6_UDP_PORT);
|
|
||||||
want_ipv4 = 1;
|
|
||||||
}
|
|
||||||
else if (strchr(address, ':'))
|
|
||||||
{
|
|
||||||
adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_IPV4_ADDR);
|
|
||||||
adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_IPV4_UDP_PORT);
|
|
||||||
want_ipv6 = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* check if user can do nat override */
|
|
||||||
if (want_ipv4 && acl_is_ip_nat_override(user->hub->acl, address))
|
|
||||||
{
|
{
|
||||||
char* client_given_ip = adc_msg_get_named_argument(cmd, ADC_INF_FLAG_IPV4_ADDR);
|
char* client_given_ip = adc_msg_get_named_argument(cmd, ADC_INF_FLAG_IPV4_ADDR);
|
||||||
if (strcmp(client_given_ip, "0.0.0.0") != 0)
|
if (strcmp(client_given_ip, "0.0.0.0") != 0)
|
||||||
{
|
{
|
||||||
user_set_nat_override(user);
|
user_set_nat_override(user);
|
||||||
nat_override = 1;
|
adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_IPV6_ADDR);
|
||||||
|
adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_IPV6_UDP_PORT);
|
||||||
|
hub_free(client_given_ip);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
hub_free(client_given_ip);
|
hub_free(client_given_ip);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!nat_override)
|
if (strchr(address, '.'))
|
||||||
{
|
{
|
||||||
if (want_ipv4)
|
adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_IPV6_ADDR);
|
||||||
|
adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_IPV6_UDP_PORT);
|
||||||
adc_msg_add_named_argument(cmd, ADC_INF_FLAG_IPV4_ADDR, address);
|
adc_msg_add_named_argument(cmd, ADC_INF_FLAG_IPV4_ADDR, address);
|
||||||
|
}
|
||||||
if (want_ipv6)
|
else if (strchr(address, ':'))
|
||||||
|
{
|
||||||
|
adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_IPV4_ADDR);
|
||||||
|
adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_IPV4_UDP_PORT);
|
||||||
adc_msg_add_named_argument(cmd, ADC_INF_FLAG_IPV6_ADDR, address);
|
adc_msg_add_named_argument(cmd, ADC_INF_FLAG_IPV6_ADDR, address);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ int ip_convert_to_binary(const char* taddr, struct ip_addr_encap* raw)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char* ip_convert_to_string(struct ip_addr_encap* raw)
|
const char* ip_convert_to_string(struct ip_addr_encap* raw)
|
||||||
{
|
{
|
||||||
static char address[INET6_ADDRSTRLEN+1];
|
static char address[INET6_ADDRSTRLEN+1];
|
||||||
memset(address, 0, INET6_ADDRSTRLEN);
|
memset(address, 0, INET6_ADDRSTRLEN);
|
||||||
|
@ -36,7 +36,7 @@ struct ip_addr_encap {
|
|||||||
|
|
||||||
extern int ip_convert_to_binary(const char* text_addr, struct ip_addr_encap* raw);
|
extern int ip_convert_to_binary(const char* text_addr, struct ip_addr_encap* raw);
|
||||||
|
|
||||||
extern char* ip_convert_to_string(struct ip_addr_encap* raw);
|
extern const char* ip_convert_to_string(struct ip_addr_encap* raw);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user