fix http response code when forwarder node is not available
This commit is contained in:
@ -338,6 +338,9 @@ func chainGroup(name string, group *config.ChainGroupConfig) chain.Chainer {
|
||||
}
|
||||
sel = parseChainSelector(group.Selector)
|
||||
}
|
||||
if len(chains) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
if sel == nil {
|
||||
sel = defaultChainSelector()
|
||||
|
2
go.mod
2
go.mod
@ -7,7 +7,7 @@ require (
|
||||
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d
|
||||
github.com/gin-contrib/cors v1.3.1
|
||||
github.com/gin-gonic/gin v1.8.2
|
||||
github.com/go-gost/core v0.0.0-20230131053758-ff3b77ac2899
|
||||
github.com/go-gost/core v0.0.0-20230131100536-f3482d7cd848
|
||||
github.com/go-gost/gosocks4 v0.0.1
|
||||
github.com/go-gost/gosocks5 v0.3.1-0.20211109033403-d894d75b7f09
|
||||
github.com/go-gost/relay v0.3.1
|
||||
|
4
go.sum
4
go.sum
@ -91,8 +91,8 @@ github.com/gin-gonic/gin v1.8.2/go.mod h1:qw5AYuDrzRTnhvusDsrov+fDIxp9Dleuu12h8n
|
||||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-gost/core v0.0.0-20230131053758-ff3b77ac2899 h1:Ofa8D9NViX+biyS3oUPgIzAjYD6i71abRGalX/0Den4=
|
||||
github.com/go-gost/core v0.0.0-20230131053758-ff3b77ac2899/go.mod h1:R08B7BVdhWsYHX8s7wkEBpeKqc4+YFP6bLLFoao0J/A=
|
||||
github.com/go-gost/core v0.0.0-20230131100536-f3482d7cd848 h1:jAack881fzd5s1jNC5w9SK1gL3bvnh4iK1lMFPnjUw8=
|
||||
github.com/go-gost/core v0.0.0-20230131100536-f3482d7cd848/go.mod h1:R08B7BVdhWsYHX8s7wkEBpeKqc4+YFP6bLLFoao0J/A=
|
||||
github.com/go-gost/gosocks4 v0.0.1 h1:+k1sec8HlELuQV7rWftIkmy8UijzUt2I6t+iMPlGB2s=
|
||||
github.com/go-gost/gosocks4 v0.0.1/go.mod h1:3B6L47HbU/qugDg4JnoFPHgJXE43Inz8Bah1QaN9qCc=
|
||||
github.com/go-gost/gosocks5 v0.3.1-0.20211109033403-d894d75b7f09 h1:A95M6UWcfZgOuJkQ7QLfG0Hs5peWIUSysCDNz4pfe04=
|
||||
|
@ -181,6 +181,7 @@ func (h *forwardHandler) handleHTTP(ctx context.Context, rw io.ReadWriter, log l
|
||||
}
|
||||
if target == nil {
|
||||
log.Warnf("node for %s not found", req.Host)
|
||||
resp.StatusCode = http.StatusBadGateway
|
||||
return resp.Write(rw)
|
||||
}
|
||||
|
||||
|
@ -181,6 +181,7 @@ func (h *forwardHandler) handleHTTP(ctx context.Context, rw io.ReadWriter, log l
|
||||
}
|
||||
if target == nil {
|
||||
log.Warnf("node for %s not found", req.Host)
|
||||
resp.StatusCode = http.StatusBadGateway
|
||||
return resp.Write(rw)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user