2015-12-14 11:26:29 -05:00
|
|
|
package http
|
|
|
|
|
2016-05-29 10:46:31 -04:00
|
|
|
import "crypto/tls"
|
2016-01-26 05:28:09 -05:00
|
|
|
|
2016-05-29 10:46:31 -04:00
|
|
|
// CertificateConfig is the config for TLS certificates used in HTTP proxy.
|
2016-05-07 04:06:12 -04:00
|
|
|
type CertificateConfig struct {
|
|
|
|
Domain string
|
|
|
|
Certificate tls.Certificate
|
|
|
|
}
|
|
|
|
|
2016-05-29 10:46:31 -04:00
|
|
|
// TlsConfig is the config for TLS connections.
|
|
|
|
type TLSConfig struct {
|
2016-05-07 04:06:12 -04:00
|
|
|
Enabled bool
|
|
|
|
Certs []*CertificateConfig
|
2016-04-25 09:30:28 -04:00
|
|
|
}
|
|
|
|
|
2016-05-29 10:46:31 -04:00
|
|
|
// GetConfig returns corresponding tls.Config.
|
|
|
|
func (this *TLSConfig) GetConfig() *tls.Config {
|
2016-05-07 04:36:36 -04:00
|
|
|
if !this.Enabled {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
config := &tls.Config{
|
|
|
|
InsecureSkipVerify: false,
|
|
|
|
}
|
|
|
|
|
|
|
|
config.Certificates = make([]tls.Certificate, len(this.Certs))
|
|
|
|
for index, cert := range this.Certs {
|
|
|
|
config.Certificates[index] = cert.Certificate
|
|
|
|
}
|
|
|
|
|
|
|
|
config.BuildNameToCertificate()
|
|
|
|
|
|
|
|
return config
|
|
|
|
}
|
|
|
|
|
2016-05-29 10:46:31 -04:00
|
|
|
// Config for HTTP proxy server.
|
2016-01-15 06:43:06 -05:00
|
|
|
type Config struct {
|
2016-05-29 10:46:31 -04:00
|
|
|
TLSConfig *TLSConfig
|
2015-12-14 11:26:29 -05:00
|
|
|
}
|
2016-05-28 07:44:11 -04:00
|
|
|
|
2016-05-29 10:46:31 -04:00
|
|
|
// ClientConfig for HTTP proxy client.
|
2016-05-28 07:44:11 -04:00
|
|
|
type ClientConfig struct {
|
|
|
|
}
|