-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the ability to load ranges from a text file
Add the ability to load IP ranges from a text file and update documentation. * **config.go** - Add a new subdirective `ranges_file` to load ranges from a text file. - Update the `UnmarshalCaddyfile` function to handle the new subdirective. - Update the `Validate` function to validate the ranges loaded from the text file. - Add a check to throw an error if neither `ranges` nor `ranges_file` is specified. * **middleware.go** - Add logic to check if the client IP is in any of the ranges loaded from the text file. * **plugin.go** - Update the `DefenderMiddleware` struct to include a new field `RangesFile`. - Update the `Provision` function to load ranges from the specified text file. * **examples/range_files/Caddyfile** - Add a new example Caddyfile demonstrating the usage of `ranges_file` subdirective. * **examples/range_files/ranges.txt** - Add a new text file containing example IP ranges. * **README.md** - Add documentation for the new `ranges_file` subdirective.
- Loading branch information
1 parent
e4a3e26
commit 4fc0a8c
Showing
6 changed files
with
123 additions
and
0 deletions.
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
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
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
auto_https off | ||
order defender before basicauth | ||
} | ||
|
||
:80 { | ||
defender block { | ||
ranges_file ./examples/range_files/ranges.txt | ||
} | ||
respond "This is what a human sees" | ||
} | ||
|
||
:83 { | ||
respond "Clear text HTTP" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
192.168.1.0/24 | ||
10.0.0.0/8 | ||
172.16.0.0/12 |
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
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