Source File
tunnel.go
Belonging Package
github.com/limanmys/render-engine/app/handlers
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"
}`)
}
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |