Skip to content

Commit

Permalink
feat: add rate limiter (#201)
Browse files Browse the repository at this point in the history
* feat: add server addresses

* feat: add config file loading

* fix: proxy protocol

Signed-off-by: haveachin <[email protected]>

* feat: add rate limiter

Signed-off-by: haveachin <[email protected]>

* refactor: middleware to filter

Signed-off-by: haveachin <[email protected]>

* refactor: more testability

* refactor: listener to only one

* refactor: config files

* feat: add config file loading

* refactor: filter for only one listener

* feat: add docs

* docs: add config docs

* refactor: file loading

* refactor: remove unnecessary mutex

* docs: clean up readme

* feat: add linting, ci and release automation

* docs: add rate limiter

* fix: linting errors

* fix: linting errors

* fix: linting errors

* chore: clean up

* refactor: ServerRequester

* feat: add zerolog

* chore: clean up

---------

Signed-off-by: haveachin <[email protected]>
  • Loading branch information
haveachin authored Feb 2, 2024
1 parent cca5096 commit a981ca1
Show file tree
Hide file tree
Showing 62 changed files with 2,122 additions and 1,025 deletions.
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: haveachin
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: haveachin
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: https://paypal.me/hendrikschlehlein # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
52 changes: 52 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: CI

on:
push:
branches:
- master
- main
pull_request:

permissions:
contents: read

env:
GO_VERSION: 1.21

jobs:
test:
name: Test
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Checkout code
uses: actions/checkout@v3
- name: Test
run: make test

build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
args: build --snapshot
46 changes: 46 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Lint

on:
push:
branches:
- master
- main
pull_request:

permissions:
contents: read
pull-requests: read
checks: write

env:
GO_VERSION: 1.21

jobs:
golangci:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.55.2

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
#
# Note: By default, the `.golangci.yml` file should be at the root of the repository.
# The location of the configuration file can be changed by using `--config=`
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
only-new-issues: true
49 changes: 49 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Release

on:
push:
tags:
- "*"

permissions:
contents: write
packages: write

env:
GO_VERSION: 1.21

jobs:
release:
name: Build & Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Artifacts
out/
__debug_bin*
dist/

# Benchmark/Profiler
*.bench
Expand All @@ -11,10 +12,10 @@ __debug_bin*
.dev/
cmd/infrared/config.yml

# VSCode
# VSCode Dev Files
.vscode/

# IntelliJ
# IntelliJ Dev Files
.idea/

# Docs
Expand Down
Loading

0 comments on commit a981ca1

Please sign in to comment.