fix versions and turn off challenges port by default
This commit is contained in:
parent
6810c6f86d
commit
b2d6bb7a08
|
@ -68,8 +68,8 @@ func main() {
|
||||||
"port to listen to (default localhost 3000)")
|
"port to listen to (default localhost 3000)")
|
||||||
flag.StringVar(&lnAddr, "listen", "",
|
flag.StringVar(&lnAddr, "listen", "",
|
||||||
"IPv4 or IPv6 bind address + port (instead of --port)")
|
"IPv4 or IPv6 bind address + port (instead of --port)")
|
||||||
flag.StringVar(&challengesPort, "challenges-port", "80",
|
flag.StringVar(&challengesPort, "challenges-port", "",
|
||||||
"port to use to respond to .well-known/acme-challenge tokens")
|
"port to use to respond to .well-known/acme-challenge tokens (should be 80, if used)")
|
||||||
flag.StringVar(&dbURL, "db-url", "postgres://postgres:postgres@localhost:5432/postgres",
|
flag.StringVar(&dbURL, "db-url", "postgres://postgres:postgres@localhost:5432/postgres",
|
||||||
"database (postgres) connection url")
|
"database (postgres) connection url")
|
||||||
flag.StringVar(&secret, "secret", "",
|
flag.StringVar(&secret, "secret", "",
|
||||||
|
@ -161,6 +161,7 @@ func main() {
|
||||||
|
|
||||||
mgmt.Init(store, provider)
|
mgmt.Init(store, provider)
|
||||||
|
|
||||||
|
if len(challengesPort) > 0 {
|
||||||
go func() {
|
go func() {
|
||||||
fmt.Println("Listening for ACME challenges on :" + challengesPort)
|
fmt.Println("Listening for ACME challenges on :" + challengesPort)
|
||||||
r := chi.NewRouter()
|
r := chi.NewRouter()
|
||||||
|
@ -175,9 +176,18 @@ func main() {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Println("Listening on", lnAddr)
|
fmt.Println("Listening on", lnAddr)
|
||||||
fmt.Fprintf(os.Stderr, "failed: %s", http.ListenAndServe(lnAddr, mgmt.RouteAll()))
|
r := chi.NewRouter()
|
||||||
|
r.Get("/version", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.Write([]byte(ver() + "\n"))
|
||||||
|
})
|
||||||
|
r.Get("/api/version", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.Write([]byte("TODO (json): " + ver() + "\n"))
|
||||||
|
})
|
||||||
|
mgmt.RouteAll(r)
|
||||||
|
fmt.Fprintf(os.Stderr, "failed: %s", http.ListenAndServe(lnAddr, r))
|
||||||
}
|
}
|
||||||
|
|
||||||
// newNameDotComDNSProvider is for the sake of demoing the tunnel
|
// newNameDotComDNSProvider is for the sake of demoing the tunnel
|
||||||
|
|
|
@ -53,7 +53,7 @@ func getACMEChallenges(w http.ResponseWriter, r *http.Request) {
|
||||||
fsrv.ServeHTTP(w, r)
|
fsrv.ServeHTTP(w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RouteAll() chi.Router {
|
func RouteAll(r chi.Router) {
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
|
@ -74,7 +74,7 @@ func RouteAll() chi.Router {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
r := chi.NewRouter()
|
r.Route("/", func(r chi.Router) {
|
||||||
r.Use(middleware.Logger)
|
r.Use(middleware.Logger)
|
||||||
r.Use(middleware.Timeout(15 * time.Second))
|
r.Use(middleware.Timeout(15 * time.Second))
|
||||||
r.Use(middleware.Recoverer)
|
r.Use(middleware.Recoverer)
|
||||||
|
@ -288,6 +288,5 @@ func RouteAll() chi.Router {
|
||||||
w.Write([]byte("Hello\n"))
|
w.Write([]byte("Hello\n"))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
})
|
||||||
return r
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue