tls.go 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. KernelTx bool `json:"kernel_tx,omitempty"`
  16. KernelRx bool `json:"kernel_rx,omitempty"`
  17. ACME *InboundACMEOptions `json:"acme,omitempty"`
  18. ECH *InboundECHOptions `json:"ech,omitempty"`
  19. Reality *InboundRealityOptions `json:"reality,omitempty"`
  20. }
  21. type InboundTLSOptionsContainer struct {
  22. TLS *InboundTLSOptions `json:"tls,omitempty"`
  23. }
  24. type InboundTLSOptionsWrapper interface {
  25. TakeInboundTLSOptions() *InboundTLSOptions
  26. ReplaceInboundTLSOptions(options *InboundTLSOptions)
  27. }
  28. func (o *InboundTLSOptionsContainer) TakeInboundTLSOptions() *InboundTLSOptions {
  29. return o.TLS
  30. }
  31. func (o *InboundTLSOptionsContainer) ReplaceInboundTLSOptions(options *InboundTLSOptions) {
  32. o.TLS = options
  33. }
  34. type OutboundTLSOptions struct {
  35. Enabled bool `json:"enabled,omitempty"`
  36. DisableSNI bool `json:"disable_sni,omitempty"`
  37. ServerName string `json:"server_name,omitempty"`
  38. Insecure bool `json:"insecure,omitempty"`
  39. ALPN badoption.Listable[string] `json:"alpn,omitempty"`
  40. MinVersion string `json:"min_version,omitempty"`
  41. MaxVersion string `json:"max_version,omitempty"`
  42. CipherSuites badoption.Listable[string] `json:"cipher_suites,omitempty"`
  43. Certificate badoption.Listable[string] `json:"certificate,omitempty"`
  44. CertificatePath string `json:"certificate_path,omitempty"`
  45. Fragment bool `json:"fragment,omitempty"`
  46. FragmentFallbackDelay badoption.Duration `json:"fragment_fallback_delay,omitempty"`
  47. RecordFragment bool `json:"record_fragment,omitempty"`
  48. KernelTx bool `json:"kernel_tx,omitempty"`
  49. KernelRx bool `json:"kernel_rx,omitempty"`
  50. ECH *OutboundECHOptions `json:"ech,omitempty"`
  51. UTLS *OutboundUTLSOptions `json:"utls,omitempty"`
  52. Reality *OutboundRealityOptions `json:"reality,omitempty"`
  53. }
  54. type OutboundTLSOptionsContainer struct {
  55. TLS *OutboundTLSOptions `json:"tls,omitempty"`
  56. }
  57. type OutboundTLSOptionsWrapper interface {
  58. TakeOutboundTLSOptions() *OutboundTLSOptions
  59. ReplaceOutboundTLSOptions(options *OutboundTLSOptions)
  60. }
  61. func (o *OutboundTLSOptionsContainer) TakeOutboundTLSOptions() *OutboundTLSOptions {
  62. return o.TLS
  63. }
  64. func (o *OutboundTLSOptionsContainer) ReplaceOutboundTLSOptions(options *OutboundTLSOptions) {
  65. o.TLS = options
  66. }
  67. type InboundRealityOptions struct {
  68. Enabled bool `json:"enabled,omitempty"`
  69. Handshake InboundRealityHandshakeOptions `json:"handshake,omitempty"`
  70. PrivateKey string `json:"private_key,omitempty"`
  71. ShortID badoption.Listable[string] `json:"short_id,omitempty"`
  72. MaxTimeDifference badoption.Duration `json:"max_time_difference,omitempty"`
  73. }
  74. type InboundRealityHandshakeOptions struct {
  75. ServerOptions
  76. DialerOptions
  77. }
  78. type InboundECHOptions struct {
  79. Enabled bool `json:"enabled,omitempty"`
  80. Key badoption.Listable[string] `json:"key,omitempty"`
  81. KeyPath string `json:"key_path,omitempty"`
  82. // Deprecated: not supported by stdlib
  83. PQSignatureSchemesEnabled bool `json:"pq_signature_schemes_enabled,omitempty"`
  84. // Deprecated: added by fault
  85. DynamicRecordSizingDisabled bool `json:"dynamic_record_sizing_disabled,omitempty"`
  86. }
  87. type OutboundECHOptions struct {
  88. Enabled bool `json:"enabled,omitempty"`
  89. Config badoption.Listable[string] `json:"config,omitempty"`
  90. ConfigPath string `json:"config_path,omitempty"`
  91. // Deprecated: not supported by stdlib
  92. PQSignatureSchemesEnabled bool `json:"pq_signature_schemes_enabled,omitempty"`
  93. // Deprecated: added by fault
  94. DynamicRecordSizingDisabled bool `json:"dynamic_record_sizing_disabled,omitempty"`
  95. }
  96. type OutboundUTLSOptions struct {
  97. Enabled bool `json:"enabled,omitempty"`
  98. Fingerprint string `json:"fingerprint,omitempty"`
  99. }
  100. type OutboundRealityOptions struct {
  101. Enabled bool `json:"enabled,omitempty"`
  102. PublicKey string `json:"public_key,omitempty"`
  103. ShortID string `json:"short_id,omitempty"`
  104. }