예제 #1
0
func main() {
	l, err := net.Listen("tcp", ":9850")
	if err != nil {
		log.Println("Error listening: ", err)
		os.Exit(1)
	}
	defer l.Close()

	for {
		// Listen for an incoming connection.
		conn, err := l.Accept()
		if err != nil {
			log.Println("Error accepting:  ", err)
			continue
		}
		go simpleSocks5.Socks5Handle(conn)
	}
}
예제 #2
0
func proxy(conn net.Conn, encode, decode cipher.Stream, randomDataLen int, key *[32]byte) {
	cconn := cipherConn.NewCipherConn(decode, encode, conn)

	var ri = 0
	var randomdata = make([]byte, randomDataLen+poly1305.TagSize)
	for ri < (randomDataLen + poly1305.TagSize) {
		r, err := cconn.Read(randomdata[ri:])
		if err != nil {
			return
		}
		ri += r
	}

	var mac [16]byte
	copy(mac[:], randomdata[randomDataLen:])
	if !poly1305.Verify(&mac, randomdata[:randomDataLen], key) {
		log.Println("poly1305 mac verify error")
		return
	}

	simpleSocks5.Socks5Handle(cconn)
	time.Sleep(time.Second)
}