@@ -3,6 +3,8 @@ package network
3
3
import (
4
4
"fmt"
5
5
"net"
6
+ "net/http"
7
+ "net/url"
6
8
"time"
7
9
8
10
"github.com/guregu/null/v6"
@@ -32,8 +34,9 @@ type IPv6StaticConfig struct {
32
34
DNS []string `json:"dns,omitempty" validate_type:"ipv6" required:"true"`
33
35
}
34
36
type NetworkConfig struct {
35
- Hostname null.String `json:"hostname,omitempty" validate_type:"hostname"`
36
- Domain null.String `json:"domain,omitempty" validate_type:"hostname"`
37
+ Hostname null.String `json:"hostname,omitempty" validate_type:"hostname"`
38
+ HTTPProxy null.String `json:"http_proxy,omitempty" validate_type:"proxy"`
39
+ Domain null.String `json:"domain,omitempty" validate_type:"hostname"`
37
40
38
41
IPv4Mode null.String `json:"ipv4_mode,omitempty" one_of:"dhcp,static,disabled" default:"dhcp"`
39
42
IPv4Static * IPv4StaticConfig `json:"ipv4_static,omitempty" required_if:"IPv4Mode=static"`
@@ -71,6 +74,18 @@ func (c *NetworkConfig) GetMDNSMode() *mdns.MDNSListenOptions {
71
74
72
75
return listenOptions
73
76
}
77
+
78
+ func (s * NetworkConfig ) GetTransportProxyFunc () func (* http.Request ) (* url.URL , error ) {
79
+ return func (* http.Request ) (* url.URL , error ) {
80
+ if s .HTTPProxy .String == "" {
81
+ return nil , nil
82
+ } else {
83
+ proxyUrl , _ := url .Parse (s .HTTPProxy .String )
84
+ return proxyUrl , nil
85
+ }
86
+ }
87
+ }
88
+
74
89
func (s * NetworkInterfaceState ) GetHostname () string {
75
90
hostname := ToValidHostname (s .config .Hostname .String )
76
91
0 commit comments