config.go 821 B

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