@@ -133,6 +133,12 @@ func getExtClient(w http.ResponseWriter, r *http.Request) {
133
133
logic .ReturnErrorResponse (w , r , logic .FormatError (err , "internal" ))
134
134
return
135
135
}
136
+ gwNode , err := logic .GetNodeByID (client .IngressGatewayID )
137
+ if err != nil {
138
+ logic .ReturnErrorResponse (w , r , logic .FormatError (err , "internal" ))
139
+ return
140
+ }
141
+ logic .SetDNSOnWgConfig (& gwNode , & client )
136
142
137
143
w .WriteHeader (http .StatusOK )
138
144
json .NewEncoder (w ).Encode (client )
@@ -288,39 +294,11 @@ func getExtClientConf(w http.ResponseWriter, r *http.Request) {
288
294
}
289
295
}
290
296
}
291
-
297
+ logic . SetDNSOnWgConfig ( & gwnode , & client )
292
298
defaultDNS := ""
293
299
if client .DNS != "" {
294
300
defaultDNS = "DNS = " + client .DNS
295
- } else if gwnode .IngressDNS != "" {
296
- defaultDNS = "DNS = " + gwnode .IngressDNS
297
- }
298
- if client .DNS == "" {
299
- if len (network .NameServers ) > 0 {
300
- if defaultDNS == "" {
301
- defaultDNS = "DNS = " + strings .Join (network .NameServers , "," )
302
- } else {
303
- defaultDNS += "," + strings .Join (network .NameServers , "," )
304
- }
305
-
306
- }
307
301
}
308
- // if servercfg.GetManageDNS() {
309
- // if gwnode.Address6.IP != nil {
310
- // if defaultDNS == "" {
311
- // defaultDNS = "DNS = " + gwnode.Address6.IP.String()
312
- // } else {
313
- // defaultDNS = defaultDNS + ", " + gwnode.Address6.IP.String()
314
- // }
315
- // }
316
- // if gwnode.Address.IP != nil {
317
- // if defaultDNS == "" {
318
- // defaultDNS = "DNS = " + gwnode.Address.IP.String()
319
- // } else {
320
- // defaultDNS = defaultDNS + ", " + gwnode.Address.IP.String()
321
- // }
322
- // }
323
- // }
324
302
325
303
defaultMTU := 1420
326
304
if host .MTU != 0 {
@@ -745,18 +723,10 @@ func createExtClient(w http.ResponseWriter, r *http.Request) {
745
723
extclient .Tags = make (map [models.TagID ]struct {})
746
724
// extclient.Tags[models.TagID(fmt.Sprintf("%s.%s", extclient.Network,
747
725
// models.RemoteAccessTagName))] = struct{}{}
748
- // set extclient dns to ingressdns if extclient dns is not explicitly set
749
- if (extclient .DNS == "" ) && (node .IngressDNS != "" ) {
750
- network , _ := logic .GetNetwork (node .Network )
751
- dns := node .IngressDNS
752
- if len (network .NameServers ) > 0 {
753
- if dns == "" {
754
- dns = strings .Join (network .NameServers , "," )
755
- } else {
756
- dns += "," + strings .Join (network .NameServers , "," )
757
- }
758
-
759
- }
726
+ // set extclient dns to ingressdns if extclient dns is not explicitly
727
+ gwDNS := logic .GetGwDNS (& node )
728
+ if (extclient .DNS == "" ) && (gwDNS != "" ) {
729
+ dns := gwDNS
760
730
extclient .DNS = dns
761
731
}
762
732
host , err := logic .GetHost (node .HostID .String ())
0 commit comments