()
| 181 | } |
| 182 | |
| 183 | func initPublicIPState() { |
| 184 | // the feature will be only enabled if the cloud has been adopted |
| 185 | // due to privacy reasons |
| 186 | |
| 187 | // but it will be initialized anyway to avoid nil pointer dereferences |
| 188 | ps := myip.NewPublicIPState(&myip.PublicIPStateConfig{ |
| 189 | Logger: networkLogger, |
| 190 | CloudflareEndpoint: config.CloudURL, |
| 191 | APIEndpoint: "", |
| 192 | IPv4: false, |
| 193 | IPv6: false, |
| 194 | HttpClientGetter: func(family int) *http.Client { |
| 195 | transport := http.DefaultTransport.(*http.Transport).Clone() |
| 196 | transport.Proxy = config.NetworkConfig.GetTransportProxyFunc() |
| 197 | transport.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) { |
| 198 | netType := network |
| 199 | switch family { |
| 200 | case link.AfInet: |
| 201 | netType = "tcp4" |
| 202 | case link.AfInet6: |
| 203 | netType = "tcp6" |
| 204 | } |
| 205 | return (&net.Dialer{}).DialContext(ctx, netType, addr) |
| 206 | } |
| 207 | |
| 208 | return &http.Client{ |
| 209 | Transport: transport, |
| 210 | Timeout: 30 * time.Second, |
| 211 | } |
| 212 | }, |
| 213 | }) |
| 214 | publicIPState = ps |
| 215 | } |
| 216 | |
| 217 | func setHostname(nm *nmlite.NetworkManager, hostname, domain string) error { |
| 218 | if nm == nil { |
no test coverage detected