// Returns the port to hit on the server to reach the protected server
Returns the port to hit on the server to reach the protected server
// Returns the port to hit on the server to reach the protected server
func (c *GoRpsClient) OpenTunnel(protectedServerPort int) (err error) {
	c.protectedServerPort = protectedServerPort
	c.ConnToProtectedServer = make(map[int32]*net.TCPConn)
	log.Printf("Dialing rps server @: %s\n", c.ServerTCPAddr.String())
	c.ConnToRpsServer, err = net.DialTCP("tcp", nil, c.ServerTCPAddr)
	if err != nil {
		log.Printf("Error dialing rps server: %s\n", err.Error())
		return err
	}
	msg, err := helper.ReceiveProtobuf(c.ConnToRpsServer)
	if err != nil {
		log.Printf("Error receiving exposed port from rps server: %s\n", err.Error())
		return err
	}
	c.ExposedPort, err = strconv.Atoi(string(msg.Data))
	if err != nil {
		return err
	}
	go c.handleServerConn()
	return nil
}
func ( c * GoRpsClient ) OpenTunnel ( protectedServerPort int ) ( err error ) { c . protectedServerPort = protectedServerPort c . ConnToProtectedServer = make ( map [ int32 ] * net . TCPConn ) log . Printf ( " \n " , c . ServerTCPAddr . String ( ) ) c . ConnToRpsServer , err = net . DialTCP ( " " , nil , c . ServerTCPAddr ) if err != nil { log . Printf ( " \n " , err . Error ( ) ) return err } msg , err := helper . ReceiveProtobuf ( c . ConnToRpsServer ) if err != nil { log . Printf ( " \n " , err . Error ( ) ) return err } c . ExposedPort , err = strconv . Atoi ( string ( msg . Data ) ) if err != nil { return err } go c . handleServerConn ( ) return nil }
Returns the port to hit on the server to reach the protected server
Returns the port to hit on the server to reach the protected server
// Connect to rps server // Wait for rps server to tell us which port is exposed