Skip to content
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

Start implementing ipv6 support #3631

Draft
wants to merge 436 commits into
base: main
Choose a base branch
from
Draft

Start implementing ipv6 support #3631

wants to merge 436 commits into from

Conversation

jaapmarcus
Copy link
Member

No description provided.

@jaapmarcus jaapmarcus marked this pull request as draft May 28, 2023 21:33
if [ -z "$ip" -a -z "$ipv6" ]; then
get_user_ipv6 # get first available user ipv6 address as fallback, if none ip address was defined
if [ -z "$ipv6" ]; then
get_user_ip # get first available user ipv4 address as fallback, if none ipv6 user address available
Copy link
Member Author

Choose a reason for hiding this comment

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

get_user_ipv6 sets $ipv6 how ever $ip is still empty


exit
${HESTIA}/bin/v-add-web-domain-ipv46 "$user" "$domain" "$ip" "$ipv6" "$restart" "$aliases" "$proxy_ext"
Copy link
Member Author

Choose a reason for hiding this comment

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

If $ip is not provided it should get ip from available ips

@@ -47,8 +47,8 @@ fi
# Verifications #
#----------------------------------------------------------#

check_args '1' "$#" 'CHAIN [PORT] [PROTOCOL]'
#is_format_valid 'chain' 'port_ext' 'protocol'
check_args '1' "$#" 'CHAIN [PORT] [PROTOCOL] [FAMILY] [IPTABLES] [LOCKINGOPT]'
Copy link
Member Author

Choose a reason for hiding this comment

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

Please make sure to add validation for this ...

Copy link
Contributor

Choose a reason for hiding this comment

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

For optional parameters too?
I will show, how it is implemented with other checks. But you are right, the [IPTABLES] parameter is very dangerous. Theoretically you can define instead of iptables each other binary or script here.

Copy link
Contributor

Choose a reason for hiding this comment

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

These parameters are from standard examples and scripts, proposed by fail2ban

Copy link
Member Author

Choose a reason for hiding this comment

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

We need at least prevent users can't be using ' as it can be abused...

format_no_quotes should fix it ...

Copy link
Contributor

Choose a reason for hiding this comment

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

No, if I implement it, then not a half solution. I make it completelly. [IPTABLES] is really very dangerous and I will check it double. [FAMILY] can be only 'inet4' or 'inet6', therefore it is very simple to check it. I rename then the variable to a better and unique one, since "family" is very common. [LOCKINGOPT] is deactivated now, since I used it wrong with quotes. But I will activate it in future and check it against '-w', since it can have actually only this option.

check_args '1' "$#" 'CHAIN [PORT] [PROTOCOL] [FAMILY] [IPTABLES] [LOCKINGOPT]'
is_format_valid 'chain' 'port_ext' 'protocol'
check_args '1' "$#" 'CHAIN [PORT] [PROTOCOL] [IPFAMILY] [IPTABLES] [FW_LOCKINGOPT]'
is_format_valid 'chain' 'port_ext' 'protocol' 'ipfamily' 'iptables' 'fw_lockingopt'
Copy link
Member Author

Choose a reason for hiding this comment

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

Do we really need iptables / fw_lockingopt option

I don't we will ever want to implement anything other then iptables and it should all be the same..

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe for iptables6 and iptables...

Copy link
Contributor

Choose a reason for hiding this comment

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

this locking option (as -w) comes from standard example of fail2ban. Therefore I pass-through it here, like it is defined in standard library of fail2ban. Unfortunatelly it works actually only in case of "add chain". I do not know, why, but that were results of my "printf test" or better to say "echo test" and play with these scripts.
The problem with this additionally option is followed: If you ignore it completelly, may be, that it will be added during call as last argument. In this case you will have iptables="iptables -w" (or something else). Therefore we need a "very last" argument after "last argument" iptables. Then you will have "clean" separation in iptables="iptables" and rest in this "lockingopt".
After it we can decide, if we want to use it, if we call iptables. Actually it is only during "add chain" and I will observe, how it works. I do not know really, why fail2ban use this option. I will read more about it

Copy link
Contributor

Choose a reason for hiding this comment

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

You can find this file under /etc/fail2ban/actions.d/iptables.conf
And that is a kind of "library" for calls over this iptables-interface

Copy link
Contributor

@asmcc asmcc Oct 12, 2023

Choose a reason for hiding this comment

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

# Notes.:  Option was introduced to iptables to prevent multiple instances from
#          running concurrently and causing irratic behavior.  -w was introduced
#          in iptables 1.4.20, so might be absent on older systems
#          See https://github.com/fail2ban/fail2ban/issues/1122
# Values:  STRING
lockingopt = -w

# Option:  iptables
# Notes.:  Actual command to be executed, including common to all calls options
# Values:  STRING
iptables = iptables <lockingopt>


[Init?family=inet6]

# Option:  blocktype (ipv6)
# Note:    This is what the action does with rules. This can be any jump target
#          as per the iptables man page (section 8). Common values are DROP
#          REJECT, REJECT --reject-with icmp6-port-unreachable
# Values:  STRING
blocktype = REJECT --reject-with icmp6-port-unreachable

# Option:  iptables (ipv6)
# Notes.:  Actual command to be executed, including common to all calls options
# Values:  STRING
iptables = ip6tables <lockingopt>

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.

None yet

4 participants