mirror of
https://github.com/cmz0228/hysteria-dev.git
synced 2025-07-25 04:48:11 +00:00
feat: add quic_settings into client config
fix: #420 allow user to disable auto reconnect when quic disconnected, along with quic handshake & idle timeout. an extra failed request would be required to make the client exit in case of quic disconnected, but i don't think this would be a problem in the common usage.
This commit is contained in:
@@ -44,11 +44,13 @@ type Client struct {
|
||||
udpSessionMutex sync.RWMutex
|
||||
udpSessionMap map[uint32]chan *udpMessage
|
||||
udpDefragger defragger
|
||||
|
||||
quicReconnectFunc func(err error)
|
||||
}
|
||||
|
||||
func NewClient(serverAddr string, protocol string, auth []byte, tlsConfig *tls.Config, quicConfig *quic.Config,
|
||||
transport *transport.ClientTransport, sendBPS uint64, recvBPS uint64, congestionFactory CongestionFactory,
|
||||
obfuscator obfs.Obfuscator,
|
||||
obfuscator obfs.Obfuscator, quicReconnectFunc func(err error),
|
||||
) (*Client, error) {
|
||||
quicConfig.DisablePathMTUDiscovery = quicConfig.DisablePathMTUDiscovery || pmtud_fix.DisablePathMTUDiscovery
|
||||
c := &Client{
|
||||
@@ -62,6 +64,7 @@ func NewClient(serverAddr string, protocol string, auth []byte, tlsConfig *tls.C
|
||||
obfuscator: obfuscator,
|
||||
tlsConfig: tlsConfig,
|
||||
quicConfig: quicConfig,
|
||||
quicReconnectFunc: quicReconnectFunc,
|
||||
}
|
||||
if err := c.connectToServer(); err != nil {
|
||||
return nil, err
|
||||
@@ -173,6 +176,7 @@ func (c *Client) openStreamWithReconnect() (quic.Connection, quic.Stream, error)
|
||||
// Temporary error, just return
|
||||
return nil, nil, err
|
||||
}
|
||||
c.quicReconnectFunc(err)
|
||||
// Permanent error, need to reconnect
|
||||
if err := c.connectToServer(); err != nil {
|
||||
// Still error, oops
|
||||
|
Reference in New Issue
Block a user