Skip to content

Commit a57a86a

Browse files
committed
feat: support new trusted proxy flags
Signed-off-by: Liam Stanley <[email protected]>
1 parent 1c440c9 commit a57a86a

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

USAGE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
| Environment vars | Flags | Type | Description |
1212
| --- | --- | --- | --- |
1313
| `HTTP_BIND_ADDR` | `--http.bind-addr` | string | ip:port pair to bind to [**required**] [**default: :8080**] |
14-
| `HTTP_TRUSTED_PROXIES` | `--http.trusted-proxies` | []string | CIDR ranges that we trust the X-Forwarded-For header from |
14+
| `HTTP_TRUSTED_PROXIES` | `--http.trusted-proxies` | []string | CIDR ranges that we trust the X-Forwarded-For header from (addl opts: local, *, cloudflare, and/or custom header to use) |
1515
| `HTTP_MAX_CONCURRENT` | `--http.max-concurrent` | int | limit total max concurrent requests across all connections (0 for no limit) |
1616
| `HTTP_LIMIT` | `--http.limit` | int | number of requests/ip/hour [**default: 2000**] |
1717
| `HTTP_HSTS` | `--http.hsts` | bool | enable HTTP Strict Transport Security |

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/bluele/gcache v0.0.2
88
github.com/go-chi/chi/v5 v5.0.7
99
github.com/go-chi/cors v1.2.1
10-
github.com/lrstanley/chix v0.0.0-20220903205755-022e8ac017bb
10+
github.com/lrstanley/chix v0.0.0-20220905152744-9e3b5cbca59c
1111
github.com/lrstanley/clix v0.0.0-20220829163403-8f716406f9d5
1212
github.com/lrstanley/go-bogon v0.0.0-20220507183221-362a880cf97b
1313
github.com/lrstanley/go-sempool v0.0.0-20220507183223-1b08ce19f0b9

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ github.com/lestrrat-go/httpcc v1.0.0/go.mod h1:tGS/u00Vh5N6FHNkExqGGNId8e0Big+++
180180
github.com/lestrrat-go/iter v1.0.1/go.mod h1:zIdgO1mRKhn8l9vrZJZz9TUMMFbQbLeTsbqPDrJ/OJc=
181181
github.com/lestrrat-go/jwx v1.2.21/go.mod h1:9cfxnOH7G1gN75CaJP2hKGcxFEx5sPh1abRIA/ZJVh4=
182182
github.com/lestrrat-go/option v1.0.0/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I=
183-
github.com/lrstanley/chix v0.0.0-20220903205755-022e8ac017bb h1:wxbYVMu1mg/4zlWJMhonvUf9I0CbbOtsFCWMad2D9Vc=
184-
github.com/lrstanley/chix v0.0.0-20220903205755-022e8ac017bb/go.mod h1:UxmCvkoFWQP+3c3bVEGmAwHz9d7MHBX1IwfQK3i9e7U=
183+
github.com/lrstanley/chix v0.0.0-20220905152744-9e3b5cbca59c h1:K0iKLicfYGAgcgtlvMabd5+lGWyUkTNJ+08OJz0H2qM=
184+
github.com/lrstanley/chix v0.0.0-20220905152744-9e3b5cbca59c/go.mod h1:UxmCvkoFWQP+3c3bVEGmAwHz9d7MHBX1IwfQK3i9e7U=
185185
github.com/lrstanley/clix v0.0.0-20220829163403-8f716406f9d5 h1:NFIBt6Wer+HmAw836W6NsKoef0pqw0YdBXm+rXSy7AA=
186186
github.com/lrstanley/clix v0.0.0-20220829163403-8f716406f9d5/go.mod h1:5srbSsLpTj3J7cjhs43rQ+PNDxPulrhjYuJh4uaJFp4=
187187
github.com/lrstanley/go-bogon v0.0.0-20220507183221-362a880cf97b h1:jFRbU7IgKGjXlo1ERztns+QOlVRExiP0syyVIsP1TqU=

http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func httpServer(ctx context.Context) *http.Server {
3232
limiter := httpware.NewLimiter(cli.Flags.HTTP, 1*time.Hour)
3333

3434
if len(cli.Flags.HTTP.TrustedProxies) > 0 {
35-
r.Use(chix.UseRealIP(cli.Flags.HTTP.TrustedProxies, chix.OptUseXForwardedFor))
35+
r.Use(chix.UseRealIPCLIOpts(cli.Flags.HTTP.TrustedProxies))
3636
}
3737

3838
// Core middeware.

internal/models/flags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type Flags struct {
1414

1515
type ConfigHTTP struct {
1616
BindAddr string `env:"BIND_ADDR" long:"bind-addr" default:":8080" required:"true" description:"ip:port pair to bind to"`
17-
TrustedProxies []string `env:"TRUSTED_PROXIES" long:"trusted-proxies" description:"CIDR ranges that we trust the X-Forwarded-For header from"`
17+
TrustedProxies []string `env:"TRUSTED_PROXIES" long:"trusted-proxies" description:"CIDR ranges that we trust the X-Forwarded-For header from (addl opts: local, *, cloudflare, and/or custom header to use)"`
1818
MaxConcurrent int `env:"MAX_CONCURRENT" long:"max-concurrent" description:"limit total max concurrent requests across all connections (0 for no limit)"`
1919
Limit int `env:"LIMIT" long:"limit" description:"number of requests/ip/hour" default:"2000"`
2020
HSTS bool `env:"HSTS" long:"hsts" description:"enable HTTP Strict Transport Security"`

0 commit comments

Comments
 (0)