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 IPv4 link-local address to private ranges detector, update list #29

Merged
merged 2 commits into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 7 additions & 20 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
linters-settings:
govet:
check-shadowing: true
golint:
min-confidence: 0
enable:
- shadow
gocyclo:
min-complexity: 15
maligned:
suggest-new: true
dupl:
threshold: 100
goconst:
Expand All @@ -26,44 +23,34 @@ linters-settings:

linters:
enable:
- megacheck
- staticcheck
- gosimple
- revive
- govet
- unconvert
- megacheck
- gas
- unused
- gosec
- gocyclo
- dupl
- misspell
- unparam
- unused
- typecheck
- ineffassign
- stylecheck
- gochecknoinits
- exportloopref
- gocritic
- nakedret
- gosimple
- prealloc
fast: false
disable-all: true

run:
output:
format: tab
skip-dirs:
- vendor

issues:
exclude-rules:
- text: 'Deferring unsafe method "Close" on type "io.ReadCloser"'
linters:
- gosec
- text: "should have a package comment, unless it's in another file for this package"
linters:
- golint
- path: _test\.go
linters:
- dupl
exclude-use-default: false
exclude-use-default: false
4 changes: 2 additions & 2 deletions benchmarks.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ func NewBenchmarks() *Benchmarks {
// Default is 15 minutes. The increase of this range will change memory utilization as each second of the range
// kept as benchData aggregate. The default means 15*60 = 900 seconds of data aggregate.
// Larger range allows for longer time periods to be benchmarked.
func (b *Benchmarks) WithTimeRange(max time.Duration) *Benchmarks {
func (b *Benchmarks) WithTimeRange(maximum time.Duration) *Benchmarks {
b.lock.Lock()
defer b.lock.Unlock()
b.maxTimeRange = max
b.maxTimeRange = maximum
return b
}

Expand Down
6 changes: 3 additions & 3 deletions logger/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ func WithBody(l *Middleware) {
}

// MaxBodySize sets size of the logged part of the request body.
func MaxBodySize(max int) Option {
func MaxBodySize(maximum int) Option {
return func(l *Middleware) {
if max >= 0 {
l.maxBodySize = max
if maximum >= 0 {
l.maxBodySize = maximum
}
}
}
Expand Down
13 changes: 10 additions & 3 deletions realip/real.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,22 @@ type ipRange struct {
end net.IP
}

// privateRanges contains the list of private and special-use IP ranges.
// reference: https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
var privateRanges = []ipRange{
// IPv4 Private Ranges
{start: net.ParseIP("10.0.0.0"), end: net.ParseIP("10.255.255.255")},
{start: net.ParseIP("100.64.0.0"), end: net.ParseIP("100.127.255.255")},
{start: net.ParseIP("172.16.0.0"), end: net.ParseIP("172.31.255.255")},
{start: net.ParseIP("192.0.0.0"), end: net.ParseIP("192.0.0.255")},
{start: net.ParseIP("192.168.0.0"), end: net.ParseIP("192.168.255.255")},
// IPv4 Link-Local
{start: net.ParseIP("169.254.0.0"), end: net.ParseIP("169.254.255.255")},
// IPv4 Shared Address Space (RFC 6598)
{start: net.ParseIP("100.64.0.0"), end: net.ParseIP("100.127.255.255")},
// IPv4 Benchmarking (RFC 2544)
{start: net.ParseIP("198.18.0.0"), end: net.ParseIP("198.19.255.255")},
{start: net.ParseIP("::1"), end: net.ParseIP("::1")},
// IPv6 Unique Local Addresses (ULA)
{start: net.ParseIP("fc00::"), end: net.ParseIP("fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")},
// IPv6 Link-local Addresses
{start: net.ParseIP("fe80::"), end: net.ParseIP("febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff")},
}

Expand Down
Loading