mirror of
https://github.com/cedar2025/hysteria.git
synced 2025-08-09 19:01:50 +00:00
feat: client handshake info
This commit is contained in:
@@ -12,13 +12,14 @@ import (
|
||||
type reconnectableClientImpl struct {
|
||||
config *Config
|
||||
client Client
|
||||
info *HandshakeInfo
|
||||
count int
|
||||
connectedFunc func(Client, int) // called when successfully connected
|
||||
connectedFunc func(Client, *HandshakeInfo, int) // called when successfully connected
|
||||
m sync.Mutex
|
||||
closed bool // permanent close
|
||||
}
|
||||
|
||||
func NewReconnectableClient(config *Config, connectedFunc func(Client, int), lazy bool) (Client, error) {
|
||||
func NewReconnectableClient(config *Config, connectedFunc func(Client, *HandshakeInfo, int), lazy bool) (Client, error) {
|
||||
// Make sure we capture any error in config and return it here,
|
||||
// so that the caller doesn't have to wait until the first call
|
||||
// to TCP() or UDP() to get the error (when lazy is true).
|
||||
@@ -42,13 +43,13 @@ func (rc *reconnectableClientImpl) reconnect() error {
|
||||
_ = rc.client.Close()
|
||||
}
|
||||
var err error
|
||||
rc.client, err = NewClient(rc.config)
|
||||
rc.client, rc.info, err = NewClient(rc.config)
|
||||
if err != nil {
|
||||
return err
|
||||
} else {
|
||||
rc.count++
|
||||
if rc.connectedFunc != nil {
|
||||
rc.connectedFunc(rc, rc.count)
|
||||
rc.connectedFunc(rc, rc.info, rc.count)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user