Compare commits

...

2 Commits

Author SHA1 Message Date
xishang0128
ce4cef0bfd chore: Adjust the error log for the search process 2024-10-11 07:31:49 +08:00
wwqgtxx
08dcef80bf fix: mistaken using net.Dialer
https://github.com/MetaCubeX/mihomo/issues/1572
2024-10-09 12:04:56 +08:00
4 changed files with 6 additions and 33 deletions

View File

@ -131,11 +131,7 @@ func (c *HysteriaOption) Speed() (uint64, uint64, error) {
}
func NewHysteria(option HysteriaOption) (*Hysteria, error) {
clientTransport := &transport.ClientTransport{
Dialer: &net.Dialer{
Timeout: 8 * time.Second,
},
}
clientTransport := &transport.ClientTransport{}
addr := net.JoinHostPort(option.Server, strconv.Itoa(option.Port))
ports := option.Ports

View File

@ -12,6 +12,7 @@ import (
"time"
"github.com/metacubex/mihomo/component/ca"
"github.com/metacubex/mihomo/component/dialer"
"github.com/metacubex/mihomo/listener/inner"
)
@ -71,8 +72,7 @@ func HttpRequestWithProxy(ctx context.Context, url, method string, header map[st
if conn, err := inner.HandleTcp(address, specialProxy); err == nil {
return conn, nil
} else {
d := net.Dialer{}
return d.DialContext(ctx, network, address)
return dialer.DialContext(ctx, network, address)
}
},
TLSClientConfig: ca.GetGlobalTLSConfig(&tls.Config{}),

View File

@ -4,7 +4,6 @@ import (
"crypto/tls"
"fmt"
"net"
"strings"
"time"
"github.com/metacubex/quic-go"
@ -16,9 +15,7 @@ import (
"github.com/metacubex/mihomo/transport/hysteria/utils"
)
type ClientTransport struct {
Dialer *net.Dialer
}
type ClientTransport struct{}
func (ct *ClientTransport) quicPacketConn(proto string, rAddr net.Addr, serverPorts string, obfs obfsPkg.Obfuscator, hopInterval time.Duration, dialer utils.PacketDialer) (net.PacketConn, error) {
server := rAddr.String()
@ -86,23 +83,3 @@ func (ct *ClientTransport) QUICDial(proto string, server string, serverPorts str
}
return qs, nil
}
func (ct *ClientTransport) DialTCP(raddr *net.TCPAddr) (*net.TCPConn, error) {
conn, err := ct.Dialer.Dial("tcp", raddr.String())
if err != nil {
return nil, err
}
return conn.(*net.TCPConn), nil
}
func (ct *ClientTransport) ListenUDP() (*net.UDPConn, error) {
return net.ListenUDP("udp", nil)
}
func isMultiPortAddr(addr string) bool {
_, portStr, err := net.SplitHostPort(addr)
if err == nil && (strings.Contains(portStr, ",") || strings.Contains(portStr, "-")) {
return true
}
return false
}

View File

@ -625,7 +625,7 @@ func match(metadata *C.Metadata) (C.Proxy, C.Rule, error) {
// normal check for process
uid, path, err := P.FindProcessName(metadata.NetWork.String(), metadata.SrcIP, int(metadata.SrcPort))
if err != nil {
log.Debugln("[Process] find process %s error: %v", metadata.String(), err)
log.Debugln("[Process] Find process error for %s: %v", metadata.String(), err)
} else {
metadata.Process = filepath.Base(path)
metadata.ProcessPath = path
@ -639,7 +639,7 @@ func match(metadata *C.Metadata) (C.Proxy, C.Rule, error) {
// check package names
pkg, err := P.FindPackageName(metadata)
if err != nil {
log.Debugln("[Process] find process %s error: %v", metadata.String(), err)
log.Debugln("[Process] Find process error for %s: %v", metadata.String(), err)
} else {
metadata.Process = pkg
}