config.go 852 B

12345678910111213141516171819202122232425262728293031323334353637
  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. CurveID = tls.CurveID
  18. )
  19. func ParseTLSVersion(version string) (uint16, error) {
  20. switch version {
  21. case "1.0":
  22. return tls.VersionTLS10, nil
  23. case "1.1":
  24. return tls.VersionTLS11, nil
  25. case "1.2":
  26. return tls.VersionTLS12, nil
  27. case "1.3":
  28. return tls.VersionTLS13, nil
  29. default:
  30. return 0, E.New("unknown tls version:", version)
  31. }
  32. }