Skip to content

Commit cbd821b

Browse files
committed
use http-001 challenge
1 parent 9f61005 commit cbd821b

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

main.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ func main() {
1919
UserAgent: "https://github.com/alash3al/httpsify",
2020
}
2121

22+
httpChallengeHandler := e.AutoTLSManager.HTTPHandler(nil)
23+
2224
e.Use(middleware.HTTPSRedirect())
2325
e.Use(middleware.Logger())
2426
e.Use(middleware.Recover())
@@ -27,12 +29,22 @@ func main() {
2729
if *flagSendXSecuredBy {
2830
c.Response().Header().Set("X-Secured-By", "https://github.com/alash3al/httpsify")
2931
}
30-
return next(c)
32+
33+
if !c.IsTLS() {
34+
return echo.WrapHandler(httpChallengeHandler)(c)
35+
}
36+
37+
hosts := hosts.Load().(map[string]*echo.Echo)
38+
host := hosts[c.Request().Host]
39+
40+
if host == nil {
41+
return echo.ErrNotFound
42+
}
43+
44+
return echo.WrapHandler(host)(c)
3145
}
3246
})
3347

34-
e.Any("/*", handler)
35-
3648
errChan := make(chan error)
3749

3850
go (func() {

0 commit comments

Comments
 (0)