-
Notifications
You must be signed in to change notification settings - Fork 234
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
Add IPv6 support to fwknop #285
Open
khorben
wants to merge
78
commits into
mrash:master
Choose a base branch
from
DeforaNetworks:khorben/ipv6
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
78 commits
Select commit
Hold shift + click to select a range
07693a9
Let IPs resolve to IPv6 addresses
khorben b8252db
Let IPs resolve to IPv6 addresses over SSL
khorben 460bd8c
Be more consistent when creating ~/.fwknoprc
khorben a0dda67
Also catch the IPv6 version of INADDR_ANY
khorben b3494dc
Migrate is_valid_ipv4_addr() to a more generic function
khorben aea56f5
Implement is_valid_ip_addr() with getaddrinfo()
khorben f7b18d6
Give have_allow_ip() a chance to allow IPv6
khorben 2f6ea52
Allow connecting to remote IPv6 hosts for TCP or UDP
khorben 72a50b9
Use uppercase to log "IP"
khorben 2367bc2
Also check for <netinet/ip6.h> and <netinet/icmp6.h>
khorben ce9b5fb
Rework the network listening routine
khorben 3dc6116
Rework the network listening routine some more
khorben 1a813bb
Code cleanup
khorben a525734
Also include <netinet/ip6.h> where relevant
khorben 37a8000
Protect some more headers for inclusion
khorben 6bcaf4f
Add support for receiving SPA messages over IPv6
khorben 8ecd10b
Interpret incoming addresses according to their family
khorben 89c7d6f
Let access list stanzas be defined in IPv6
khorben bd1c488
Typo
khorben a2462c6
Typo
khorben 82a5eec
Constify
khorben 17549b9
Use a more appropriate type for sd_len
khorben d1c1373
Allow access control "ANY" with any protocol family
khorben baed23c
Use AF_INET instead of PF_INET
khorben f61a308
Use sizeof() instead of re-using hard-coded values
khorben b070e80
Use sizeof() instead of re-using hard-coded values
khorben da1ab05
Use a constant for AF_INET
khorben 76d609b
Use /usr/bin/env to locate perl
khorben 587a4fb
Rework IPv6 support when comparing addresses
khorben 11e9b29
Fix processing command-line arguments with whitespace
khorben d6ce22b
Set the address family for incoming SPA over UDP
khorben 32cdd11
Specify the family at run-time for TCP/UDP servers
khorben f35c1d7
Add IPv6 support to the plain UDP and TCP servers
khorben 7437039
Constify
khorben a2902cb
Terminate IPs resolved externally as expected
khorben c753215
Prepare access stanzas for more address families
khorben d260f50
Use the correct offset for inet_ntop()
khorben c8670aa
Simplify the calculation of pkt_data_len
khorben 3e329a5
Correct the packet length calculation with IPv6
khorben 9878756
Fix some issues with TCP over IPv6
khorben 1fd5fe1
Begin to allow IPv6 addresses in source stanzas
khorben 6405398
Add a command-line option to enable IPv6 (TCP/UDP)
khorben 08e805d
Optimize moot variable initialization away
khorben 15dfc94
Fix the build on Linux (iptables)
khorben bbb341c
Fix the build with firewalld
khorben 3a8e01a
Update the manual page for the -6 option (--ipv6)
khorben 13dee2c
Support further address families in the future
khorben 9923fc0
Verify if the protocol family matches incoming packets
khorben c5994a3
Do not use INADDR_ANY for default ports
khorben e3aeb46
Check for errors from inet_addr() with INADDR_NONE
khorben e29d62e
Fix build with NFQ enabled
khorben 956e1df
Allow the longest possible IPv6 address in sources
khorben edeea23
Add a configuration variable for IPv6 firewall binaries
khorben a7a9ecb
Add the fw_command6 member to the right struct fw_config
khorben 7f9d09e
Initialize the configuration for ip6tables as well
khorben 576eb11
Add IPv6 support to --fw-list{,all}
khorben 81e2255
Update a comment
khorben fa664db
Add preliminary support for IPv6 with iptables
khorben dd0597f
Code cleanup
khorben ba4d095
Fix a couple more uses of ctype(3)
khorben 282aa2d
Provide enough space to resolve IPv6 addresses
khorben 68cacee
Remove support for IPv6 for rules shared with IPv4
khorben d28d1cb
Add support for rule expiration with IPv6
khorben f97214b
Revert "Remove support for IPv6 for rules shared with IPv4"
khorben 0bbbd13
Code cleanup
khorben 2bdaeff
Default to IPv6 rules when listening on IPv6
khorben fd6def0
Remove useless code
khorben 561ba96
Resolve hostnames to IPv6 addresses in IPv6 mode
khorben 159c62c
Re-indent
khorben 70df56f
Only support IPv4 on Windows
khorben c1d3656
Code cleanup
khorben 73d7b79
Use "::" for matching any address for IPv6 rules
khorben 460774c
No longer accept colon (":") as port separator
khorben f3895bb
Fix DNAT with IPv6
khorben 46d4d77
Use "::/0" for IPT_ANY_IPV6
khorben 3f3b304
Port src_dst_check() to IPv6
khorben a2edaec
Also output the value obtained for ip6tables
khorben 91f3842
Complete the check and search for ip6tables
khorben File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,6 +212,7 @@ try_url(struct url *url, fko_cli_options_t *options) | |
return(-1); | ||
} | ||
for (rp = result; rp != NULL; rp = rp->ai_next) { | ||
/* the canonical value is in the first structure returned */ | ||
strlcpy(options->allow_ip_str, | ||
rp->ai_canonname, sizeof(options->allow_ip_str)); | ||
break; | ||
|
@@ -312,8 +313,9 @@ parse_url(char *res_url, struct url* url) | |
int | ||
resolve_ip_https(fko_cli_options_t *options) | ||
{ | ||
int o1, o2, o3, o4, got_resp=0, i=0; | ||
char *ndx, resp[MAX_IPV4_STR_LEN+1] = {0}; | ||
int got_resp=0, error; | ||
char resp[MAX_IPV4_STR_LEN+1] = {0}; | ||
struct addrinfo *result=NULL, *rp, hints; | ||
struct url url; /* for validation only */ | ||
char wget_ssl_cmd[MAX_URL_PATH_LEN] = {0}; /* for verbose logging only */ | ||
|
||
|
@@ -482,32 +484,35 @@ resolve_ip_https(fko_cli_options_t *options) | |
pclose(wget); | ||
#endif | ||
|
||
if(got_resp) | ||
if(! got_resp) | ||
{ | ||
ndx = resp; | ||
for(i=0; i<MAX_IPV4_STR_LEN; i++) { | ||
if(! isdigit((int)(unsigned char)*(ndx+i)) && *(ndx+i) != '.') | ||
break; | ||
} | ||
*(ndx+i) = '\0'; | ||
|
||
if((sscanf(ndx, "%u.%u.%u.%u", &o1, &o2, &o3, &o4)) == 4 | ||
&& o1 >= 0 && o1 <= 255 | ||
&& o2 >= 0 && o2 <= 255 | ||
&& o3 >= 0 && o3 <= 255 | ||
&& o4 >= 0 && o4 <= 255) | ||
{ | ||
strlcpy(options->allow_ip_str, ndx, sizeof(options->allow_ip_str)); | ||
log_msg(LOG_VERBOSITY_ERROR, | ||
"[-] Could not resolve IP via: '%s'", wget_ssl_cmd); | ||
return -1; | ||
} | ||
|
||
log_msg(LOG_VERBOSITY_INFO, | ||
"\n[+] Resolved external IP (via '%s') as: %s", | ||
wget_ssl_cmd, options->allow_ip_str); | ||
return 1; | ||
} | ||
memset(&hints, 0, sizeof(struct addrinfo)); | ||
hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */ | ||
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'", wget_ssl_cmd); | ||
return(-1); | ||
} | ||
for (rp = result; rp != NULL; rp = rp->ai_next) { | ||
/* the canonical value is in the first structure returned */ | ||
strlcpy(options->allow_ip_str, | ||
rp->ai_canonname, sizeof(options->allow_ip_str)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why getting last entry ? |
||
break; | ||
} | ||
log_msg(LOG_VERBOSITY_ERROR, | ||
"[-] Could not resolve IP via: '%s'", wget_ssl_cmd); | ||
return -1; | ||
freeaddrinfo(result); | ||
|
||
log_msg(LOG_VERBOSITY_INFO, | ||
"\n[+] Resolved external IP (via '%s') as: %s", | ||
wget_ssl_cmd, options->allow_ip_str); | ||
return 1; | ||
} | ||
|
||
int | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MAX_IPV46_STR_LEN ?