tun2: avoid intN panic
This commit is contained in:
parent
aa16ea5e26
commit
1c221cdf6d
|
@ -365,7 +365,7 @@ func (s *Server) RoundTrip(req *http.Request) (*http.Response, error) {
|
|||
val, ok := s.domains.Get(req.Host)
|
||||
if ok {
|
||||
conns, ok = val.([]*Connection)
|
||||
if !ok || len(conns) == 0 {
|
||||
if !ok {
|
||||
ln.Error(errors.New("no backend connected"), ln.F{
|
||||
"action": "no_backend_connected",
|
||||
"remote": req.RemoteAddr,
|
||||
|
@ -385,6 +385,10 @@ func (s *Server) RoundTrip(req *http.Request) (*http.Response, error) {
|
|||
}
|
||||
}
|
||||
|
||||
if len(conns) == 0 {
|
||||
return nil, errors.New("no backend connected")
|
||||
}
|
||||
|
||||
c := conns[rand.Intn(len(conns))]
|
||||
|
||||
stream, err := c.session.OpenStream()
|
||||
|
|
Loading…
Reference in New Issue