| 90 | } |
| 91 | |
| 92 | func findLocalProxyPort(configJSON string) string { |
| 93 | if configJSON == "" { |
| 94 | return "" |
| 95 | } |
| 96 | var cfg struct { |
| 97 | Inbounds []struct { |
| 98 | Protocol string `json:"protocol"` |
| 99 | Port int `json:"port"` |
| 100 | } `json:"inbounds"` |
| 101 | } |
| 102 | if err := json.Unmarshal([]byte(configJSON), &cfg); err != nil { |
| 103 | return "" |
| 104 | } |
| 105 | for _, ib := range cfg.Inbounds { |
| 106 | switch ib.Protocol { |
| 107 | case "http": |
| 108 | return fmt.Sprintf("http://127.0.0.1:%d", ib.Port) |
| 109 | case "socks": |
| 110 | return fmt.Sprintf("socks5://127.0.0.1:%d", ib.Port) |
| 111 | } |
| 112 | } |
| 113 | return "" |
| 114 | } |
| 115 | |
| 116 | type streamServiceDef struct { |
| 117 | name string |