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

Add the ability to load ranges from a text file #13

Closed
wants to merge 10 commits into from

Conversation

JasonLovesDoggo
Copy link
Owner

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.

JasonLovesDoggo and others added 10 commits January 16, 2025 19:28
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.
Registers the `defender` directive to be executed before
`basicauth`. This ensures that IP restrictions are applied
before authentication.  Removes redundant `order` directives
from Caddyfile examples.
Renamed `DefenderMiddleware` to `Defender` for clarity and
consistency. This change affects the struct name,
corresponding methods, and documentation.  Updated
`CONTRIBUTING.md`, `README.md`, and examples to reflect
this change.  Adjusted error handling in `config.go` to
align with Caddy's conventions. Simplified `plugin.go` by
removing unnecessary nil check after `UnmarshalCaddyfile`.
Removed global `order` directive from `intro.md` and
`README.md` as it's now redundant.
The configuration for the custom responder has been simplified.  The
`message` field is now directly part of the Defender
configuration and is passed to the `CustomResponder`.  The responder
type is no longer required during setup, streamlining the process.
The configuration for the custom responder has been simplified.  The
`message` field is now directly part of the Defender
configuration and is passed to the `CustomResponder`.  The responder
type is no longer required during setup, streamlining the process.
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.

1 participant