зеркало из https://github.com/golang/build.git
cmd/pubsubhelper, maintner/maintnerd: enable HTTP ACME challenges
Updates golang/go#23627 Change-Id: Iaf24b403e12266e7c426bf6311b7f20f9cc6df83 Reviewed-on: https://go-review.googlesource.com/90915 Reviewed-by: Andrew Bonventre <andybons@golang.org>
This commit is contained in:
Родитель
7a0c634c6c
Коммит
c4be133125
|
@ -6,8 +6,8 @@ LABEL maintainer "golang-dev@googlegroups.com"
|
|||
|
||||
# BEGIN deps (run `make update-deps` to update)
|
||||
|
||||
# Repo cloud.google.com/go at 76d607c (2017-07-20)
|
||||
ENV REV=76d607c4e7a2b9df49f1d1a58a3f3d2dd2614704
|
||||
# Repo cloud.google.com/go at 1d0c2da (2018-01-30)
|
||||
ENV REV=1d0c2da40456a9b47f5376165f275424acc15c09
|
||||
RUN go get -d cloud.google.com/go/compute/metadata &&\
|
||||
(cd /go/src/cloud.google.com/go && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
|
||||
|
||||
|
@ -26,13 +26,13 @@ ENV REV=034d17a462f7b2dcd1a4a73553ec5357ff6e6c6e
|
|||
RUN go get -d go4.org/types &&\
|
||||
(cd /go/src/go4.org && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
|
||||
|
||||
# Repo golang.org/x/crypto at 94c6142 (2017-07-20)
|
||||
ENV REV=94c6142ae57b8dc154f6e1813c921a6c85f505cd
|
||||
# Repo golang.org/x/crypto at 1875d0a (2018-01-27)
|
||||
ENV REV=1875d0a70c90e57f11972aefd42276df65e895b9
|
||||
RUN go get -d golang.org/x/crypto/acme `#and 2 other pkgs` &&\
|
||||
(cd /go/src/golang.org/x/crypto && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
|
||||
|
||||
# Repo golang.org/x/net at ab54850 (2017-07-21)
|
||||
ENV REV=ab5485076ff3407ad2d02db054635913f017b0ed
|
||||
# Repo golang.org/x/net at 0ed95ab (2018-01-24)
|
||||
ENV REV=0ed95abb35c445290478a5348a7b38bb154135fd
|
||||
RUN go get -d golang.org/x/net/context `#and 2 other pkgs` &&\
|
||||
(cd /go/src/golang.org/x/net && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
|
||||
|
||||
|
|
|
@ -70,14 +70,14 @@ func main() {
|
|||
err := s.ListenAndServe()
|
||||
errc <- fmt.Errorf("SMTP ListenAndServe: %v", err)
|
||||
}()
|
||||
m := &autocert.Manager{
|
||||
Prompt: autocert.AcceptTOS,
|
||||
HostPolicy: autocert.HostWhitelist(*acmeDomain),
|
||||
}
|
||||
go func() {
|
||||
if *acmeDomain == "" {
|
||||
return
|
||||
}
|
||||
m := autocert.Manager{
|
||||
Prompt: autocert.AcceptTOS,
|
||||
HostPolicy: autocert.HostWhitelist(*acmeDomain),
|
||||
}
|
||||
if _, err := os.Stat("/autocert-cache"); err == nil {
|
||||
m.Cache = autocert.DirCache("/autocert-cache")
|
||||
} else {
|
||||
|
@ -101,6 +101,7 @@ func main() {
|
|||
ReadHeaderTimeout: 10 * time.Second,
|
||||
WriteTimeout: 5 * time.Minute,
|
||||
IdleTimeout: 5 * time.Minute,
|
||||
Handler: m.HTTPHandler(http.DefaultServeMux),
|
||||
}
|
||||
err := s.ListenAndServe()
|
||||
errc <- fmt.Errorf("HTTP ListenAndServe: %v", err)
|
||||
|
|
|
@ -6,18 +6,18 @@ LABEL maintainer "golang-dev@googlegroups.com"
|
|||
|
||||
# BEGIN deps (run `make update-deps` to update)
|
||||
|
||||
# Repo cloud.google.com/go at 2d3a665 (2017-11-01)
|
||||
ENV REV=2d3a6656c17a60b0815b7e06ab0be04eacb6e613
|
||||
# Repo cloud.google.com/go at 1d0c2da (2018-01-30)
|
||||
ENV REV=1d0c2da40456a9b47f5376165f275424acc15c09
|
||||
RUN go get -d cloud.google.com/go/compute/metadata `#and 6 other pkgs` &&\
|
||||
(cd /go/src/cloud.google.com/go && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
|
||||
|
||||
# Repo github.com/golang/protobuf at 1e59b77 (2017-11-13)
|
||||
ENV REV=1e59b77b52bf8e4b449a57e6f79f21226d571845
|
||||
# Repo github.com/golang/protobuf at 9255415 (2018-01-25)
|
||||
ENV REV=925541529c1fa6821df4e44ce2723319eb2be768
|
||||
RUN go get -d github.com/golang/protobuf/proto `#and 6 other pkgs` &&\
|
||||
(cd /go/src/github.com/golang/protobuf && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
|
||||
|
||||
# Repo github.com/google/go-github at a89ea1c (2017-11-25)
|
||||
ENV REV=a89ea1cdf79929726a9416663609269ada774da0
|
||||
# Repo github.com/google/go-github at 897969c (2018-01-30)
|
||||
ENV REV=897969cdc831052c4694e205e24a033fe7248c2f
|
||||
RUN go get -d github.com/google/go-github/github &&\
|
||||
(cd /go/src/github.com/google/go-github && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
|
||||
|
||||
|
@ -41,18 +41,18 @@ ENV REV=034d17a462f7b2dcd1a4a73553ec5357ff6e6c6e
|
|||
RUN go get -d go4.org/types &&\
|
||||
(cd /go/src/go4.org && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
|
||||
|
||||
# Repo golang.org/x/crypto at 94eea52 (2017-11-28)
|
||||
ENV REV=94eea52f7b742c7cbe0b03b22f0c4c8631ece122
|
||||
# Repo golang.org/x/crypto at 1875d0a (2018-01-27)
|
||||
ENV REV=1875d0a70c90e57f11972aefd42276df65e895b9
|
||||
RUN go get -d golang.org/x/crypto/acme `#and 2 other pkgs` &&\
|
||||
(cd /go/src/golang.org/x/crypto && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
|
||||
|
||||
# Repo golang.org/x/net at 6921abc (2017-11-28)
|
||||
ENV REV=6921abc35dffd00438a0c020584ce560108737ea
|
||||
# Repo golang.org/x/net at 0ed95ab (2018-01-24)
|
||||
ENV REV=0ed95abb35c445290478a5348a7b38bb154135fd
|
||||
RUN go get -d golang.org/x/net/context `#and 8 other pkgs` &&\
|
||||
(cd /go/src/golang.org/x/net && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
|
||||
|
||||
# Repo golang.org/x/oauth2 at f95fa95 (2017-11-17)
|
||||
ENV REV=f95fa95eaa936d9d87489b15d1d18b97c1ba9c28
|
||||
# Repo golang.org/x/oauth2 at 30785a2 (2018-01-04)
|
||||
ENV REV=30785a2c434e431ef7c507b54617d6a951d5f2b4
|
||||
RUN go get -d golang.org/x/oauth2 `#and 5 other pkgs` &&\
|
||||
(cd /go/src/golang.org/x/oauth2 && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
|
||||
|
||||
|
@ -61,24 +61,24 @@ ENV REV=fd80eb99c8f653c847d294a001bdf2a3a6f768f5
|
|||
RUN go get -d golang.org/x/sync/errgroup &&\
|
||||
(cd /go/src/golang.org/x/sync && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
|
||||
|
||||
# Repo golang.org/x/text at 572a2b1 (2017-11-28)
|
||||
ENV REV=572a2b141f625f4360cf42a41a43622067e0510b
|
||||
# Repo golang.org/x/text at e19ae14 (2017-12-27)
|
||||
ENV REV=e19ae1496984b1c655b8044a65c0300a3c878dd3
|
||||
RUN go get -d golang.org/x/text/secure/bidirule `#and 4 other pkgs` &&\
|
||||
(cd /go/src/golang.org/x/text && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
|
||||
|
||||
# Repo google.golang.org/api at b804618 (2017-11-25)
|
||||
ENV REV=b804618854e387dc7fdd9e50496183ddcbb4b120
|
||||
# Repo google.golang.org/api at 7d0e2d3 (2018-01-30)
|
||||
ENV REV=7d0e2d350555821bef5a5b8aecf0d12cc1def633
|
||||
RUN go get -d google.golang.org/api/gensupport `#and 9 other pkgs` &&\
|
||||
(cd /go/src/google.golang.org/api && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
|
||||
|
||||
# Repo google.golang.org/genproto at 7f0da29 (2017-11-23)
|
||||
ENV REV=7f0da29060c682909f650ad8ed4e515bd74fa12a
|
||||
# Repo google.golang.org/genproto at 4eb30f4 (2018-01-25)
|
||||
ENV REV=4eb30f4778eed4c258ba66527a0d4f9ec8a36c45
|
||||
RUN go get -d google.golang.org/genproto/googleapis/api/annotations `#and 3 other pkgs` &&\
|
||||
(cd /go/src/google.golang.org/genproto && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
|
||||
|
||||
# Repo google.golang.org/grpc at 1e1a47f (2017-11-28)
|
||||
ENV REV=1e1a47f0f28f70686674869a7dee0f1096d86919
|
||||
RUN go get -d google.golang.org/grpc `#and 22 other pkgs` &&\
|
||||
# Repo google.golang.org/grpc at 0bd008f (2018-01-25)
|
||||
ENV REV=0bd008f5fadb62d228f12b18d016709e8139a7af
|
||||
RUN go get -d google.golang.org/grpc `#and 23 other pkgs` &&\
|
||||
(cd /go/src/google.golang.org/grpc && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
|
||||
|
||||
# Repo grpc.go4.org at 11d0a25 (2017-06-09)
|
||||
|
@ -138,11 +138,13 @@ RUN go install cloud.google.com/go/compute/metadata \
|
|||
google.golang.org/genproto/googleapis/rpc/status \
|
||||
google.golang.org/grpc \
|
||||
google.golang.org/grpc/balancer \
|
||||
google.golang.org/grpc/balancer/base \
|
||||
google.golang.org/grpc/balancer/roundrobin \
|
||||
google.golang.org/grpc/codes \
|
||||
google.golang.org/grpc/connectivity \
|
||||
google.golang.org/grpc/credentials \
|
||||
google.golang.org/grpc/encoding \
|
||||
google.golang.org/grpc/encoding/proto \
|
||||
google.golang.org/grpc/grpclb/grpc_lb_v1/messages \
|
||||
google.golang.org/grpc/grpclog \
|
||||
google.golang.org/grpc/internal \
|
||||
|
@ -152,7 +154,6 @@ RUN go install cloud.google.com/go/compute/metadata \
|
|||
google.golang.org/grpc/peer \
|
||||
google.golang.org/grpc/resolver \
|
||||
google.golang.org/grpc/resolver/dns \
|
||||
google.golang.org/grpc/resolver/manual \
|
||||
google.golang.org/grpc/resolver/passthrough \
|
||||
google.golang.org/grpc/stats \
|
||||
google.golang.org/grpc/status \
|
||||
|
|
|
@ -72,8 +72,26 @@ Maintner is short for "maintainer."
|
|||
}
|
||||
}
|
||||
|
||||
var autocertManager *autocert.Manager
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
if *autocertDomain != "" {
|
||||
if *autocertBucket == "" {
|
||||
log.Fatalf("using --autocert requires --autocert-bucket.")
|
||||
}
|
||||
sc, err := storage.NewClient(context.Background())
|
||||
if err != nil {
|
||||
log.Fatalf("Creating autocert cache, storage.NewClient: %v", err)
|
||||
}
|
||||
autocertManager = &autocert.Manager{
|
||||
Prompt: autocert.AcceptTOS,
|
||||
HostPolicy: autocert.HostWhitelist(*autocertDomain),
|
||||
Cache: autocertcache.NewGoogleCloudStorageCache(sc, *autocertBucket),
|
||||
}
|
||||
}
|
||||
|
||||
if *dataDir == "" {
|
||||
*dataDir = filepath.Join(os.Getenv("HOME"), "var", "maintnerd")
|
||||
if *bucket == "" {
|
||||
|
@ -256,7 +274,11 @@ func main() {
|
|||
go func() { errc <- fmt.Errorf("Corpus.SyncLoop = %v", corpus.SyncLoop(ctx)) }()
|
||||
}
|
||||
if ln != nil {
|
||||
go func() { errc <- fmt.Errorf("http.Serve = %v", http.Serve(ln, nil)) }()
|
||||
var handler http.Handler = http.DefaultServeMux
|
||||
if autocertManager != nil {
|
||||
handler = autocertManager.HTTPHandler(handler)
|
||||
}
|
||||
go func() { errc <- fmt.Errorf("http.Serve = %v", http.Serve(ln, handler)) }()
|
||||
}
|
||||
if *autocertDomain != "" {
|
||||
go func() { errc <- serveAutocertTLS() }()
|
||||
|
@ -355,17 +377,8 @@ func serveAutocertTLS() error {
|
|||
return err
|
||||
}
|
||||
defer ln.Close()
|
||||
sc, err := storage.NewClient(context.Background())
|
||||
if err != nil {
|
||||
return fmt.Errorf("storage.NewClient: %v", err)
|
||||
}
|
||||
m := autocert.Manager{
|
||||
Prompt: autocert.AcceptTOS,
|
||||
HostPolicy: autocert.HostWhitelist(*autocertDomain),
|
||||
Cache: autocertcache.NewGoogleCloudStorageCache(sc, *autocertBucket),
|
||||
}
|
||||
config := &tls.Config{
|
||||
GetCertificate: m.GetCertificate,
|
||||
GetCertificate: autocertManager.GetCertificate,
|
||||
NextProtos: []string{"h2", "http/1.1"},
|
||||
}
|
||||
tlsLn := tls.NewListener(tcpKeepAliveListener{ln.(*net.TCPListener)}, config)
|
||||
|
|
Загрузка…
Ссылка в новой задаче