detectJSONProxy looks for an executable on PATH and a config file in one of the candidate locations. Returns a Client that patches the first VLESS/VMess outbound it finds.
(name string, candidates []string)
| 61 | // of the candidate locations. Returns a Client that patches the first |
| 62 | // VLESS/VMess outbound it finds. |
| 63 | func detectJSONProxy(name string, candidates []string) (Client, bool) { |
| 64 | bin, err := exec.LookPath(name) |
| 65 | if err != nil { |
| 66 | return Client{}, false |
| 67 | } |
| 68 | for _, p := range candidates { |
| 69 | if _, err := os.Stat(p); err == nil { |
| 70 | return Client{ |
| 71 | Name: name, |
| 72 | Binary: bin, |
| 73 | ConfigPath: p, |
| 74 | Patch: jsonProxyPatcher(p), |
| 75 | }, true |
| 76 | } |
| 77 | } |
| 78 | return Client{}, false |
| 79 | } |
| 80 | |
| 81 | func jsonProxyPatcher(path string) func(string, uint16) error { |
| 82 | return func(origHost string, origPort uint16) error { |
no test coverage detected