mirror of
https://github.com/Luzifer/staticmap.git
synced 2024-12-30 01:31:18 +00:00
Update dependencies once more
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
9e37fa0cd5
commit
93fbf9f3ae
6 changed files with 85 additions and 14 deletions
10
Gopkg.lock
generated
10
Gopkg.lock
generated
|
@ -14,8 +14,8 @@
|
||||||
"http",
|
"http",
|
||||||
"str"
|
"str"
|
||||||
]
|
]
|
||||||
revision = "8fdddb7041fe962e750caa553a0714f94e261c4a"
|
revision = "15199b8e33ca5558e8c58af7924083983eb63ca4"
|
||||||
version = "v2.3.1"
|
version = "v2.4.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/Luzifer/rconfig"
|
name = "github.com/Luzifer/rconfig"
|
||||||
|
@ -100,7 +100,8 @@
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/patrickmn/go-cache"
|
name = "github.com/patrickmn/go-cache"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "7ac151875ffb48b9f3ccce9ea20f020b0c1596c8"
|
revision = "a3647f8e31d79543b2d0f0ae2fe5c379d72cedc0"
|
||||||
|
version = "v2.1.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/spf13/pflag"
|
name = "github.com/spf13/pflag"
|
||||||
|
@ -147,9 +148,10 @@
|
||||||
revision = "378d26f46672a356c46195c28f61bdb4c0a781dd"
|
revision = "378d26f46672a356c46195c28f61bdb4c0a781dd"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
name = "golang.org/x/time"
|
name = "golang.org/x/time"
|
||||||
packages = ["rate"]
|
packages = ["rate"]
|
||||||
revision = "711ca1cb87636abec28122ef3bc6a77269d433f3"
|
revision = "26559e0f760e39c24d730d3224364aef164ee23f"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "v2"
|
branch = "v2"
|
||||||
|
|
23
vendor/github.com/Luzifer/go_helpers/http/logHandler.go
generated
vendored
23
vendor/github.com/Luzifer/go_helpers/http/logHandler.go
generated
vendored
|
@ -3,17 +3,22 @@ package http
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Luzifer/go_helpers/accessLogger"
|
"github.com/Luzifer/go_helpers/accessLogger"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HTTPLogHandler struct {
|
type HTTPLogHandler struct {
|
||||||
Handler http.Handler
|
Handler http.Handler
|
||||||
|
TrustedIPHeaders []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHTTPLogHandler(h http.Handler) http.Handler {
|
func NewHTTPLogHandler(h http.Handler) http.Handler {
|
||||||
return HTTPLogHandler{Handler: h}
|
return HTTPLogHandler{
|
||||||
|
Handler: h,
|
||||||
|
TrustedIPHeaders: []string{"X-Forwarded-For", "RemoteAddr", "X-Real-IP"},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l HTTPLogHandler) ServeHTTP(res http.ResponseWriter, r *http.Request) {
|
func (l HTTPLogHandler) ServeHTTP(res http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -23,7 +28,7 @@ func (l HTTPLogHandler) ServeHTTP(res http.ResponseWriter, r *http.Request) {
|
||||||
l.Handler.ServeHTTP(ares, r)
|
l.Handler.ServeHTTP(ares, r)
|
||||||
|
|
||||||
log.Printf("%s - \"%s %s\" %d %d \"%s\" \"%s\" %s",
|
log.Printf("%s - \"%s %s\" %d %d \"%s\" \"%s\" %s",
|
||||||
r.RemoteAddr,
|
l.findIP(r),
|
||||||
r.Method,
|
r.Method,
|
||||||
r.URL.Path,
|
r.URL.Path,
|
||||||
ares.StatusCode,
|
ares.StatusCode,
|
||||||
|
@ -33,3 +38,15 @@ func (l HTTPLogHandler) ServeHTTP(res http.ResponseWriter, r *http.Request) {
|
||||||
time.Since(start),
|
time.Since(start),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l HTTPLogHandler) findIP(r *http.Request) string {
|
||||||
|
remoteAddr := strings.SplitN(r.RemoteAddr, ":", 2)[0]
|
||||||
|
|
||||||
|
for _, hdr := range l.TrustedIPHeaders {
|
||||||
|
if value := r.Header.Get(hdr); value != "" {
|
||||||
|
return strings.SplitN(value, ",", 2)[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return remoteAddr
|
||||||
|
}
|
||||||
|
|
2
vendor/github.com/patrickmn/go-cache/cache.go
generated
vendored
2
vendor/github.com/patrickmn/go-cache/cache.go
generated
vendored
|
@ -1074,7 +1074,6 @@ type janitor struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *janitor) Run(c *cache) {
|
func (j *janitor) Run(c *cache) {
|
||||||
j.stop = make(chan bool)
|
|
||||||
ticker := time.NewTicker(j.Interval)
|
ticker := time.NewTicker(j.Interval)
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
@ -1094,6 +1093,7 @@ func stopJanitor(c *Cache) {
|
||||||
func runJanitor(c *cache, ci time.Duration) {
|
func runJanitor(c *cache, ci time.Duration) {
|
||||||
j := &janitor{
|
j := &janitor{
|
||||||
Interval: ci,
|
Interval: ci,
|
||||||
|
stop: make(chan bool),
|
||||||
}
|
}
|
||||||
c.janitor = j
|
c.janitor = j
|
||||||
go j.Run(c)
|
go j.Run(c)
|
||||||
|
|
22
vendor/golang.org/x/time/rate/rate.go
generated
vendored
22
vendor/golang.org/x/time/rate/rate.go
generated
vendored
|
@ -10,8 +10,6 @@ import (
|
||||||
"math"
|
"math"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"golang.org/x/net/context"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Limit defines the maximum frequency of some events.
|
// Limit defines the maximum frequency of some events.
|
||||||
|
@ -199,9 +197,10 @@ func (lim *Limiter) Reserve() *Reservation {
|
||||||
// The Limiter takes this Reservation into account when allowing future events.
|
// The Limiter takes this Reservation into account when allowing future events.
|
||||||
// ReserveN returns false if n exceeds the Limiter's burst size.
|
// ReserveN returns false if n exceeds the Limiter's burst size.
|
||||||
// Usage example:
|
// Usage example:
|
||||||
// r, ok := lim.ReserveN(time.Now(), 1)
|
// r := lim.ReserveN(time.Now(), 1)
|
||||||
// if !ok {
|
// if !r.OK() {
|
||||||
// // Not allowed to act! Did you remember to set lim.burst to be > 0 ?
|
// // Not allowed to act! Did you remember to set lim.burst to be > 0 ?
|
||||||
|
// return
|
||||||
// }
|
// }
|
||||||
// time.Sleep(r.Delay())
|
// time.Sleep(r.Delay())
|
||||||
// Act()
|
// Act()
|
||||||
|
@ -213,8 +212,19 @@ func (lim *Limiter) ReserveN(now time.Time, n int) *Reservation {
|
||||||
return &r
|
return &r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// contextContext is a temporary(?) copy of the context.Context type
|
||||||
|
// to support both Go 1.6 using golang.org/x/net/context and Go 1.7+
|
||||||
|
// with the built-in context package. If people ever stop using Go 1.6
|
||||||
|
// we can remove this.
|
||||||
|
type contextContext interface {
|
||||||
|
Deadline() (deadline time.Time, ok bool)
|
||||||
|
Done() <-chan struct{}
|
||||||
|
Err() error
|
||||||
|
Value(key interface{}) interface{}
|
||||||
|
}
|
||||||
|
|
||||||
// Wait is shorthand for WaitN(ctx, 1).
|
// Wait is shorthand for WaitN(ctx, 1).
|
||||||
func (lim *Limiter) Wait(ctx context.Context) (err error) {
|
func (lim *Limiter) wait(ctx contextContext) (err error) {
|
||||||
return lim.WaitN(ctx, 1)
|
return lim.WaitN(ctx, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,7 +232,7 @@ func (lim *Limiter) Wait(ctx context.Context) (err error) {
|
||||||
// It returns an error if n exceeds the Limiter's burst size, the Context is
|
// It returns an error if n exceeds the Limiter's burst size, the Context is
|
||||||
// canceled, or the expected wait time exceeds the Context's Deadline.
|
// canceled, or the expected wait time exceeds the Context's Deadline.
|
||||||
// The burst limit is ignored if the rate limit is Inf.
|
// The burst limit is ignored if the rate limit is Inf.
|
||||||
func (lim *Limiter) WaitN(ctx context.Context, n int) (err error) {
|
func (lim *Limiter) waitN(ctx contextContext, n int) (err error) {
|
||||||
if n > lim.burst && lim.limit != Inf {
|
if n > lim.burst && lim.limit != Inf {
|
||||||
return fmt.Errorf("rate: Wait(n=%d) exceeds limiter's burst %d", n, lim.burst)
|
return fmt.Errorf("rate: Wait(n=%d) exceeds limiter's burst %d", n, lim.burst)
|
||||||
}
|
}
|
||||||
|
|
21
vendor/golang.org/x/time/rate/rate_go16.go
generated
vendored
Normal file
21
vendor/golang.org/x/time/rate/rate_go16.go
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !go1.7
|
||||||
|
|
||||||
|
package rate
|
||||||
|
|
||||||
|
import "golang.org/x/net/context"
|
||||||
|
|
||||||
|
// Wait is shorthand for WaitN(ctx, 1).
|
||||||
|
func (lim *Limiter) Wait(ctx context.Context) (err error) {
|
||||||
|
return lim.waitN(ctx, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WaitN blocks until lim permits n events to happen.
|
||||||
|
// It returns an error if n exceeds the Limiter's burst size, the Context is
|
||||||
|
// canceled, or the expected wait time exceeds the Context's Deadline.
|
||||||
|
func (lim *Limiter) WaitN(ctx context.Context, n int) (err error) {
|
||||||
|
return lim.waitN(ctx, n)
|
||||||
|
}
|
21
vendor/golang.org/x/time/rate/rate_go17.go
generated
vendored
Normal file
21
vendor/golang.org/x/time/rate/rate_go17.go
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build go1.7
|
||||||
|
|
||||||
|
package rate
|
||||||
|
|
||||||
|
import "context"
|
||||||
|
|
||||||
|
// Wait is shorthand for WaitN(ctx, 1).
|
||||||
|
func (lim *Limiter) Wait(ctx context.Context) (err error) {
|
||||||
|
return lim.waitN(ctx, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WaitN blocks until lim permits n events to happen.
|
||||||
|
// It returns an error if n exceeds the Limiter's burst size, the Context is
|
||||||
|
// canceled, or the expected wait time exceeds the Context's Deadline.
|
||||||
|
func (lim *Limiter) WaitN(ctx context.Context, n int) (err error) {
|
||||||
|
return lim.waitN(ctx, n)
|
||||||
|
}
|
Loading…
Reference in a new issue