Skip to content

Commit

Permalink
fix: mistaken using net.Dialer
Browse files Browse the repository at this point in the history
  • Loading branch information
wwqgtxx committed Oct 9, 2024
1 parent 9fd63fe commit 08dcef8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 31 deletions.
6 changes: 1 addition & 5 deletions adapter/outbound/hysteria.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions component/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"time"

"github.com/metacubex/mihomo/component/ca"
"github.com/metacubex/mihomo/component/dialer"
"github.com/metacubex/mihomo/listener/inner"
)

Expand Down Expand Up @@ -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{}),
Expand Down
25 changes: 1 addition & 24 deletions transport/hysteria/transport/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"crypto/tls"
"fmt"
"net"
"strings"
"time"

"github.com/metacubex/quic-go"
Expand All @@ -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()
Expand Down Expand Up @@ -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
}

0 comments on commit 08dcef8

Please sign in to comment.