2015-12-14 16:26:29 +00:00
|
|
|
package http
|
|
|
|
|
2016-05-29 14:46:31 +00:00
|
|
|
import "crypto/tls"
|
2016-01-26 10:28:09 +00:00
|
|
|
|
2016-05-29 14:46:31 +00:00
|
|
|
// CertificateConfig is the config for TLS certificates used in HTTP proxy.
|
2016-05-07 08:06:12 +00:00
|
|
|
type CertificateConfig struct {
|
|
|
|
Domain string
|
|
|
|
Certificate tls.Certificate
|
|
|
|
}
|
|
|
|
|
2016-05-29 14:46:31 +00:00
|
|
|
// TlsConfig is the config for TLS connections.
|
|
|
|
type TLSConfig struct {
|
2016-05-07 08:06:12 +00:00
|
|
|
Enabled bool
|
|
|
|
Certs []*CertificateConfig
|
2016-04-25 13:30:28 +00:00
|
|
|
}
|
|
|
|
|
2016-05-29 14:46:31 +00:00
|
|
|
// GetConfig returns corresponding tls.Config.
|
|
|
|
func (this *TLSConfig) GetConfig() *tls.Config {
|
2016-05-07 08:36:36 +00: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 14:46:31 +00:00
|
|
|
// Config for HTTP proxy server.
|
2016-01-15 11:43:06 +00:00
|
|
|
type Config struct {
|
2016-05-29 14:46:31 +00:00
|
|
|
TLSConfig *TLSConfig
|
2015-12-14 16:26:29 +00:00
|
|
|
}
|
2016-05-28 11:44:11 +00:00
|
|
|
|
2016-05-29 14:46:31 +00:00
|
|
|
// ClientConfig for HTTP proxy client.
|
2016-05-28 11:44:11 +00:00
|
|
|
type ClientConfig struct {
|
|
|
|
}
|