| 139 | ` |
| 140 | |
| 141 | func New() *Config { |
| 142 | // merge default config with internal config |
| 143 | mergedConfig, err := Merge(defaultConfig, InternalConfig) |
| 144 | if err != nil { |
| 145 | panic(err) |
| 146 | } |
| 147 | config := &Config{} |
| 148 | err = yaml3.Unmarshal([]byte(mergedConfig), config) |
| 149 | if err != nil { |
| 150 | panic(err) |
| 151 | } |
| 152 | // Defaults for fields whose Go zero value is not the desired default. |
| 153 | // EnableIPv6Redirect defaults to true so ::1 traffic is redirected to |
| 154 | // the proxy on modern Linux distros where glibc resolves localhost to |
| 155 | // ::1 first. Setting it false in config is the opt-in rollback knob. |
| 156 | config.Agent.EnableIPv6Redirect = true |
| 157 | return config |
| 158 | } |
| 159 | |
| 160 | func Merge(srcStr, destStr string) (string, error) { |
| 161 | return mergeStrings(srcStr, destStr, false, yaml.MergeOptions{}) |