package old_tcp_tailscale

import (
	"fmt"
	"net"
	"os"
)

func main() {

	if len(os.Args) < 2 {
		fmt.Println("start socks5 server error must provide listen port !")
		return
	}
	if len(os.Args) > 3 {
		fmt.Println("start socks5 server error !")
		return
	}
	username := ""
	password := ""
	if len(os.Args) == 4 {
		username = os.Args[2]
		password = os.Args[3]
	}

	port := os.Args[1]

	listener, err := net.Listen("tcp", ":"+port)
	if err != nil {
		fmt.Println("start listener error ! => " + err.Error())
	}

	server := &Server{
		Username: username,
		Password: password,
	}

	err = server.Serve(listener)
	if err != nil {
		fmt.Println("server start to server error ! => " + err.Error())
	}
}
