config.go 858 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package http
  2. import "crypto/tls"
  3. // CertificateConfig is the config for TLS certificates used in HTTP proxy.
  4. type CertificateConfig struct {
  5. Domain string
  6. Certificate tls.Certificate
  7. }
  8. // TlsConfig is the config for TLS connections.
  9. type TLSConfig struct {
  10. Enabled bool
  11. Certs []*CertificateConfig
  12. }
  13. // GetConfig returns corresponding tls.Config.
  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. // Config for HTTP proxy server.
  29. type Config struct {
  30. TLSConfig *TLSConfig
  31. }
  32. // ClientConfig for HTTP proxy client.
  33. type ClientConfig struct {
  34. }