Skip to content

Commit

Permalink
[skip-release] test multiple versions of traefik
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall committed Feb 26, 2025
1 parent 0051d5b commit 1d7d7ce
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/github-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ permissions:
actions: write
jobs:
release:
if: github.event.pull_request.merged == true
if: github.event.pull_request.merged == true && !contains(github.event.pull_request.title, '[skip-release]')
runs-on: ubuntu-24.04
steps:
- name: Checkout
Expand Down
26 changes: 15 additions & 11 deletions .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,26 @@ jobs:
exit 1
fi
- name: Install dependencies
run: go get .

- name: vendor
run: go mod vendor

- name: unit test
run: go test -v -race ./...

- name: integration test
jobs:
integration-test:
needs: [run]
permissions:
contents: read
runs-on: ubuntu-24.04
strategy:
matrix:
traefik: [v2.11, v3.0, v3.1, v3.2, v3.3]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

- name: run
run: go run test.go
working-directory: ./ci

- name: get stats
run: |
curl -s -H "X-Forwarded-For: 127.0.0.1" http://localhost/captcha-protect/stats | sort -n
env:
TRAEFIK_TAG: ${{ matrix.traefik }}

- name: cleanup
if: ${{ always() }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![lint-test](https://github.com/libops/captcha-protect/actions/workflows/lint-test.yml/badge.svg)](https://github.com/libops/captcha-protect/actions/workflows/lint-test.yml)
[![Go Report Card](https://goreportcard.com/badge/github.com/libops/captcha-protect)](https://goreportcard.com/report/github.com/libops/captcha-protect)

Traefik middleware to challenge individual IPs in a subnet when traffic spikes are detected from that subnet, using a captcha of your choice for the challenge (turnstile, recaptcha, or hcaptcha).
Traefik middleware to challenge individual IPs in a subnet when traffic spikes are detected from that subnet, using a captcha of your choice for the challenge (turnstile, recaptcha, or hcaptcha). **Requires traefik `v2.11.0` or above**

You may have seen CAPTCHAs added to individual forms on the web to prevent bots from spamming submissions. This plugin extends that concept to your entire site (or specific routes on your site), effectively placing your entire site behind a CAPTCHA. However, the CAPTCHA is only triggered when a spike in traffic is detected from the same IP subnet. Once the CAPTCHA is successfully completed, that IP is no longer challenged, allowing uninterrupted browsing.

Expand Down
5 changes: 5 additions & 0 deletions ci/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ func runCommand(name string, args ...string) {
cmd.Stderr = os.Stderr
cmd.Env = append(cmd.Env, fmt.Sprintf("RATE_LIMIT=%d", rateLimit))
cmd.Env = append(cmd.Env, fmt.Sprintf("PATH=%s", os.Getenv("PATH")))

tt := os.Getenv("TRAEFIK_TAG")
if tt != "" {
cmd.Env = append(cmd.Env, fmt.Sprintf("TRAEFIK_TAG=%s", tt))
}
if err := cmd.Run(); err != nil {
log.Fatalf("Command failed: %v", err)
}
Expand Down

0 comments on commit 1d7d7ce

Please sign in to comment.