Skip to content
/ fwknop Public
forked from mrash/fwknop

Commit

Permalink
Various changes on IPv6
Browse files Browse the repository at this point in the history
  • Loading branch information
Seb35 committed Jan 15, 2024
1 parent 2f98e06 commit abee34a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
20 changes: 10 additions & 10 deletions client/http_resolve_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ struct url
};

static int resolve_ip(const char * resp, fko_cli_options_t *options, const char * extraerror1,char *extraerror2) {
struct addrinfo *result=NULL;
struct addrinfo *rp;
struct addrinfo hints;
int error;

memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_flags = AI_NUMERICHOST | AI_CANONNAME;
error = getaddrinfo(resp, NULL, &hints, &result);
if (error != 0)
struct addrinfo *result=NULL;
struct addrinfo *rp;
struct addrinfo hints;
int error;

memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_flags = AI_NUMERICHOST | AI_CANONNAME;
error = getaddrinfo(resp, NULL, &hints, &result);
if (error != 0)
{
log_msg(LOG_VERBOSITY_ERROR,
"[-] Could not resolve IP via: '%s%s'", extraerror1, extraerror2);
Expand Down
3 changes: 3 additions & 0 deletions common/fko_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ is_valid_hostname(const char * const hostname_str, const int len)
if (*ndx == '-')
return 0;

if (*ndx == '.')
label_size--;

if (label_size > 63)
return 0;

Expand Down
2 changes: 1 addition & 1 deletion server/access.c
Original file line number Diff line number Diff line change
Expand Up @@ -2087,7 +2087,7 @@ compare_addr_list_ipv4(acc_int_list_t *ip_list, uint32_t ip)
{
if(ip_list->family == AF_UNSPEC)
return 1;
if(ip_list->family != AF_INET6)
if(ip_list->family != AF_INET)
continue;
if((ip & ip_list->acc_int.inet.mask) == (ip_list->acc_int.inet.maddr & ip_list->acc_int.inet.mask))
return 1;
Expand Down
13 changes: 8 additions & 5 deletions server/fw_util_iptables.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,13 +496,13 @@ jump_rule_exists_chk_support(const fko_srv_options_t * const opts, const int cha

static int
jump_rule_exists_no_chk_support(const fko_srv_options_t * const opts,
const int chain_num)
const int chain_num, int ipv6)
{
int exists = 0;
char chain_search[CMD_BUFSIZE] = {0};

snprintf(cmd_buf, CMD_BUFSIZE-1, "%s " IPT_LIST_RULES_ARGS,
fwc.fw_command,
ipv6 ? fwc.fw_command6 : fwc.fw_command,
fwc.chain[chain_num].table,
fwc.chain[chain_num].from_chain
);
Expand Down Expand Up @@ -532,7 +532,7 @@ jump_rule_exists(const fko_srv_options_t * const opts, const int chain_num, int
if(have_ipt_chk_support == 1)
exists = jump_rule_exists_chk_support(opts, chain_num, ipv6);
else
exists = jump_rule_exists_no_chk_support(opts, chain_num);
exists = jump_rule_exists_no_chk_support(opts, chain_num, ipv6);

return exists;
}
Expand Down Expand Up @@ -1583,8 +1583,11 @@ process_spa_request(const fko_srv_options_t * const opts,
time_t now;
unsigned int exp_ts;

/* XXX set adequately per SPA message */
int ipv6 = (opts->family == AF_INET6) ? 1 : 0;
int ipv6 = 0;
if(is_valid_ip_addr(spadat->use_src_ip, strlen(spadat->use_src_ip), AF_INET6))
{
ipv6 = 1;
}

/* Parse and expand our access message.
*/
Expand Down

0 comments on commit abee34a

Please sign in to comment.