2020-11-22 12:39:20 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2020-11-23 20:40:34 -05:00
|
|
|
"flag"
|
2020-11-22 12:39:20 -05:00
|
|
|
|
|
|
|
"github.com/eyedeekay/goSam"
|
|
|
|
"github.com/getlantern/go-socks5"
|
|
|
|
"log"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2020-11-23 20:40:34 -05:00
|
|
|
samaddr = flag.String("sam", "127.0.0.1:7656", "SAM API address to use")
|
|
|
|
socksaddr = flag.String("socks", "127.0.0.1:7675", "SOCKS address to use")
|
2020-11-22 12:39:20 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
sam, err := goSam.NewClient(*samaddr)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
log.Println("Client Created")
|
|
|
|
|
|
|
|
// create a transport that uses SAM to dial TCP Connections
|
|
|
|
conf := &socks5.Config{
|
|
|
|
Dial: sam.DialContext,
|
|
|
|
Resolver: sam,
|
|
|
|
}
|
|
|
|
server, err := socks5.New(conf)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create SOCKS5 proxy on localhost port 8000
|
|
|
|
if err := server.ListenAndServe("tcp", *socksaddr); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|