optimize(routing): fix slow domain++ ip routing (#133)

This commit is contained in:
mzz
2023-06-11 12:48:52 +08:00
committed by GitHub
parent e885e76adf
commit 40b553edc9
7 changed files with 82 additions and 70 deletions

View File

@ -6,10 +6,12 @@
package dialer
import (
"bytes"
"context"
"errors"
"fmt"
"github.com/daeuniverse/dae/common"
"io"
"net"
"net/http"
"net/netip"
@ -580,6 +582,10 @@ func (d *Dialer) HttpCheck(ctx context.Context, u *netutils.URL, ip netip.Addr,
// Judge the status code.
if page := path.Base(req.URL.Path); strings.HasPrefix(page, "generate_") {
if strconv.Itoa(resp.StatusCode) != strings.TrimPrefix(page, "generate_") {
b, _ := io.ReadAll(resp.Body)
buf := bytes.NewBuffer(nil)
_ = resp.Request.Write(buf)
d.Log.Debugln(buf.String(), "Resp: ", string(b))
return false, fmt.Errorf("unexpected status code: %v", resp.StatusCode)
}
return true, nil