tls.go 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. package option
  2. import "github.com/sagernet/sing/common/json/badoption"
  3. type InboundTLSOptions struct {
  4. Enabled bool `json:"enabled,omitempty"`
  5. ServerName string `json:"server_name,omitempty"`
  6. Insecure bool `json:"insecure,omitempty"`
  7. ALPN badoption.Listable[string] `json:"alpn,omitempty"`
  8. MinVersion string `json:"min_version,omitempty"`
  9. MaxVersion string `json:"max_version,omitempty"`
  10. CipherSuites badoption.Listable[string] `json:"cipher_suites,omitempty"`
  11. Certificate badoption.Listable[string] `json:"certificate,omitempty"`
  12. CertificatePath string `json:"certificate_path,omitempty"`
  13. Key badoption.Listable[string] `json:"key,omitempty"`
  14. KeyPath string `json:"key_path,omitempty"`
  15. ACME *InboundACMEOptions `json:"acme,omitempty"`
  16. ECH *InboundECHOptions `json:"ech,omitempty"`
  17. Reality *InboundRealityOptions `json:"reality,omitempty"`
  18. }
  19. type InboundTLSOptionsContainer struct {
  20. TLS *InboundTLSOptions `json:"tls,omitempty"`
  21. }
  22. type InboundTLSOptionsWrapper interface {
  23. TakeInboundTLSOptions() *InboundTLSOptions
  24. ReplaceInboundTLSOptions(options *InboundTLSOptions)
  25. }
  26. func (o *InboundTLSOptionsContainer) TakeInboundTLSOptions() *InboundTLSOptions {
  27. return o.TLS
  28. }
  29. func (o *InboundTLSOptionsContainer) ReplaceInboundTLSOptions(options *InboundTLSOptions) {
  30. o.TLS = options
  31. }
  32. type OutboundTLSOptions struct {
  33. Enabled bool `json:"enabled,omitempty"`
  34. DisableSNI bool `json:"disable_sni,omitempty"`
  35. ServerName string `json:"server_name,omitempty"`
  36. Insecure bool `json:"insecure,omitempty"`
  37. ALPN badoption.Listable[string] `json:"alpn,omitempty"`
  38. MinVersion string `json:"min_version,omitempty"`
  39. MaxVersion string `json:"max_version,omitempty"`
  40. CipherSuites badoption.Listable[string] `json:"cipher_suites,omitempty"`
  41. Certificate badoption.Listable[string] `json:"certificate,omitempty"`
  42. CertificatePath string `json:"certificate_path,omitempty"`
  43. ECH *OutboundECHOptions `json:"ech,omitempty"`
  44. UTLS *OutboundUTLSOptions `json:"utls,omitempty"`
  45. Reality *OutboundRealityOptions `json:"reality,omitempty"`
  46. }
  47. type OutboundTLSOptionsContainer struct {
  48. TLS *OutboundTLSOptions `json:"tls,omitempty"`
  49. }
  50. type OutboundTLSOptionsWrapper interface {
  51. TakeOutboundTLSOptions() *OutboundTLSOptions
  52. ReplaceOutboundTLSOptions(options *OutboundTLSOptions)
  53. }
  54. func (o *OutboundTLSOptionsContainer) TakeOutboundTLSOptions() *OutboundTLSOptions {
  55. return o.TLS
  56. }
  57. func (o *OutboundTLSOptionsContainer) ReplaceOutboundTLSOptions(options *OutboundTLSOptions) {
  58. o.TLS = options
  59. }
  60. type InboundRealityOptions struct {
  61. Enabled bool `json:"enabled,omitempty"`
  62. Handshake InboundRealityHandshakeOptions `json:"handshake,omitempty"`
  63. PrivateKey string `json:"private_key,omitempty"`
  64. ShortID badoption.Listable[string] `json:"short_id,omitempty"`
  65. MaxTimeDifference badoption.Duration `json:"max_time_difference,omitempty"`
  66. }
  67. type InboundRealityHandshakeOptions struct {
  68. ServerOptions
  69. DialerOptions
  70. }
  71. type InboundECHOptions struct {
  72. Enabled bool `json:"enabled,omitempty"`
  73. Key badoption.Listable[string] `json:"key,omitempty"`
  74. KeyPath string `json:"key_path,omitempty"`
  75. // Deprecated: not supported by stdlib
  76. PQSignatureSchemesEnabled bool `json:"pq_signature_schemes_enabled,omitempty"`
  77. // Deprecated: added by fault
  78. DynamicRecordSizingDisabled bool `json:"dynamic_record_sizing_disabled,omitempty"`
  79. }
  80. type OutboundECHOptions struct {
  81. Enabled bool `json:"enabled,omitempty"`
  82. Config badoption.Listable[string] `json:"config,omitempty"`
  83. ConfigPath string `json:"config_path,omitempty"`
  84. // Deprecated: not supported by stdlib
  85. PQSignatureSchemesEnabled bool `json:"pq_signature_schemes_enabled,omitempty"`
  86. // Deprecated: added by fault
  87. DynamicRecordSizingDisabled bool `json:"dynamic_record_sizing_disabled,omitempty"`
  88. }
  89. type OutboundUTLSOptions struct {
  90. Enabled bool `json:"enabled,omitempty"`
  91. Fingerprint string `json:"fingerprint,omitempty"`
  92. }
  93. type OutboundRealityOptions struct {
  94. Enabled bool `json:"enabled,omitempty"`
  95. PublicKey string `json:"public_key,omitempty"`
  96. ShortID string `json:"short_id,omitempty"`
  97. }