Exemple #1
0
func SetupClient(port, remote, subdomain string, servInfo chan string) bool {
	localServer := net.JoinHostPort("127.0.0.1", port)

	// if !ensureServer(localServer) {
	// 	return false
	// }

	req, quit, conn := make(chan bool), make(chan bool), make(chan string)

	// fmt.Printf("Setting Gotunnel server %s with local server on %s\n\n", remote, port)

	go setupCommandChannel(remote, subdomain, req, quit, conn, servInfo)

	remoteProxy := <-conn

	// l.Log("remote proxy: %v", remoteProxy)

	for {
		select {
		case <-req:
			// fmt.Printf("New link b/w %s and %s\n", remoteProxy, localServer)
			rp, err := net.Dial("tcp", remoteProxy)
			if err != nil {
				l.Log("Coundn't connect to remote clientproxy", err)
				return false
			}
			lp, err := net.Dial("tcp", localServer)
			if err != nil {
				l.Log("Couldn't connect to localserver", err)
				return false
			}

			go rwtunnel.NewRWTunnel(rp, lp)
		case <-quit:
			return true
		}
	}
	return true
}
func (p *ProxyClient) Forward(c io.ReadWriteCloser) error {
	bc := <-p.conn
	l.Log("Received new connection. Fowarding.. ")
	rwtunnel.NewRWTunnel(c, bc)
	return nil
}