mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 19:56:51 +08:00
fix: tfo not working with smux/yamux
This commit is contained in:
parent
1025101954
commit
9bd70e1366
|
@ -15,6 +15,11 @@ import (
|
||||||
"github.com/metacubex/mihomo/constant/features"
|
"github.com/metacubex/mihomo/constant/features"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
DefaultTCPTimeout = 5 * time.Second
|
||||||
|
DefaultUDPTimeout = DefaultTCPTimeout
|
||||||
|
)
|
||||||
|
|
||||||
type dialFunc func(ctx context.Context, network string, ips []netip.Addr, port string, opt *option) (net.Conn, error)
|
type dialFunc func(ctx context.Context, network string, ips []netip.Addr, port string, opt *option) (net.Conn, error)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -2,10 +2,11 @@ package dialer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/sagernet/tfo-go"
|
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/sagernet/tfo-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
type tfoConn struct {
|
type tfoConn struct {
|
||||||
|
@ -66,14 +67,14 @@ func (c *tfoConn) Close() error {
|
||||||
|
|
||||||
func (c *tfoConn) LocalAddr() net.Addr {
|
func (c *tfoConn) LocalAddr() net.Addr {
|
||||||
if c.Conn == nil {
|
if c.Conn == nil {
|
||||||
return nil
|
return &net.TCPAddr{}
|
||||||
}
|
}
|
||||||
return c.Conn.LocalAddr()
|
return c.Conn.LocalAddr()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *tfoConn) RemoteAddr() net.Addr {
|
func (c *tfoConn) RemoteAddr() net.Addr {
|
||||||
if c.Conn == nil {
|
if c.Conn == nil {
|
||||||
return nil
|
return &net.TCPAddr{}
|
||||||
}
|
}
|
||||||
return c.Conn.RemoteAddr()
|
return c.Conn.RemoteAddr()
|
||||||
}
|
}
|
||||||
|
@ -123,7 +124,7 @@ func (c *tfoConn) WriterReplaceable() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func dialTFO(ctx context.Context, netDialer net.Dialer, network, address string) (net.Conn, error) {
|
func dialTFO(ctx context.Context, netDialer net.Dialer, network, address string) (net.Conn, error) {
|
||||||
ctx, cancel := context.WithCancel(ctx)
|
ctx, cancel := context.WithTimeout(context.Background(), DefaultTCPTimeout)
|
||||||
dialer := tfo.Dialer{Dialer: netDialer, DisableTFO: false}
|
dialer := tfo.Dialer{Dialer: netDialer, DisableTFO: false}
|
||||||
return &tfoConn{
|
return &tfoConn{
|
||||||
dialed: make(chan bool, 1),
|
dialed: make(chan bool, 1),
|
||||||
|
|
|
@ -43,9 +43,9 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DefaultTCPTimeout = 5 * time.Second
|
DefaultTCPTimeout = dialer.DefaultTCPTimeout
|
||||||
|
DefaultUDPTimeout = dialer.DefaultUDPTimeout
|
||||||
DefaultDropTime = 12 * DefaultTCPTimeout
|
DefaultDropTime = 12 * DefaultTCPTimeout
|
||||||
DefaultUDPTimeout = DefaultTCPTimeout
|
|
||||||
DefaultTLSTimeout = DefaultTCPTimeout
|
DefaultTLSTimeout = DefaultTCPTimeout
|
||||||
DefaultTestURL = "https://www.gstatic.com/generate_204"
|
DefaultTestURL = "https://www.gstatic.com/generate_204"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user