Skip to content

Commit

Permalink
sowc: update hints for http_proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
navigaid committed Mar 14, 2024
1 parent 93a970a commit bacd9ba
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions apps/sowc/sowc.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,33 @@ func Arg1(args []string, fallback string) string {
return fallback
}

func Run(args []string) error {
addr := Arg0(args, ":8123")
remote := Arg1(args, "wss://sows.ufo.k0s.io")
log.Println("socks5 listening on", addr)
log.Println("remote socks5+wss", remote)

// CAVEAT: curl recognizes only lowercase http_proxy, not HTTP_PROXY
func proxyHints(addr string) {
log.Println("# bash")
println(fmt.Sprintf("export HTTP_PROXY=http://127.0.0.1%s HTTPS_PROXY=http://127.0.0.1%s", addr, addr))
println(fmt.Sprintf("export http_proxy=http://127.0.0.1%s https_proxy=http://127.0.0.1%s", addr, addr))
println(fmt.Sprintf("export HTTP_PROXY=socks5h://127.0.0.1%s HTTPS_PROXY=socks5h://127.0.0.1%s", addr, addr))
println(fmt.Sprintf("export http_proxy=socks5h://127.0.0.1%s https_proxy=socks5h://127.0.0.1%s", addr, addr))

log.Println("# cmd")
println(fmt.Sprintf("set HTTP_PROXY=http://127.0.0.1%s HTTPS_PROXY=http://127.0.0.1%s", addr, addr))
println(fmt.Sprintf("set http_proxy=http://127.0.0.1%s https_proxy=http://127.0.0.1%s", addr, addr))
println(fmt.Sprintf("set HTTP_PROXY=socks5h://127.0.0.1%s HTTPS_PROXY=socks5h://127.0.0.1%s", addr, addr))
println(fmt.Sprintf("set http_proxy=socks5h://127.0.0.1%s https_proxy=socks5h://127.0.0.1%s", addr, addr))

log.Println("# powershell")
println(fmt.Sprintf("$env:HTTP_PROXY='http://127.0.0.1%s'; $env:HTTPS_PROXY='http://127.0.0.1%s'", addr, addr))
println(fmt.Sprintf("$env:http_proxy='http://127.0.0.1%s'; $env:https_proxy='http://127.0.0.1%s'", addr, addr))
println(fmt.Sprintf("$env:HTTP_PROXY='socks5h://127.0.0.1%s'; $env:HTTPS_PROXY='socks5h://127.0.0.1%s'", addr, addr))
println(fmt.Sprintf("$env:http_proxy='socks5h://127.0.0.1%s'; $env:https_proxy='socks5h://127.0.0.1%s'", addr, addr))
}

func Run(args []string) error {
addr := Arg0(args, ":8123")
remote := Arg1(args, "wss://sows.ufo.k0s.io")
log.Println("[arg0] socks5 listening on", addr)
log.Println("[arg1] remote socks5+wss", remote)
proxyHints(addr)

ln, err := net.Listen("tcp", addr)
if err != nil {
Expand Down

0 comments on commit bacd9ba

Please sign in to comment.