mirror of
https://github.com/SagerNet/sing-shadowtls.git
synced 2025-04-01 19:27:36 +03:00
Make tls handshake func optional
This commit is contained in:
parent
574313aaae
commit
78e50cd7b5
1 changed files with 8 additions and 1 deletions
|
@ -42,7 +42,7 @@ func NewClient(config ClientConfig) (*Client, error) {
|
|||
tlsHandshake: config.TLSHandshake,
|
||||
logger: config.Logger,
|
||||
}
|
||||
if !client.server.IsValid() || client.dialer == nil || client.tlsHandshake == nil {
|
||||
if !client.server.IsValid() || client.dialer == nil {
|
||||
return nil, os.ErrInvalid
|
||||
}
|
||||
switch client.version {
|
||||
|
@ -56,11 +56,18 @@ func NewClient(config ClientConfig) (*Client, error) {
|
|||
return client, nil
|
||||
}
|
||||
|
||||
func (c *Client) SetHandshakeFunc(handshakeFunc TLSHandshakeFunc) {
|
||||
c.tlsHandshake = handshakeFunc
|
||||
}
|
||||
|
||||
func (c *Client) DialContext(ctx context.Context) (net.Conn, error) {
|
||||
conn, err := c.dialer.DialContext(ctx, N.NetworkTCP, c.server)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if c.tlsHandshake == nil {
|
||||
return nil, os.ErrInvalid
|
||||
}
|
||||
switch c.version {
|
||||
default:
|
||||
fallthrough
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue