package handlers

import (
	
	
	
)

// OpenTunnel opens ssh tunnel on unix sockets or ports
func ( *fiber.Ctx) error {
	 := []string{"remote_host", "remote_port", "username", "password"}

	for ,  := range  {
		if len(.FormValue()) < 1 {
			return logger.FiberError(fiber.StatusBadRequest, +" parameter is missing")
		}
	}

	 := .FormValue("ssh_port")
	if len() < 1 {
		 = "22"
	}

	 := bridge.CreateTunnel(
		.FormValue("remote_host"),
		.FormValue("remote_port"),
		.FormValue("username"),
		.FormValue("password"),
		,
	)

	return .JSON()
}

// KeepTunnelAlive keeps tunnel connection alive
func ( *fiber.Ctx) error {
	 := []string{"remote_host", "remote_port", "username"}

	for ,  := range  {
		if len(.FormValue()) < 1 {
			return logger.FiberError(fiber.StatusBadRequest, +" parameter is missing")
		}
	}

	,  := bridge.Tunnels.Get(
		.FormValue("remote_host"),
		.FormValue("remote_port"),
		.FormValue("username"),
	)
	if  != nil {
		return logger.FiberError(fiber.StatusNotFound, "tunnel not found")
	}

	return .Type("json").SendString(`{
		"status":  200,
		"message": "tunnel keep alive successfully"
	}`)
}