mirror of
https://github.com/moby/moby.git
synced 2026-08-05 23:51:18 +00:00
Merge pull request #51229 from olljanat/win-overlay-custom-dns
libnetwork: support custom DNS servers in Windows overlay driver
This commit is contained in:
@@ -124,12 +124,18 @@ func (d *driver) CreateEndpoint(ctx context.Context, nid, eid string, ifInfo dri
|
||||
|
||||
// Todo: Add port bindings and qos policies here
|
||||
|
||||
dnsServerList, err := windows.ParseDNSServers(epOptions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
hnsEndpoint := &hcsshim.HNSEndpoint{
|
||||
Name: eid,
|
||||
VirtualNetwork: n.hnsID,
|
||||
IPAddress: ep.addr.IP,
|
||||
EnableInternalDNS: true,
|
||||
GatewayAddress: s.gwIP.String(),
|
||||
DNSServerList: dnsServerList,
|
||||
}
|
||||
|
||||
if ep.mac != nil {
|
||||
|
||||
@@ -610,14 +610,6 @@ func parseEndpointOptions(epOptions map[string]any) (*endpointOption, error) {
|
||||
}
|
||||
}
|
||||
|
||||
if opt, ok := epOptions[netlabel.DNSServers]; ok {
|
||||
if dns, ok := opt.([]string); ok {
|
||||
ec.DNSServers = dns
|
||||
} else {
|
||||
return nil, fmt.Errorf("Invalid endpoint configuration")
|
||||
}
|
||||
}
|
||||
|
||||
if opt, ok := epOptions[DisableICC]; ok {
|
||||
if disableICC, ok := opt.(bool); ok {
|
||||
ec.DisableICC = disableICC
|
||||
@@ -637,6 +629,17 @@ func parseEndpointOptions(epOptions map[string]any) (*endpointOption, error) {
|
||||
return ec, nil
|
||||
}
|
||||
|
||||
func ParseDNSServers(epOptions map[string]any) (string, error) {
|
||||
if opt, ok := epOptions[netlabel.DNSServers]; ok {
|
||||
if dns, ok := opt.([]string); ok {
|
||||
return strings.Join(dns, ","), nil
|
||||
} else {
|
||||
return "", fmt.Errorf("Invalid endpoint configuration")
|
||||
}
|
||||
}
|
||||
return "", nil
|
||||
}
|
||||
|
||||
// ParseEndpointConnectivity parses options passed to CreateEndpoint, specifically port bindings, and store in a endpointConnectivity object.
|
||||
func ParseEndpointConnectivity(epOptions map[string]any) (*EndpointConnectivity, error) {
|
||||
if epOptions == nil {
|
||||
@@ -729,7 +732,11 @@ func (d *driver) CreateEndpoint(ctx context.Context, nid, eid string, ifInfo dri
|
||||
endpointStruct.IPAddress = ifInfo.Address().IP
|
||||
}
|
||||
|
||||
endpointStruct.DNSServerList = strings.Join(epOption.DNSServers, ",")
|
||||
dnsServerList, err := ParseDNSServers(epOptions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
endpointStruct.DNSServerList = dnsServerList
|
||||
|
||||
// overwrite the ep DisableDNS option if DisableGatewayDNS was set to true during the network creation option
|
||||
if n.config.DisableGatewayDNS {
|
||||
|
||||
Reference in New Issue
Block a user