Merge pull request #1529 from weaveworks/expose-proxy-tls
Expose some tls functions from the proxy for use elsewhere.
This commit is contained in:
commit
da49e71eb8
2 files changed
+7
-5
No files matched your search
+2
-2
@@ -76,7 +76,7 @@ type Proxy struct {
|
|||||||
func NewProxy(c Config) (*Proxy, error) {
|
func NewProxy(c Config) (*Proxy, error) {
|
||||||
p := &Proxy{Config: c, waiters: make(map[*http.Request]*wait)}
|
p := &Proxy{Config: c, waiters: make(map[*http.Request]*wait)}
|
||||||
|
|
||||||
if err := p.TLSConfig.loadCerts(); err != nil {
|
if err := p.TLSConfig.LoadCerts(); err != nil {
|
||||||
Log.Fatalf("Could not configure tls for proxy: %s", err)
|
Log.Fatalf("Could not configure tls for proxy: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,7 +262,7 @@ func (proxy *Proxy) listen(protoAndAddr string) (net.Listener, string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, "", err
|
return nil, "", err
|
||||||
}
|
}
|
||||||
if proxy.TLSConfig.enabled() {
|
if proxy.TLSConfig.IsEnabled() {
|
||||||
listener = tls.NewListener(listener, proxy.TLSConfig.Config)
|
listener = tls.NewListener(listener, proxy.TLSConfig.Config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-3
@@ -17,15 +17,17 @@ type TLSConfig struct {
|
|||||||
*tls.Config
|
*tls.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *TLSConfig) enabled() bool {
|
// IsEnabled returns true if TLS is enable, according to the config.
|
||||||
|
func (c *TLSConfig) IsEnabled() bool {
|
||||||
if c == nil {
|
if c == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return c.Enabled || c.Verify
|
return c.Enabled || c.Verify
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *TLSConfig) loadCerts() error {
|
// LoadCerts loads the certificates into c.Config, if TLS is enabled.
|
||||||
if !c.enabled() {
|
func (c *TLSConfig) LoadCerts() error {
|
||||||
|
if !c.IsEnabled() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user