Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tabacco
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai3
tools
tabacco
Commits
85c333c9
Commit
85c333c9
authored
Dec 30, 2018
by
ale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update dependencies
parent
c4a888c7
Pipeline
#1979
failed with stages
in 36 seconds
Changes
107
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
107 changed files
with
40885 additions
and
26286 deletions
+40885
-26286
vendor/git.autistici.org/ai3/go-common/README.md
vendor/git.autistici.org/ai3/go-common/README.md
+22
-0
vendor/git.autistici.org/ai3/go-common/clientutil/balancer.go
...or/git.autistici.org/ai3/go-common/clientutil/balancer.go
+4
-1
vendor/git.autistici.org/ai3/go-common/clientutil/dns.go
vendor/git.autistici.org/ai3/go-common/clientutil/dns.go
+3
-1
vendor/git.autistici.org/ai3/go-common/clientutil/transport.go
...r/git.autistici.org/ai3/go-common/clientutil/transport.go
+4
-2
vendor/git.autistici.org/ai3/go-common/clientutil/watcher.go
vendor/git.autistici.org/ai3/go-common/clientutil/watcher.go
+186
-0
vendor/git.autistici.org/ai3/go-common/serverutil/http.go
vendor/git.autistici.org/ai3/go-common/serverutil/http.go
+27
-6
vendor/git.autistici.org/ai3/go-common/serverutil/tls.go
vendor/git.autistici.org/ai3/go-common/serverutil/tls.go
+10
-1
vendor/github.com/beorn7/perks/quantile/stream.go
vendor/github.com/beorn7/perks/quantile/stream.go
+29
-5
vendor/github.com/cenkalti/backoff/context.go
vendor/github.com/cenkalti/backoff/context.go
+6
-2
vendor/github.com/cenkalti/backoff/exponential.go
vendor/github.com/cenkalti/backoff/exponential.go
+1
-6
vendor/github.com/cenkalti/backoff/retry.go
vendor/github.com/cenkalti/backoff/retry.go
+1
-1
vendor/github.com/coreos/go-systemd/NOTICE
vendor/github.com/coreos/go-systemd/NOTICE
+5
-0
vendor/github.com/coreos/go-systemd/daemon/sdnotify.go
vendor/github.com/coreos/go-systemd/daemon/sdnotify.go
+30
-9
vendor/github.com/coreos/go-systemd/daemon/watchdog.go
vendor/github.com/coreos/go-systemd/daemon/watchdog.go
+5
-4
vendor/github.com/golang/protobuf/LICENSE
vendor/github.com/golang/protobuf/LICENSE
+0
-3
vendor/github.com/golang/protobuf/proto/Makefile
vendor/github.com/golang/protobuf/proto/Makefile
+0
-43
vendor/github.com/golang/protobuf/proto/clone.go
vendor/github.com/golang/protobuf/proto/clone.go
+35
-11
vendor/github.com/golang/protobuf/proto/decode.go
vendor/github.com/golang/protobuf/proto/decode.go
+63
-606
vendor/github.com/golang/protobuf/proto/deprecated.go
vendor/github.com/golang/protobuf/proto/deprecated.go
+63
-0
vendor/github.com/golang/protobuf/proto/discard.go
vendor/github.com/golang/protobuf/proto/discard.go
+350
-0
vendor/github.com/golang/protobuf/proto/encode.go
vendor/github.com/golang/protobuf/proto/encode.go
+25
-1184
vendor/github.com/golang/protobuf/proto/equal.go
vendor/github.com/golang/protobuf/proto/equal.go
+17
-16
vendor/github.com/golang/protobuf/proto/extensions.go
vendor/github.com/golang/protobuf/proto/extensions.go
+151
-131
vendor/github.com/golang/protobuf/proto/lib.go
vendor/github.com/golang/protobuf/proto/lib.go
+117
-49
vendor/github.com/golang/protobuf/proto/message_set.go
vendor/github.com/golang/protobuf/proto/message_set.go
+4
-134
vendor/github.com/golang/protobuf/proto/pointer_reflect.go
vendor/github.com/golang/protobuf/proto/pointer_reflect.go
+237
-361
vendor/github.com/golang/protobuf/proto/pointer_unsafe.go
vendor/github.com/golang/protobuf/proto/pointer_unsafe.go
+210
-167
vendor/github.com/golang/protobuf/proto/properties.go
vendor/github.com/golang/protobuf/proto/properties.go
+72
-399
vendor/github.com/golang/protobuf/proto/table_marshal.go
vendor/github.com/golang/protobuf/proto/table_marshal.go
+2776
-0
vendor/github.com/golang/protobuf/proto/table_merge.go
vendor/github.com/golang/protobuf/proto/table_merge.go
+654
-0
vendor/github.com/golang/protobuf/proto/table_unmarshal.go
vendor/github.com/golang/protobuf/proto/table_unmarshal.go
+2053
-0
vendor/github.com/golang/protobuf/proto/text.go
vendor/github.com/golang/protobuf/proto/text.go
+27
-38
vendor/github.com/golang/protobuf/proto/text_parser.go
vendor/github.com/golang/protobuf/proto/text_parser.go
+34
-49
vendor/github.com/gorilla/handlers/cors.go
vendor/github.com/gorilla/handlers/cors.go
+20
-9
vendor/github.com/gorilla/handlers/handlers.go
vendor/github.com/gorilla/handlers/handlers.go
+0
-225
vendor/github.com/gorilla/handlers/logging.go
vendor/github.com/gorilla/handlers/logging.go
+252
-0
vendor/github.com/mattn/go-sqlite3/callback.go
vendor/github.com/mattn/go-sqlite3/callback.go
+6
-0
vendor/github.com/mattn/go-sqlite3/sqlite3-binding.c
vendor/github.com/mattn/go-sqlite3/sqlite3-binding.c
+28489
-21190
vendor/github.com/mattn/go-sqlite3/sqlite3-binding.h
vendor/github.com/mattn/go-sqlite3/sqlite3-binding.h
+217
-78
vendor/github.com/mattn/go-sqlite3/sqlite3.go
vendor/github.com/mattn/go-sqlite3/sqlite3.go
+61
-6
vendor/github.com/mattn/go-sqlite3/sqlite3_func_crypt.go
vendor/github.com/mattn/go-sqlite3/sqlite3_func_crypt.go
+4
-4
vendor/github.com/mattn/go-sqlite3/sqlite3ext.h
vendor/github.com/mattn/go-sqlite3/sqlite3ext.h
+8
-0
vendor/github.com/prometheus/client_golang/prometheus/collector.go
...thub.com/prometheus/client_golang/prometheus/collector.go
+59
-14
vendor/github.com/prometheus/client_golang/prometheus/counter.go
...github.com/prometheus/client_golang/prometheus/counter.go
+110
-22
vendor/github.com/prometheus/client_golang/prometheus/desc.go
...or/github.com/prometheus/client_golang/prometheus/desc.go
+3
-8
vendor/github.com/prometheus/client_golang/prometheus/doc.go
vendor/github.com/prometheus/client_golang/prometheus/doc.go
+21
-6
vendor/github.com/prometheus/client_golang/prometheus/fnv.go
vendor/github.com/prometheus/client_golang/prometheus/fnv.go
+13
-0
vendor/github.com/prometheus/client_golang/prometheus/gauge.go
...r/github.com/prometheus/client_golang/prometheus/gauge.go
+130
-17
vendor/github.com/prometheus/client_golang/prometheus/go_collector.go
...b.com/prometheus/client_golang/prometheus/go_collector.go
+20
-3
vendor/github.com/prometheus/client_golang/prometheus/histogram.go
...thub.com/prometheus/client_golang/prometheus/histogram.go
+196
-55
vendor/github.com/prometheus/client_golang/prometheus/http.go
...or/github.com/prometheus/client_golang/prometheus/http.go
+67
-87
vendor/github.com/prometheus/client_golang/prometheus/labels.go
.../github.com/prometheus/client_golang/prometheus/labels.go
+32
-2
vendor/github.com/prometheus/client_golang/prometheus/metric.go
.../github.com/prometheus/client_golang/prometheus/metric.go
+49
-41
vendor/github.com/prometheus/client_golang/prometheus/observer.go
...ithub.com/prometheus/client_golang/prometheus/observer.go
+2
-0
vendor/github.com/prometheus/client_golang/prometheus/process_collector.go
.../prometheus/client_golang/prometheus/process_collector.go
+93
-29
vendor/github.com/prometheus/client_golang/prometheus/promhttp/delegator.go
...prometheus/client_golang/prometheus/promhttp/delegator.go
+15
-15
vendor/github.com/prometheus/client_golang/prometheus/promhttp/delegator_1_8.go
...etheus/client_golang/prometheus/promhttp/delegator_1_8.go
+16
-16
vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go
....com/prometheus/client_golang/prometheus/promhttp/http.go
+164
-57
vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_client.go
...us/client_golang/prometheus/promhttp/instrument_client.go
+14
-15
vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_client_1_8.go
...lient_golang/prometheus/promhttp/instrument_client_1_8.go
+2
-2
vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go
...us/client_golang/prometheus/promhttp/instrument_server.go
+81
-74
vendor/github.com/prometheus/client_golang/prometheus/registry.go
...ithub.com/prometheus/client_golang/prometheus/registry.go
+409
-240
vendor/github.com/prometheus/client_golang/prometheus/summary.go
...github.com/prometheus/client_golang/prometheus/summary.go
+88
-39
vendor/github.com/prometheus/client_golang/prometheus/value.go
...r/github.com/prometheus/client_golang/prometheus/value.go
+9
-83
vendor/github.com/prometheus/client_golang/prometheus/vec.go
vendor/github.com/prometheus/client_golang/prometheus/vec.go
+268
-159
vendor/github.com/prometheus/client_golang/prometheus/wrap.go
...or/github.com/prometheus/client_golang/prometheus/wrap.go
+179
-0
vendor/github.com/prometheus/client_model/go/metrics.pb.go
vendor/github.com/prometheus/client_model/go/metrics.pb.go
+323
-58
vendor/github.com/prometheus/common/expfmt/decode.go
vendor/github.com/prometheus/common/expfmt/decode.go
+2
-2
vendor/github.com/prometheus/common/expfmt/expfmt.go
vendor/github.com/prometheus/common/expfmt/expfmt.go
+1
-1
vendor/github.com/prometheus/common/expfmt/text_create.go
vendor/github.com/prometheus/common/expfmt/text_create.go
+261
-96
vendor/github.com/prometheus/common/expfmt/text_parse.go
vendor/github.com/prometheus/common/expfmt/text_parse.go
+3
-3
vendor/github.com/prometheus/common/model/silence.go
vendor/github.com/prometheus/common/model/silence.go
+2
-2
vendor/github.com/prometheus/common/model/time.go
vendor/github.com/prometheus/common/model/time.go
+1
-1
vendor/github.com/prometheus/common/model/value.go
vendor/github.com/prometheus/common/model/value.go
+2
-2
vendor/github.com/prometheus/procfs/Makefile
vendor/github.com/prometheus/procfs/Makefile
+71
-12
vendor/github.com/prometheus/procfs/buddyinfo.go
vendor/github.com/prometheus/procfs/buddyinfo.go
+1
-1
vendor/github.com/prometheus/procfs/fixtures.ttar
vendor/github.com/prometheus/procfs/fixtures.ttar
+462
-0
vendor/github.com/prometheus/procfs/fs.go
vendor/github.com/prometheus/procfs/fs.go
+36
-0
vendor/github.com/prometheus/procfs/ipvs.go
vendor/github.com/prometheus/procfs/ipvs.go
+18
-5
vendor/github.com/prometheus/procfs/mdstat.go
vendor/github.com/prometheus/procfs/mdstat.go
+13
-0
vendor/github.com/prometheus/procfs/mountstats.go
vendor/github.com/prometheus/procfs/mountstats.go
+57
-7
vendor/github.com/prometheus/procfs/net_dev.go
vendor/github.com/prometheus/procfs/net_dev.go
+216
-0
vendor/github.com/prometheus/procfs/proc.go
vendor/github.com/prometheus/procfs/proc.go
+35
-1
vendor/github.com/prometheus/procfs/proc_io.go
vendor/github.com/prometheus/procfs/proc_io.go
+14
-4
vendor/github.com/prometheus/procfs/proc_limits.go
vendor/github.com/prometheus/procfs/proc_limits.go
+13
-0
vendor/github.com/prometheus/procfs/proc_ns.go
vendor/github.com/prometheus/procfs/proc_ns.go
+68
-0
vendor/github.com/prometheus/procfs/proc_stat.go
vendor/github.com/prometheus/procfs/proc_stat.go
+13
-0
vendor/github.com/prometheus/procfs/stat.go
vendor/github.com/prometheus/procfs/stat.go
+13
-0
vendor/github.com/prometheus/procfs/ttar
vendor/github.com/prometheus/procfs/ttar
+129
-4
vendor/github.com/prometheus/procfs/xfrm.go
vendor/github.com/prometheus/procfs/xfrm.go
+1
-1
vendor/github.com/prometheus/procfs/xfs/parse.go
vendor/github.com/prometheus/procfs/xfs/parse.go
+4
-33
vendor/gopkg.in/yaml.v2/LICENSE
vendor/gopkg.in/yaml.v2/LICENSE
+198
-10
vendor/gopkg.in/yaml.v2/NOTICE
vendor/gopkg.in/yaml.v2/NOTICE
+13
-0
vendor/gopkg.in/yaml.v2/README.md
vendor/gopkg.in/yaml.v2/README.md
+2
-2
vendor/gopkg.in/yaml.v2/apic.go
vendor/gopkg.in/yaml.v2/apic.go
+26
-29
vendor/gopkg.in/yaml.v2/decode.go
vendor/gopkg.in/yaml.v2/decode.go
+165
-75
vendor/gopkg.in/yaml.v2/emitterc.go
vendor/gopkg.in/yaml.v2/emitterc.go
+6
-5
vendor/gopkg.in/yaml.v2/encode.go
vendor/gopkg.in/yaml.v2/encode.go
+96
-40
vendor/gopkg.in/yaml.v2/go.mod
vendor/gopkg.in/yaml.v2/go.mod
+5
-0
vendor/gopkg.in/yaml.v2/readerc.go
vendor/gopkg.in/yaml.v2/readerc.go
+19
-1
vendor/gopkg.in/yaml.v2/resolve.go
vendor/gopkg.in/yaml.v2/resolve.go
+65
-15
vendor/gopkg.in/yaml.v2/scannerc.go
vendor/gopkg.in/yaml.v2/scannerc.go
+7
-22
vendor/gopkg.in/yaml.v2/sorter.go
vendor/gopkg.in/yaml.v2/sorter.go
+9
-0
vendor/gopkg.in/yaml.v2/writerc.go
vendor/gopkg.in/yaml.v2/writerc.go
+1
-64
vendor/gopkg.in/yaml.v2/yaml.go
vendor/gopkg.in/yaml.v2/yaml.go
+117
-8
vendor/gopkg.in/yaml.v2/yamlh.go
vendor/gopkg.in/yaml.v2/yamlh.go
+26
-4
vendor/vendor.json
vendor/vendor.json
+53
-53
No files found.
vendor/git.autistici.org/ai3/go-common/README.md
0 → 100644
View file @
85c333c9
ai3/go-common
===
Common code for ai3 services and tools.
A quick overview of the contents:
*
[
client
](
clientutil/
)
and
[
server
](
serverutil/
)
HTTP-based
"RPC" implementation, just JSON POST requests but with retries,
backoff, timeouts, tracing, etc.
*
[
server implementation of a line-based protocol over a UNIX socket
](
unix/
)
*
a
[
LDAP connection pool
](
ldap/
)
*
a
[
password hashing library
](
pwhash/
)
that uses fancy advanced
crypto by default but is also backwards compatible with old
libc crypto.
*
utilities to
[
manage encryption keys
](
userenckey/
)
, themselves
encrypted with a password and a KDF.
vendor/git.autistici.org/ai3/go-common/clientutil/balancer.go
View file @
85c333c9
...
...
@@ -104,7 +104,10 @@ func (b *balancedBackend) Call(ctx context.Context, shard, path string, req, res
}
var
tg
targetGenerator
=
b
.
backendTracker
if
b
.
sharded
&&
shard
!=
""
{
if
b
.
sharded
{
if
shard
==
""
{
return
fmt
.
Errorf
(
"call without shard to sharded service %s"
,
b
.
baseURI
.
String
())
}
tg
=
newShardedGenerator
(
shard
,
b
.
baseURI
.
Host
,
b
.
resolver
)
}
seq
:=
newSequence
(
tg
)
...
...
vendor/git.autistici.org/ai3/go-common/clientutil/dns.go
View file @
85c333c9
...
...
@@ -40,6 +40,8 @@ type cacheDatum struct {
deadline
time
.
Time
}
var
dnsCacheTTL
=
1
*
time
.
Minute
type
dnsCache
struct
{
resolver
resolver
sf
singleflight
.
Group
...
...
@@ -72,7 +74,7 @@ func (c *dnsCache) update(host string) []string {
c
.
mx
.
Lock
()
c
.
cache
[
host
]
=
cacheDatum
{
addrs
:
addrs
,
deadline
:
time
.
Now
()
.
Add
(
60
*
time
.
Second
),
deadline
:
time
.
Now
()
.
Add
(
dnsCacheTTL
),
}
c
.
mx
.
Unlock
()
return
addrs
,
nil
...
...
vendor/git.autistici.org/ai3/go-common/clientutil/transport.go
View file @
85c333c9
...
...
@@ -7,6 +7,8 @@ import (
"net/http"
"sync"
"time"
"git.autistici.org/ai3/go-common/tracing"
)
// The transportCache is just a cache of http transports, each
...
...
@@ -29,12 +31,12 @@ func newTransportCache(tlsConfig *tls.Config) *transportCache {
}
func
(
m
*
transportCache
)
newTransport
(
addr
string
)
http
.
RoundTripper
{
return
&
http
.
Transport
{
return
tracing
.
WrapTransport
(
&
http
.
Transport
{
TLSClientConfig
:
m
.
tlsConfig
,
DialContext
:
func
(
ctx
context
.
Context
,
network
,
_
string
)
(
net
.
Conn
,
error
)
{
return
netDialContext
(
ctx
,
network
,
addr
)
},
}
}
)
}
func
(
m
*
transportCache
)
getTransport
(
addr
string
)
http
.
RoundTripper
{
...
...
vendor/git.autistici.org/ai3/go-common/clientutil/watcher.go
0 → 100644
View file @
85c333c9
package
clientutil
import
(
"fmt"
"sync"
"time"
)
var
dnsWatcherInterval
=
1
*
time
.
Minute
// A DNSWatcher monitors a DNS name for changes, constantly attempting
// to resolve it every minute and notifying a channel when the list of
// returned IP addresses changes. All addresses must be in host:port
// format.
type
DNSWatcher
struct
{
hostport
string
resolver
resolver
addrs
[]
string
updateCh
chan
[]
string
stopCh
chan
struct
{}
}
// NewDNSWatcher creates a new DNSWatcher.
func
NewDNSWatcher
(
hostport
string
)
(
*
DNSWatcher
,
error
)
{
return
newDNSWatcherWithResolver
(
hostport
,
defaultResolver
)
}
func
newDNSWatcherWithResolver
(
hostport
string
,
resolver
resolver
)
(
*
DNSWatcher
,
error
)
{
// Resolve names once before returning. Return a fatal error
// when there are no results, as it may indicate a syntax
// error in hostport.
addrs
:=
resolver
.
ResolveIP
(
hostport
)
if
len
(
addrs
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"can't resolve %s"
,
hostport
)
}
w
:=
&
DNSWatcher
{
hostport
:
hostport
,
resolver
:
resolver
,
addrs
:
addrs
,
updateCh
:
make
(
chan
[]
string
,
10
),
stopCh
:
make
(
chan
struct
{}),
}
w
.
updateCh
<-
addrs
go
w
.
loop
()
return
w
,
nil
}
// Stop the watcher.
func
(
w
*
DNSWatcher
)
Stop
()
{
close
(
w
.
stopCh
)
}
// Changes returns a channel where the resolved addresses are sent
// whenever they change.
func
(
w
*
DNSWatcher
)
Changes
()
<-
chan
[]
string
{
return
w
.
updateCh
}
func
(
w
*
DNSWatcher
)
check
()
{
addrs
:=
w
.
resolver
.
ResolveIP
(
w
.
hostport
)
if
len
(
addrs
)
>
0
&&
!
addrListEqual
(
addrs
,
w
.
addrs
)
{
w
.
addrs
=
addrs
w
.
updateCh
<-
addrs
}
}
func
(
w
*
DNSWatcher
)
loop
()
{
defer
close
(
w
.
updateCh
)
tick
:=
time
.
NewTicker
(
dnsWatcherInterval
)
defer
tick
.
Stop
()
for
{
select
{
case
<-
tick
.
C
:
w
.
check
()
case
<-
w
.
stopCh
:
return
}
}
}
type
multiDNSUpdate
struct
{
hostport
string
addrs
[]
string
}
// A MultiDNSWatcher watches multiple addresses for DNS changes. The
// results are merged and returned as a list of addresses.
type
MultiDNSWatcher
struct
{
watchers
[]
*
DNSWatcher
addrmap
map
[
string
][]
string
faninCh
chan
multiDNSUpdate
updateCh
chan
[]
string
}
// NewMultiDNSWatcher creates a new MultiDNSWatcher.
func
NewMultiDNSWatcher
(
hostports
[]
string
)
(
*
MultiDNSWatcher
,
error
)
{
return
newMultiDNSWatcherWithResolver
(
hostports
,
defaultResolver
)
}
func
newMultiDNSWatcherWithResolver
(
hostports
[]
string
,
resolver
resolver
)
(
*
MultiDNSWatcher
,
error
)
{
mw
:=
&
MultiDNSWatcher
{
addrmap
:
make
(
map
[
string
][]
string
),
faninCh
:
make
(
chan
multiDNSUpdate
,
10
),
updateCh
:
make
(
chan
[]
string
,
10
),
}
// All the MultiDNSWatcher does is multiplex updates from the
// individual DNSWatchers onto faninCh, then merging those
// updates with all the others and sending the result to
// updateCh.
go
func
()
{
defer
close
(
mw
.
updateCh
)
for
up
:=
range
mw
.
faninCh
{
mw
.
addrmap
[
up
.
hostport
]
=
up
.
addrs
mw
.
updateCh
<-
mw
.
allAddrs
()
}
}()
var
wg
sync
.
WaitGroup
for
_
,
hostport
:=
range
hostports
{
w
,
err
:=
newDNSWatcherWithResolver
(
hostport
,
resolver
)
if
err
!=
nil
{
return
nil
,
err
}
mw
.
watchers
=
append
(
mw
.
watchers
,
w
)
wg
.
Add
(
1
)
go
func
(
hostport
string
)
{
for
addrs
:=
range
w
.
Changes
()
{
mw
.
faninCh
<-
multiDNSUpdate
{
hostport
:
hostport
,
addrs
:
addrs
,
}
}
wg
.
Done
()
}(
hostport
)
}
go
func
()
{
wg
.
Wait
()
close
(
mw
.
faninCh
)
}()
return
mw
,
nil
}
func
(
mw
*
MultiDNSWatcher
)
allAddrs
()
[]
string
{
var
out
[]
string
for
_
,
addrs
:=
range
mw
.
addrmap
{
out
=
append
(
out
,
addrs
...
)
}
return
out
}
// Stop the watcher.
func
(
mw
*
MultiDNSWatcher
)
Stop
()
{
for
_
,
w
:=
range
mw
.
watchers
{
w
.
Stop
()
}
}
// Changes returns a channel where the aggregate resolved addresses
// are sent whenever they change.
func
(
mw
*
MultiDNSWatcher
)
Changes
()
<-
chan
[]
string
{
return
mw
.
updateCh
}
func
addrListEqual
(
a
,
b
[]
string
)
bool
{
if
len
(
a
)
!=
len
(
b
)
{
return
false
}
tmp
:=
make
(
map
[
string
]
struct
{})
for
_
,
aa
:=
range
a
{
tmp
[
aa
]
=
struct
{}{}
}
for
_
,
bb
:=
range
b
{
if
_
,
ok
:=
tmp
[
bb
];
!
ok
{
return
false
}
delete
(
tmp
,
bb
)
}
return
len
(
tmp
)
==
0
}
vendor/git.autistici.org/ai3/go-common/serverutil/http.go
View file @
85c333c9
...
...
@@ -3,16 +3,18 @@ package serverutil
import
(
"context"
"crypto/tls"
"fmt"
"io"
"log"
"net"
"net/http"
"net/http/pprof"
_
"net/http/pprof"
"os"
"os/signal"
"syscall"
"time"
"git.autistici.org/ai3/go-common/tracing"
"github.com/coreos/go-systemd/daemon"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
...
...
@@ -77,6 +79,10 @@ func (config *ServerConfig) buildHTTPServer(h http.Handler) (*http.Server, error
// the listener, otherwise it will handle graceful termination on
// SIGINT or SIGTERM and return nil.
func
Serve
(
h
http
.
Handler
,
config
*
ServerConfig
,
addr
string
)
error
{
// Wrap with tracing handler (exclude metrics and other
// debugging endpoints).
h
=
tracing
.
WrapHandler
(
h
,
guessEndpointName
(
addr
))
// Create the HTTP server.
srv
,
err
:=
config
.
buildHTTPServer
(
h
)
if
err
!=
nil
{
...
...
@@ -115,8 +121,9 @@ func Serve(h http.Handler, config *ServerConfig, addr string) error {
signal
.
Notify
(
sigCh
,
syscall
.
SIGINT
,
syscall
.
SIGTERM
)
// Notify systemd that we are ready to serve.
daemon
.
SdNotify
(
false
,
"READY=1"
)
// Notify systemd that we are ready to serve. This call is
// allowed to fail (in case there is no systemd).
daemon
.
SdNotify
(
false
,
"READY=1"
)
// nolint
err
=
srv
.
Serve
(
l
)
if
err
!=
http
.
ErrServerClosed
{
...
...
@@ -132,14 +139,16 @@ func defaultHandler(h http.Handler) http.Handler {
// Add an endpoint for HTTP health checking probes.
root
.
Handle
(
"/health"
,
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
_
*
http
.
Request
)
{
io
.
WriteString
(
w
,
"OK"
)
io
.
WriteString
(
w
,
"OK"
)
// nolint
}))
// Add an endpoint to serve Prometheus metrics.
root
.
Handle
(
"/metrics"
,
promhttp
.
Handler
())
// Add the net/http/pprof debug handlers.
root
.
Handle
(
"/debug/pprof/"
,
pprof
.
Handler
(
""
))
// Let the default net/http handler deal with /debug/
// URLs. Packages such as net/http/pprof register their
// handlers there in ways that aren't reproducible.
root
.
Handle
(
"/debug/"
,
http
.
DefaultServeMux
)
// Forward everything else to the main handler, adding
// Prometheus instrumentation (requests to /metrics and
...
...
@@ -150,6 +159,18 @@ func defaultHandler(h http.Handler) http.Handler {
return
root
}
func
guessEndpointName
(
addr
string
)
string
{
_
,
port
,
err
:=
net
.
SplitHostPort
(
addr
)
if
err
!=
nil
{
return
addr
}
host
,
err
:=
os
.
Hostname
()
if
err
!=
nil
{
return
addr
}
return
fmt
.
Sprintf
(
"%s:%s"
,
host
,
port
)
}
// HTTP-related metrics.
var
(
// Since we instrument the root HTTP handler, we don't really
...
...
vendor/git.autistici.org/ai3/go-common/serverutil/tls.go
View file @
85c333c9
...
...
@@ -2,6 +2,8 @@ package serverutil
import
(
"crypto/tls"
"fmt"
"log"
"net/http"
"regexp"
...
...
@@ -119,6 +121,13 @@ func (c *TLSServerConfig) TLSAuthWrapper(h http.Handler) (http.Handler, error) {
h
.
ServeHTTP
(
w
,
r
)
return
}
http
.
Error
(
w
,
"Unauthorized"
,
http
.
StatusUnauthorized
)
// Log the failed access, useful for debugging.
var
tlsmsg
string
if
r
.
TLS
!=
nil
&&
len
(
r
.
TLS
.
PeerCertificates
)
>
0
{
tlsmsg
=
fmt
.
Sprintf
(
" TLS client '%s' at"
,
r
.
TLS
.
PeerCertificates
[
0
]
.
Subject
.
CommonName
)
}
log
.
Printf
(
"unauthorized access to %s from %s%s"
,
r
.
URL
.
Path
,
tlsmsg
,
r
.
RemoteAddr
)
http
.
Error
(
w
,
"Forbidden"
,
http
.
StatusForbidden
)
}),
nil
}
vendor/github.com/beorn7/perks/quantile/stream.go
View file @
85c333c9
...
...
@@ -77,15 +77,20 @@ func NewHighBiased(epsilon float64) *Stream {
// is guaranteed to be within (Quantile±Epsilon).
//
// See http://www.cs.rutgers.edu/~muthu/bquant.pdf for time, space, and error properties.
func
NewTargeted
(
targets
map
[
float64
]
float64
)
*
Stream
{
func
NewTargeted
(
targetMap
map
[
float64
]
float64
)
*
Stream
{
// Convert map to slice to avoid slow iterations on a map.
// ƒ is called on the hot path, so converting the map to a slice
// beforehand results in significant CPU savings.
targets
:=
targetMapToSlice
(
targetMap
)
ƒ
:=
func
(
s
*
stream
,
r
float64
)
float64
{
var
m
=
math
.
MaxFloat64
var
f
float64
for
quantile
,
epsilon
:=
range
targets
{
if
quantile
*
s
.
n
<=
r
{
f
=
(
2
*
epsilon
*
r
)
/
quantile
for
_
,
t
:=
range
targets
{
if
t
.
quantile
*
s
.
n
<=
r
{
f
=
(
2
*
t
.
epsilon
*
r
)
/
t
.
quantile
}
else
{
f
=
(
2
*
epsilon
*
(
s
.
n
-
r
))
/
(
1
-
quantile
)
f
=
(
2
*
t
.
epsilon
*
(
s
.
n
-
r
))
/
(
1
-
t
.
quantile
)
}
if
f
<
m
{
m
=
f
...
...
@@ -96,6 +101,25 @@ func NewTargeted(targets map[float64]float64) *Stream {
return
newStream
(
ƒ
)
}
type
target
struct
{
quantile
float64
epsilon
float64
}
func
targetMapToSlice
(
targetMap
map
[
float64
]
float64
)
[]
target
{
targets
:=
make
([]
target
,
0
,
len
(
targetMap
))
for
quantile
,
epsilon
:=
range
targetMap
{
t
:=
target
{
quantile
:
quantile
,
epsilon
:
epsilon
,
}
targets
=
append
(
targets
,
t
)
}
return
targets
}
// Stream computes quantiles for a stream of float64s. It is not thread-safe by
// design. Take care when using across multiple goroutines.
type
Stream
struct
{
...
...
vendor/github.com/cenkalti/backoff/context.go
View file @
85c333c9
...
...
@@ -51,9 +51,13 @@ func (b *backOffContext) Context() context.Context {
func
(
b
*
backOffContext
)
NextBackOff
()
time
.
Duration
{
select
{
case
<-
b
.
Context
()
.
Done
()
:
case
<-
b
.
ctx
.
Done
()
:
return
Stop
default
:
return
b
.
BackOff
.
NextBackOff
()
}
next
:=
b
.
BackOff
.
NextBackOff
()
if
deadline
,
ok
:=
b
.
ctx
.
Deadline
();
ok
&&
deadline
.
Sub
(
time
.
Now
())
<
next
{
return
Stop
}
return
next
}
vendor/github.com/cenkalti/backoff/exponential.go
View file @
85c333c9
...
...
@@ -63,7 +63,6 @@ type ExponentialBackOff struct {
currentInterval
time
.
Duration
startTime
time
.
Time
random
*
rand
.
Rand
}
// Clock is an interface that returns current time for BackOff.
...
...
@@ -89,7 +88,6 @@ func NewExponentialBackOff() *ExponentialBackOff {
MaxInterval
:
DefaultMaxInterval
,
MaxElapsedTime
:
DefaultMaxElapsedTime
,
Clock
:
SystemClock
,
random
:
rand
.
New
(
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
())),
}
b
.
Reset
()
return
b
...
...
@@ -118,10 +116,7 @@ func (b *ExponentialBackOff) NextBackOff() time.Duration {
return
Stop
}
defer
b
.
incrementCurrentInterval
()
if
b
.
random
==
nil
{
b
.
random
=
rand
.
New
(
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
}
return
getRandomValueFromInterval
(
b
.
RandomizationFactor
,
b
.
random
.
Float64
(),
b
.
currentInterval
)
return
getRandomValueFromInterval
(
b
.
RandomizationFactor
,
rand
.
Float64
(),
b
.
currentInterval
)
}
// GetElapsedTime returns the elapsed time since an ExponentialBackOff instance
...
...
vendor/github.com/cenkalti/backoff/retry.go
View file @
85c333c9
...
...
@@ -41,7 +41,7 @@ func RetryNotify(operation Operation, b BackOff, notify Notify) error {
return
permanent
.
Err
}
if
next
=
b
.
NextBackOff
();
next
==
Stop
{
if
next
=
c
b
.
NextBackOff
();
next
==
Stop
{
return
err
}
...
...
vendor/github.com/coreos/go-systemd/NOTICE
0 → 100644
View file @
85c333c9
CoreOS Project
Copyright 2018 CoreOS, Inc
This product includes software developed at CoreOS, Inc.
(http://www.coreos.com/).
vendor/github.com/coreos/go-systemd/daemon/sdnotify.go
View file @
85c333c9
// Copyright 2014 Docker, Inc.
// Copyright 2015-2018 CoreOS, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
@@ -13,7 +14,11 @@
// limitations under the License.
//
// Code forked from Docker project
// Package daemon provides a Go implementation of the sd_notify protocol.
// It can be used to inform systemd of service start-up completion, watchdog
// events, and other status changes.
//
// https://www.freedesktop.org/software/systemd/man/sd_notify.html#Description
package
daemon
import
(
...
...
@@ -21,6 +26,25 @@ import (
"os"
)
const
(
// SdNotifyReady tells the service manager that service startup is finished
// or the service finished loading its configuration.
SdNotifyReady
=
"READY=1"
// SdNotifyStopping tells the service manager that the service is beginning
// its shutdown.
SdNotifyStopping
=
"STOPPING=1"
// SdNotifyReloading tells the service manager that this service is
// reloading its configuration. Note that you must call SdNotifyReady when
// it completed reloading.
SdNotifyReloading
=
"RELOADING=1"
// SdNotifyWatchdog tells the service manager to update the watchdog
// timestamp for the service.
SdNotifyWatchdog
=
"WATCHDOG=1"
)
// SdNotify sends a message to the init daemon. It is common to ignore the error.
// If `unsetEnvironment` is true, the environment variable `NOTIFY_SOCKET`
// will be unconditionally unset.
...
...
@@ -29,7 +53,7 @@ import (
// (false, nil) - notification not supported (i.e. NOTIFY_SOCKET is unset)
// (false, err) - notification supported, but failure happened (e.g. error connecting to NOTIFY_SOCKET or while sending data)
// (true, nil) - notification supported, data has been sent
func
SdNotify
(
unsetEnvironment
bool
,
state
string
)
(
sent
bool
,
err
error
)
{
func
SdNotify
(
unsetEnvironment
bool
,
state
string
)
(
bool
,
error
)
{
socketAddr
:=
&
net
.
UnixAddr
{
Name
:
os
.
Getenv
(
"NOTIFY_SOCKET"
),
Net
:
"unixgram"
,
...
...
@@ -41,10 +65,9 @@ func SdNotify(unsetEnvironment bool, state string) (sent bool, err error) {
}
if
unsetEnvironment
{
err
=
os
.
Unsetenv
(
"NOTIFY_SOCKET"
)
}
if
err
!=
nil
{
return
false
,
err
if
err
:=
os
.
Unsetenv
(
"NOTIFY_SOCKET"
);
err
!=
nil
{
return
false
,
err
}
}
conn
,
err
:=
net
.
DialUnix
(
socketAddr
.
Net
,
nil
,
socketAddr
)
...
...
@@ -54,9 +77,7 @@ func SdNotify(unsetEnvironment bool, state string) (sent bool, err error) {
}
defer
conn
.
Close
()
_
,
err
=
conn
.
Write
([]
byte
(
state
))
// Error sending the message
if
err
!=
nil
{
if
_
,
err
=
conn
.
Write
([]
byte
(
state
));
err
!=
nil
{
return