config.go 861 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package http
  2. import (
  3. "crypto/tls"
  4. v2net "github.com/v2ray/v2ray-core/common/net"
  5. )
  6. type CertificateConfig struct {
  7. Domain string
  8. Certificate tls.Certificate
  9. }
  10. type TlsConfig struct {
  11. Enabled bool
  12. Certs []*CertificateConfig
  13. }
  14. func (this *TlsConfig) GetConfig() *tls.Config {
  15. if !this.Enabled {
  16. return nil
  17. }
  18. config := &tls.Config{
  19. InsecureSkipVerify: false,
  20. }
  21. config.Certificates = make([]tls.Certificate, len(this.Certs))
  22. for index, cert := range this.Certs {
  23. config.Certificates[index] = cert.Certificate
  24. }
  25. config.BuildNameToCertificate()
  26. return config
  27. }
  28. type Config struct {
  29. OwnHosts []v2net.Address
  30. TlsConfig *TlsConfig
  31. }
  32. func (this *Config) IsOwnHost(host v2net.Address) bool {
  33. for _, ownHost := range this.OwnHosts {
  34. if ownHost.Equals(host) {
  35. return true
  36. }
  37. }
  38. return false
  39. }
  40. type ClientConfig struct {
  41. }