MCPcopy Create free account
hub / github.com/SamNet-dev/snix / detectJSONProxy

Function detectJSONProxy

integrate/integrate.go:63–79  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

61// of the candidate locations. Returns a Client that patches the first
62// VLESS/VMess outbound it finds.
63func 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
81func jsonProxyPatcher(path string) func(string, uint16) error {
82 return func(origHost string, origPort uint16) error {

Callers 2

detectXrayFunction · 0.85
detectV2rayFunction · 0.85

Calls 1

jsonProxyPatcherFunction · 0.85

Tested by

no test coverage detected