sing-box/common/tls/config.go

37 lines
821 B
Go
Raw Normal View History

2022-09-09 18:45:10 +08:00
package tls
import (
"crypto/tls"
E "github.com/sagernet/sing/common/exceptions"
2023-02-28 11:30:46 +08:00
aTLS "github.com/sagernet/sing/common/tls"
2022-09-09 18:45:10 +08:00
)
type (
2023-02-28 11:30:46 +08:00
Config = aTLS.Config
ConfigCompat = aTLS.ConfigCompat
ServerConfig = aTLS.ServerConfig
ServerConfigCompat = aTLS.ServerConfigCompat
WithSessionIDGenerator = aTLS.WithSessionIDGenerator
Conn = aTLS.Conn
2023-02-18 14:55:47 +08:00
STDConfig = tls.Config
STDConn = tls.Conn
ConnectionState = tls.ConnectionState
2022-09-09 18:45:10 +08:00
)
func ParseTLSVersion(version string) (uint16, error) {
switch version {
case "1.0":
return tls.VersionTLS10, nil
case "1.1":
return tls.VersionTLS11, nil
case "1.2":
return tls.VersionTLS12, nil
case "1.3":
return tls.VersionTLS13, nil
default:
return 0, E.New("unknown tls version:", version)
}
}