patchServers rewrites the first servers[].address/port for Trojan/SS style.
(settings map[string]any, origHost string, origPort uint16)
| 153 | |
| 154 | // patchServers rewrites the first servers[].address/port for Trojan/SS style. |
| 155 | func patchServers(settings map[string]any, origHost string, origPort uint16) bool { |
| 156 | servers, ok := settings["servers"].([]any) |
| 157 | if !ok { |
| 158 | return false |
| 159 | } |
| 160 | for _, s := range servers { |
| 161 | sm, ok := s.(map[string]any) |
| 162 | if !ok { |
| 163 | continue |
| 164 | } |
| 165 | if _, has := sm["address"]; has { |
| 166 | sm["address"] = "127.0.0.1" |
| 167 | sm["port"] = 40443 |
| 168 | _ = origHost |
| 169 | _ = origPort |
| 170 | return true |
| 171 | } |
| 172 | } |
| 173 | return false |
| 174 | } |
| 175 | |
| 176 | // -- sing-box (JSON with typed outbounds) --------------------------------- |
| 177 |