Surge Mac supports the External Proxy policy, which allows Surge to work more easily with other proxy software.
The following is an example of ssh.
First, the policy keyword type is
[Proxy] external = external, exec = "/usr/bin/ssh", args = "126.96.36.199", args = "-D", args = "127.0.0.1:1080", local-port = 1080, addresses = 188.8.131.52
addresses parameters are optional,
local-port are required.
addresses fields can be repeatedly used for appending.
Surge will do the following.
- When the policy is used, Surge starts the external process with the exec and args parameters, and later forwards the request to SOCKS5 127.0.0.1:[local-port].
- If the external process is terminated, it will be restarted automatically when the policy is used.
- Surge automatically excludes the addresses in the addresses parameter from the VIF routes when Enhanced Mode is on. (so please fill in the proxy server IP address in this field. Hostname and domain are not supported.)
- Surge always uses the DIRECT policy for requests from external processes. (In order to deal with plug-in programs like obfs-local, children of external processes are handled similarly)
- Automatically shut down all external processes when Surge exits, and automatically clean up the route table items when the Enhanced Mode shuts down.
- The functions of 3 and 4 above are overlapping, please use the addresses declaration to exclude VIF processing, which can reduce processing overhead, the function of 4 is for additional protection.
- stdout and stderr of external processes are redirected to /tmp/Surge-External-xxxxxx.log for troubleshooting.
- Since external processes may take a little time to start. If a connection refused error is encountered when forwarding to 127.0.0.1:[local-port], Surge will automatically retry after 500ms, up to 6 times per request.
- Surge iOS will be treated as the external policy as REJECT since it's not supported.