[proxy] Add --without-dns flag, and change meaning of --with-dns flag

This commit is contained in:
Paul Bellamy committed 2015-06-16 14:07:40 +01:00
1 parent a1cb5b16a6
commit 8873d69b77
6 files changed
+58 -18

No files matched your search

+9 -4
View File
@@ -81,7 +81,12 @@ func (i *createContainerInterceptor) setWeaveWaitEntrypoint(container *docker.Co
}
func (i *createContainerInterceptor) setWeaveDNS(container *createContainerRequestBody, r *http.Request) error {
if !i.proxy.WithDNS {
if i.proxy.WithoutDNS {
return nil
}
dnsDomain, dnsRunning := i.getDNSDomain()
if !(dnsRunning || i.proxy.WithDNS) {
return nil
}
@@ -95,13 +100,13 @@ func (i *createContainerInterceptor) setWeaveDNS(container *createContainerReque
if container.Hostname == "" && name != "" {
container.Hostname = name
// Strip trailing period because it's unusual to see it used on the end of a host name
container.Domainname = strings.TrimSuffix(i.getDNSDomain(), ".")
container.Domainname = strings.TrimSuffix(dnsDomain, ".")
}
return nil
}
func (i *createContainerInterceptor) getDNSDomain() (domain string) {
func (i *createContainerInterceptor) getDNSDomain() (domain string, running bool) {
domain = nameserver.DefaultLocalDomain
dnsContainer, err := i.proxy.client.InspectContainer("weavedns")
if err != nil ||
@@ -122,7 +127,7 @@ func (i *createContainerInterceptor) getDNSDomain() (domain string) {
return
}
return string(b)
return string(b), true
}
func (i *createContainerInterceptor) InterceptResponse(r *http.Response) error {
+2 -1
View File
@@ -37,6 +37,7 @@ type Config struct {
TLSConfig TLSConfig
Version string
WithDNS bool
WithoutDNS bool
WithIPAM bool
}
@@ -61,7 +62,7 @@ func NewProxy(c Config) (*Proxy, error) {
},
}
if p.WithDNS {
if !p.WithoutDNS {
dockerBridgeIP, err := callWeave("docker-bridge-ip")
if err != nil {
return nil, err