Execute command with tsocks(a transparent SOCKS proxy library) in golang
Install tsocks:
For Ubuntu/Debian
apt-get install tsocks
For CentOS/Fedora
yum install tsocks
Install gotsocks:
go get github.com/joeguo/gotsocks
package main
import (
"fmt"
"github.com/joeguo/gotsocks"
)
func main() {
proxy, err := gotsocks.New("198.xx.xx.xx:12345", gotsocks.Socks5)
if err != nil {
fmt.Println(err)
return
}
result, err := proxy.Command("/usr/bin/whois", 10, "google.com")
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(result))
}