mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
fix: mistaken using net.Dialer
Some checks failed
Trigger CMFA Update / trigger-CMFA-update (push) Has been cancelled
Some checks failed
Trigger CMFA Update / trigger-CMFA-update (push) Has been cancelled
https://github.com/MetaCubeX/mihomo/issues/1572
This commit is contained in:
parent
9fd63fe938
commit
08dcef80bf
|
@ -131,11 +131,7 @@ func (c *HysteriaOption) Speed() (uint64, uint64, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHysteria(option HysteriaOption) (*Hysteria, error) {
|
func NewHysteria(option HysteriaOption) (*Hysteria, error) {
|
||||||
clientTransport := &transport.ClientTransport{
|
clientTransport := &transport.ClientTransport{}
|
||||||
Dialer: &net.Dialer{
|
|
||||||
Timeout: 8 * time.Second,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
addr := net.JoinHostPort(option.Server, strconv.Itoa(option.Port))
|
addr := net.JoinHostPort(option.Server, strconv.Itoa(option.Port))
|
||||||
ports := option.Ports
|
ports := option.Ports
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/metacubex/mihomo/component/ca"
|
"github.com/metacubex/mihomo/component/ca"
|
||||||
|
"github.com/metacubex/mihomo/component/dialer"
|
||||||
"github.com/metacubex/mihomo/listener/inner"
|
"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 {
|
if conn, err := inner.HandleTcp(address, specialProxy); err == nil {
|
||||||
return conn, nil
|
return conn, nil
|
||||||
} else {
|
} else {
|
||||||
d := net.Dialer{}
|
return dialer.DialContext(ctx, network, address)
|
||||||
return d.DialContext(ctx, network, address)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
TLSClientConfig: ca.GetGlobalTLSConfig(&tls.Config{}),
|
TLSClientConfig: ca.GetGlobalTLSConfig(&tls.Config{}),
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/metacubex/quic-go"
|
"github.com/metacubex/quic-go"
|
||||||
|
@ -16,9 +15,7 @@ import (
|
||||||
"github.com/metacubex/mihomo/transport/hysteria/utils"
|
"github.com/metacubex/mihomo/transport/hysteria/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ClientTransport struct {
|
type ClientTransport struct{}
|
||||||
Dialer *net.Dialer
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ct *ClientTransport) quicPacketConn(proto string, rAddr net.Addr, serverPorts string, obfs obfsPkg.Obfuscator, hopInterval time.Duration, dialer utils.PacketDialer) (net.PacketConn, error) {
|
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()
|
server := rAddr.String()
|
||||||
|
@ -86,23 +83,3 @@ func (ct *ClientTransport) QUICDial(proto string, server string, serverPorts str
|
||||||
}
|
}
|
||||||
return qs, nil
|
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
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user