github.com/inazumav/sing-box@v0.0.0-20230926072359-ab51429a14f1/common/tls/config.go (about) 1 package tls 2 3 import ( 4 "crypto/tls" 5 6 E "github.com/sagernet/sing/common/exceptions" 7 aTLS "github.com/sagernet/sing/common/tls" 8 ) 9 10 type ( 11 Config = aTLS.Config 12 ConfigCompat = aTLS.ConfigCompat 13 ServerConfig = aTLS.ServerConfig 14 ServerConfigCompat = aTLS.ServerConfigCompat 15 WithSessionIDGenerator = aTLS.WithSessionIDGenerator 16 Conn = aTLS.Conn 17 18 STDConfig = tls.Config 19 STDConn = tls.Conn 20 ConnectionState = tls.ConnectionState 21 ) 22 23 func ParseTLSVersion(version string) (uint16, error) { 24 switch version { 25 case "1.0": 26 return tls.VersionTLS10, nil 27 case "1.1": 28 return tls.VersionTLS11, nil 29 case "1.2": 30 return tls.VersionTLS12, nil 31 case "1.3": 32 return tls.VersionTLS13, nil 33 default: 34 return 0, E.New("unknown tls version:", version) 35 } 36 }