sing-box/common/tls/config.go

37 lines
821 B
Go
Raw Permalink Normal View History

2022-09-09 10:45:10 +00:00
package tls
import (
"crypto/tls"
E "github.com/sagernet/sing/common/exceptions"
2023-02-28 03:30:46 +00:00
aTLS "github.com/sagernet/sing/common/tls"
2022-09-09 10:45:10 +00:00
)
type (
2023-02-28 03:30:46 +00:00
Config = aTLS.Config
ConfigCompat = aTLS.ConfigCompat
ServerConfig = aTLS.ServerConfig
ServerConfigCompat = aTLS.ServerConfigCompat
WithSessionIDGenerator = aTLS.WithSessionIDGenerator
Conn = aTLS.Conn
2023-02-18 06:55:47 +00:00
STDConfig = tls.Config
STDConn = tls.Conn
ConnectionState = tls.ConnectionState
2022-09-09 10:45:10 +00: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)
}
}