feat: add source support#139
Open
DakEnviy wants to merge 4 commits into
Open
Conversation
2748fc3 to
aa1a11b
Compare
467c9ea to
cf82828
Compare
cf82828 to
a2d07f3
Compare
Author
|
@chaifeng, hello! Please have a look once you have time |
Owner
|
Hi @DakEnviy Thanks for your contribution! I've looked this PR and have some concerns regarding backward compatibility. The changes introduce a new Could we explore options to maintain backward compatibility? For example, perhaps we could follow |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds optional source filtering (IP, subnet or "any") to UFW rules created by
ufw-docker, updates help/usage, and introduces comprehensive test coverage for the new behaviour.Motivation
Users need to restrict allowed traffic to a container by specific source addresses or subnets, not only by destination port/protocol.
It is useful for cases when an application lives behind a proxy (e.g. CloudFlare). I use it with this script:
What’s changed
ufw-docker <list|allow> [docker-instance-id-or-name [source] [port[/tcp|/udp]] [network]]192.168.1.10,fd00:cf::42)192.168.1.0/24,fd00:cf::/8)anyufw route allow proto <tcp|udp> from <SOURCE> to <INSTANCE_IP> [port <PORT>] comment "allow <instance> <SOURCE> <PORT>/<PROTO> [<NETWORK>]"anyis used as the default when the source is omitted to allow.Implementation note:
sourceparameter was added before port to setfromand use auto-detection for ports together.Documentation note:
I wrote the Chinese part using a translator, so please do not judge it strictly and check it thoroughly.