Last active
June 13, 2024 13:26
-
-
Save simos/35c6aa259cab05fd56c19ad6b0cfdd0f to your computer and use it in GitHub Desktop.
Minimal SOCKS5 proxy server in Go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For use in the tutorial at https://blog.simos.info/a-network-isolated-container-in-lxd/ | |
// Source: https://github.com/armon/go-socks5 | |
// | |
// To compile, run once: go get github.com/armon/go-socks5 | |
// then run: go run simplesocks5proxyserver.go | |
// | |
package main | |
import ( | |
"fmt" | |
"log" | |
"os" | |
"github.com/armon/go-socks5" | |
) | |
func main() { | |
// Create a SOCKS5 server | |
config := &socks5.Config{ | |
Logger: log.New(os.Stdout, "SOCKS5Server", log.LstdFlags), | |
} | |
server, err := socks5.New(config) | |
if err != nil { | |
panic(err) | |
} | |
fmt.Print("Listening on 127.0.0.1:10080...\n"); | |
fmt.Print("Press Ctrl+C to interrupt: "); | |
// Create SOCKS5 proxy on localhost port 1080 | |
if err := server.ListenAndServe("tcp", "127.0.0.1:10080"); err != nil { | |
panic(err) | |
} | |
} |
@derekmahar, indeed, you get this error when you build this Go code.
Run first,
go get github.com/armon/go-socks5
and then you should be able to go run
successfully.
Thank you! That fixed the problem.
Note that go get github.com/armon/go-socks5
downloaded the package into ~/go/pkg
:
derek@derek-TB350-BTC:~/Projects/go/35c6aa259cab05fd56c19ad6b0cfdd0f$ go get github.com/armon/go-socks5
derek@derek-TB350-BTC:~/Projects/go/35c6aa259cab05fd56c19ad6b0cfdd0f$ find ~/go/pkg/linux_amd64/github.com/
/home/derek/go/pkg/linux_amd64/github.com/
/home/derek/go/pkg/linux_amd64/github.com/armon
/home/derek/go/pkg/linux_amd64/github.com/armon/go-socks5.a
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@simos, what should I do to resolve this compilation error? The Go compiler apparently misinterprets the
go-socks5
module import as a local import.