From bcf97fde6dcf98e2f97569fcb40e58232d33313c Mon Sep 17 00:00:00 2001 From: imterah Date: Mon, 23 Dec 2024 20:47:01 -0500 Subject: [PATCH] fix: Fixes API routes. --- backend/api/controllers/v1/backends/lookup.go | 27 ++++-- .../api/controllers/v1/proxies/connections.go | 27 +----- backend/api/controllers/v1/proxies/create.go | 87 ++++++++++++++----- backend/api/controllers/v1/proxies/lookup.go | 51 ++++++----- backend/api/controllers/v1/proxies/remove.go | 59 +++++++++++-- backend/api/controllers/v1/proxies/start.go | 30 +++++-- backend/api/controllers/v1/proxies/stop.go | 51 +++++++++-- backend/api/main.go | 3 +- backend/backendutil/application.go | 35 ++++++-- routes/Hermes API/Forward/Create.bru | 10 +-- .../Forward/Get Inbound Connections.bru | 6 +- routes/Hermes API/Forward/Lookup.bru | 4 +- routes/Hermes API/Forward/Remove.bru | 14 +-- routes/Hermes API/Forward/Start.bru | 6 +- routes/Hermes API/Forward/Stop.bru | 6 +- 15 files changed, 284 insertions(+), 132 deletions(-) diff --git a/backend/api/controllers/v1/backends/lookup.go b/backend/api/controllers/v1/backends/lookup.go index 189184b..e72e157 100644 --- a/backend/api/controllers/v1/backends/lookup.go +++ b/backend/api/controllers/v1/backends/lookup.go @@ -6,6 +6,7 @@ import ( "net/http" "strings" + "git.terah.dev/imterah/hermes/api/backendruntime" "git.terah.dev/imterah/hermes/api/dbcore" "git.terah.dev/imterah/hermes/api/jwtcore" "git.terah.dev/imterah/hermes/api/permissions" @@ -23,12 +24,13 @@ type BackendLookupRequest struct { } type SanitizedBackend struct { - Name string `json:"name"` - BackendID uint `json:"id"` - OwnerID uint `json:"ownerID"` - Description *string `json:"description"` - Backend string `json:"backend"` - BackendParameters *string `json:"connectionDetails"` + Name string `json:"name"` + BackendID uint `json:"id"` + OwnerID uint `json:"ownerID"` + Description *string `json:"description"` + Backend string `json:"backend"` + BackendParameters *string `json:"connectionDetails"` + Logs []string `json:"logs"` } type LookupResponse struct { @@ -121,12 +123,25 @@ func LookupBackend(c *gin.Context) { hasSecretVisibility := permissions.UserHasPermission(user, "backends.secretVis") for backendIndex, backend := range backends { + foundBackend, ok := backendruntime.RunningBackends[backend.ID] + + if !ok { + log.Warnf("Failed to get backend #%d controller", backend.ID) + + c.JSON(http.StatusInternalServerError, gin.H{ + "error": "Failed to get backends", + }) + + return + } + sanitizedBackends[backendIndex] = &SanitizedBackend{ BackendID: backend.ID, OwnerID: backend.UserID, Name: backend.Name, Description: backend.Description, Backend: backend.Backend, + Logs: foundBackend.Logs, } if backend.UserID == user.ID || hasSecretVisibility { diff --git a/backend/api/controllers/v1/proxies/connections.go b/backend/api/controllers/v1/proxies/connections.go index a79b2a9..7a4585b 100644 --- a/backend/api/controllers/v1/proxies/connections.go +++ b/backend/api/controllers/v1/proxies/connections.go @@ -106,33 +106,10 @@ func GetConnections(c *gin.Context) { return } - var backend dbcore.Backend - backendRequest := dbcore.DB.Where("id = ?", proxy.BackendID).First(&backend) - - if backendRequest.Error != nil { - log.Warnf("failed to find backend: %s", backendRequest.Error) - - c.JSON(http.StatusInternalServerError, gin.H{ - "error": "Failed to find backend entry", - }) - - return - } - - backendExists := backendRequest.RowsAffected > 0 - - if !backendExists { - c.JSON(http.StatusBadRequest, gin.H{ - "error": "No forward entry found", - }) - - return - } - - backendRuntime, ok := backendruntime.RunningBackends[backend.ID] + backendRuntime, ok := backendruntime.RunningBackends[proxy.BackendID] if !ok { - log.Warnf("Couldn't fetch backend runtime from backend ID #%d", backend.ID) + log.Warnf("Couldn't fetch backend runtime from backend ID #%d", proxy.BackendID) c.JSON(http.StatusInternalServerError, gin.H{ "error": "Couldn't fetch backend runtime", diff --git a/backend/api/controllers/v1/proxies/create.go b/backend/api/controllers/v1/proxies/create.go index 3f1f442..bc710b4 100644 --- a/backend/api/controllers/v1/proxies/create.go +++ b/backend/api/controllers/v1/proxies/create.go @@ -4,9 +4,11 @@ import ( "fmt" "net/http" + "git.terah.dev/imterah/hermes/api/backendruntime" "git.terah.dev/imterah/hermes/api/dbcore" "git.terah.dev/imterah/hermes/api/jwtcore" "git.terah.dev/imterah/hermes/api/permissions" + "git.terah.dev/imterah/hermes/commonbackend" "github.com/charmbracelet/log" "github.com/gin-gonic/gin" "github.com/go-playground/validator/v10" @@ -16,17 +18,12 @@ type ProxyCreationRequest struct { Token string `validate:"required" json:"token"` Name string `validate:"required" json:"name"` Description *string `json:"description"` - Protcol string `validate:"required" json:"protcol"` - SourceIP string `validate:"required" json:"source_ip"` - SourcePort uint16 `validate:"required" json:"source_port"` - DestinationPort uint16 `validate:"required" json:"destination_port"` - ProviderID uint `validate:"required" json:"provider_id"` - AutoStart bool `json:"auto_start"` -} - -type ProxyCreationResponse struct { - Success bool `json:"success"` - Id uint `json:"id"` + Protocol string `validate:"required" json:"protocol"` + SourceIP string `validate:"required" json:"sourceIP"` + SourcePort uint16 `validate:"required" json:"sourcePort"` + DestinationPort uint16 `validate:"required" json:"destinationPort"` + ProviderID uint `validate:"required" json:"providerID"` + AutoStart *bool `json:"autoStart"` } func CreateProxy(c *gin.Context) { @@ -75,9 +72,9 @@ func CreateProxy(c *gin.Context) { return } - if req.Protcol != "tcp" && req.Protcol != "udp" { + if req.Protocol != "tcp" && req.Protocol != "udp" { c.JSON(http.StatusBadRequest, gin.H{ - "error": "Body protocol must be either 'tcp' or 'udp'", + "error": "Protocol must be either 'tcp' or 'udp'", }) return @@ -85,31 +82,39 @@ func CreateProxy(c *gin.Context) { var backend dbcore.Backend backendRequest := dbcore.DB.Where("id = ?", req.ProviderID).First(&backend) + if backendRequest.Error != nil { log.Warnf("failed to find if backend exists or not: %s", backendRequest.Error) c.JSON(http.StatusInternalServerError, gin.H{ - "error": "Failed to find if provider exists", + "error": "Failed to find if backend exists", }) } backendExists := backendRequest.RowsAffected > 0 + if !backendExists { c.JSON(http.StatusBadRequest, gin.H{ - "error": "Could not find provider", + "error": "Could not find backend", }) } + autoStart := false + + if req.AutoStart != nil { + autoStart = *req.AutoStart + } + proxy := &dbcore.Proxy{ UserID: user.ID, BackendID: req.ProviderID, Name: req.Name, Description: req.Description, - Protocol: req.Protcol, + Protocol: req.Protocol, SourceIP: req.SourceIP, SourcePort: req.SourcePort, DestinationPort: req.DestinationPort, - AutoStart: req.AutoStart, + AutoStart: autoStart, } if result := dbcore.DB.Create(proxy); result.Error != nil { @@ -120,8 +125,50 @@ func CreateProxy(c *gin.Context) { }) } - c.JSON(http.StatusOK, &ProxyCreationResponse{ - Success: true, - Id: proxy.ID, + if autoStart { + backend, ok := backendruntime.RunningBackends[proxy.BackendID] + + if !ok { + log.Warnf("Couldn't fetch backend runtime from backend ID #%d", proxy.BackendID) + + c.JSON(http.StatusOK, gin.H{ + "success": true, + "id": proxy.ID, + }) + + return + } + + backend.RuntimeCommands <- &commonbackend.AddProxy{ + Type: "addProxy", + SourceIP: proxy.SourceIP, + SourcePort: proxy.SourcePort, + DestPort: proxy.DestinationPort, + Protocol: proxy.Protocol, + } + + backendResponse := <-backend.RuntimeCommands + + switch responseMessage := backendResponse.(type) { + case error: + log.Warnf("Failed to get response for backend #%d: %s", proxy.BackendID, responseMessage.Error()) + + c.JSON(http.StatusInternalServerError, gin.H{ + "error": "failed to get response from backend", + }) + + return + case *commonbackend.ProxyStatusResponse: + if !responseMessage.IsActive { + log.Warnf("Failed to start proxy for backend #%d", proxy.BackendID) + } + default: + log.Errorf("Got illegal response type for backend #%d: %T", proxy.BackendID, responseMessage) + } + } + + c.JSON(http.StatusOK, gin.H{ + "success": true, + "id": proxy.ID, }) } diff --git a/backend/api/controllers/v1/proxies/lookup.go b/backend/api/controllers/v1/proxies/lookup.go index 862bcbe..c7e79bb 100644 --- a/backend/api/controllers/v1/proxies/lookup.go +++ b/backend/api/controllers/v1/proxies/lookup.go @@ -19,23 +19,23 @@ type ProxyLookupRequest struct { Name *string `json:"name"` Description *string `json:"description"` Protocol *string `json:"protocol"` - SourceIP *string `json:"source_ip"` - SourcePort *uint16 `json:"source_port"` - DestinationPort *uint16 `json:"destination_port"` - ProviderID *uint `json:"provider_id"` - AutoStart *bool `json:"auto_start"` + SourceIP *string `json:"sourceIP"` + SourcePort *uint16 `json:"sourcePort"` + DestinationPort *uint16 `json:"destPort"` + ProviderID *uint `json:"providerID"` + AutoStart *bool `json:"autoStart"` } type SanitizedProxy struct { Id uint `json:"id"` Name string `json:"name"` Description *string `json:"description"` - Protcol string `json:"protcol"` - SourceIP string `json:"source_ip"` - SourcePort uint16 `json:"source_port"` - DestinationPort uint16 `json:"destination_port"` - ProviderID uint `json:"provider_id"` - AutoStart bool `json:"auto_start"` + Protcol string `json:"protocol"` + SourceIP string `json:"sourceIP"` + SourcePort uint16 `json:"sourcePort"` + DestinationPort uint16 `json:"destPort"` + ProviderID uint `json:"providerID"` + AutoStart bool `json:"autoStart"` } type ProxyLookupResponse struct { @@ -63,6 +63,7 @@ func LookupProxy(c *gin.Context) { } user, err := jwtcore.GetUserFromJWT(req.Token) + if err != nil { if err.Error() == "token is expired" || err.Error() == "user does not exist" { c.JSON(http.StatusForbidden, gin.H{ @@ -89,13 +90,16 @@ func LookupProxy(c *gin.Context) { return } - if *req.Protcol != "tcp" && *req.Protcol != "udp" { - c.JSON(http.StatusBadRequest, gin.H{ - "error": "Protocol specified in body must either be 'tcp' or 'udp'", - }) + if req.Protocol != nil { + if *req.Protocol != "tcp" && *req.Protocol != "udp" { + c.JSON(http.StatusBadRequest, gin.H{ + "error": "Protocol specified in body must either be 'tcp' or 'udp'", + }) + } } proxies := []dbcore.Proxy{} + queryString := []string{} queryParameters := []interface{}{} @@ -103,34 +107,42 @@ func LookupProxy(c *gin.Context) { queryString = append(queryString, "id = ?") queryParameters = append(queryParameters, req.Id) } + if req.Name != nil { queryString = append(queryString, "name = ?") queryParameters = append(queryParameters, req.Name) } + if req.Description != nil { queryString = append(queryString, "description = ?") queryParameters = append(queryParameters, req.Description) } + if req.SourceIP != nil { queryString = append(queryString, "name = ?") queryParameters = append(queryParameters, req.Name) } + if req.SourcePort != nil { queryString = append(queryString, "sourceport = ?") queryParameters = append(queryParameters, req.SourcePort) } + if req.DestinationPort != nil { queryString = append(queryString, "destinationport = ?") queryParameters = append(queryParameters, req.DestinationPort) } + if req.ProviderID != nil { queryString = append(queryString, "backendid = ?") queryParameters = append(queryParameters, req.ProviderID) } + if req.AutoStart != nil { queryString = append(queryString, "autostart = ?") queryParameters = append(queryParameters, req.AutoStart) } + if req.Protocol != nil { queryString = append(queryString, "protocol = ?") queryParameters = append(queryParameters, req.Protocol) @@ -140,7 +152,7 @@ func LookupProxy(c *gin.Context) { log.Warnf("failed to get proxies: %s", err.Error()) c.JSON(http.StatusInternalServerError, gin.H{ - "error": "failed to get forward rules", + "error": "Failed to get proxies", }) return @@ -149,15 +161,10 @@ func LookupProxy(c *gin.Context) { sanitizedProxies := make([]*SanitizedProxy, len(proxies)) for proxyIndex, proxy := range proxies { - description := "" - if proxy.Description != nil { - description = *proxy.Description - } - sanitizedProxies[proxyIndex] = &SanitizedProxy{ Id: proxy.ID, Name: proxy.Name, - Description: &description, + Description: proxy.Description, Protcol: proxy.Protocol, SourceIP: proxy.SourceIP, SourcePort: proxy.SourcePort, diff --git a/backend/api/controllers/v1/proxies/remove.go b/backend/api/controllers/v1/proxies/remove.go index e7b83bb..75e3b66 100644 --- a/backend/api/controllers/v1/proxies/remove.go +++ b/backend/api/controllers/v1/proxies/remove.go @@ -4,9 +4,11 @@ import ( "fmt" "net/http" + "git.terah.dev/imterah/hermes/api/backendruntime" "git.terah.dev/imterah/hermes/api/dbcore" "git.terah.dev/imterah/hermes/api/jwtcore" "git.terah.dev/imterah/hermes/api/permissions" + "git.terah.dev/imterah/hermes/commonbackend" "github.com/charmbracelet/log" "github.com/gin-gonic/gin" "github.com/go-playground/validator/v10" @@ -17,10 +19,6 @@ type ProxyRemovalRequest struct { ID uint `validate:"required" json:"id"` } -type ProxyRemovalResponse struct { - Success bool `json:"success"` -} - func RemoveProxy(c *gin.Context) { var req ProxyRemovalRequest @@ -100,7 +98,56 @@ func RemoveProxy(c *gin.Context) { return } - c.JSON(http.StatusOK, &ProxyRemovalResponse{ - Success: true, + backend, ok := backendruntime.RunningBackends[proxy.BackendID] + + if !ok { + log.Warnf("Couldn't fetch backend runtime from backend ID #%d", proxy.BackendID) + + c.JSON(http.StatusInternalServerError, gin.H{ + "error": "Couldn't fetch backend runtime", + }) + + return + } + + backend.RuntimeCommands <- &commonbackend.RemoveProxy{ + Type: "removeProxy", + SourceIP: proxy.SourceIP, + SourcePort: proxy.SourcePort, + DestPort: proxy.DestinationPort, + Protocol: proxy.Protocol, + } + + backendResponse := <-backend.RuntimeCommands + + switch responseMessage := backendResponse.(type) { + case error: + log.Warnf("Failed to get response for backend #%d: %s", proxy.BackendID, responseMessage.Error()) + + c.JSON(http.StatusInternalServerError, gin.H{ + "error": "Failed to get response from backend. Proxy was still successfully deleted", + }) + + return + case *commonbackend.ProxyStatusResponse: + if responseMessage.IsActive { + c.JSON(http.StatusInternalServerError, gin.H{ + "error": "Failed to stop proxy. Proxy was still successfully deleted", + }) + + return + } + default: + log.Errorf("Got illegal response type for backend #%d: %T", proxy.BackendID, responseMessage) + + c.JSON(http.StatusInternalServerError, gin.H{ + "error": "Got invalid response from backend. Proxy was still successfully deleted", + }) + + return + } + + c.JSON(http.StatusOK, gin.H{ + "success": true, }) } diff --git a/backend/api/controllers/v1/proxies/start.go b/backend/api/controllers/v1/proxies/start.go index d3f36ae..1aedbfc 100644 --- a/backend/api/controllers/v1/proxies/start.go +++ b/backend/api/controllers/v1/proxies/start.go @@ -19,10 +19,6 @@ type ProxyStartRequest struct { ID uint `validate:"required" json:"id"` } -type ProxyStartResponse struct { - Success bool `json:"success"` -} - func StartProxy(c *gin.Context) { var req ProxyStartRequest @@ -92,9 +88,19 @@ func StartProxy(c *gin.Context) { return } - backend := backendruntime.RunningBackends[proxy.BackendID] + backend, ok := backendruntime.RunningBackends[proxy.BackendID] - backend.RuntimeCommands <- commonbackend.AddProxy{ + if !ok { + log.Warnf("Couldn't fetch backend runtime from backend ID #%d", proxy.BackendID) + + c.JSON(http.StatusInternalServerError, gin.H{ + "error": "Couldn't fetch backend runtime", + }) + + return + } + + backend.RuntimeCommands <- &commonbackend.AddProxy{ Type: "addProxy", SourceIP: proxy.SourceIP, SourcePort: proxy.SourcePort, @@ -121,13 +127,19 @@ func StartProxy(c *gin.Context) { return } + break default: log.Errorf("Got illegal response type for backend #%d: %T", proxy.BackendID, responseMessage) - break + + c.JSON(http.StatusInternalServerError, gin.H{ + "error": "Got invalid response from backend. Proxy was still successfully deleted", + }) + + return } - c.JSON(http.StatusOK, &ProxyStartResponse{ - Success: true, + c.JSON(http.StatusOK, gin.H{ + "success": true, }) } diff --git a/backend/api/controllers/v1/proxies/stop.go b/backend/api/controllers/v1/proxies/stop.go index cf94f59..6bbcfef 100644 --- a/backend/api/controllers/v1/proxies/stop.go +++ b/backend/api/controllers/v1/proxies/stop.go @@ -19,10 +19,6 @@ type ProxyStopRequest struct { ID uint `validate:"required" json:"id"` } -type ProxyStopResponse struct { - Success bool `json:"success"` -} - func StopProxy(c *gin.Context) { var req ProxyStopRequest @@ -92,9 +88,19 @@ func StopProxy(c *gin.Context) { return } - backend := backendruntime.RunningBackends[proxy.BackendID] + backend, ok := backendruntime.RunningBackends[proxy.BackendID] - backend.RuntimeCommands <- commonbackend.RemoveProxy{ + if !ok { + log.Warnf("Couldn't fetch backend runtime from backend ID #%d", proxy.BackendID) + + c.JSON(http.StatusInternalServerError, gin.H{ + "error": "Couldn't fetch backend runtime", + }) + + return + } + + backend.RuntimeCommands <- &commonbackend.RemoveProxy{ Type: "removeProxy", SourceIP: proxy.SourceIP, SourcePort: proxy.SourcePort, @@ -102,7 +108,36 @@ func StopProxy(c *gin.Context) { Protocol: proxy.Protocol, } - c.JSON(http.StatusOK, &ProxyStopResponse{ - Success: true, + backendResponse := <-backend.RuntimeCommands + + switch responseMessage := backendResponse.(type) { + case error: + log.Warnf("Failed to get response for backend #%d: %s", proxy.BackendID, responseMessage.Error()) + + c.JSON(http.StatusInternalServerError, gin.H{ + "error": "failed to get response from backend", + }) + + return + case *commonbackend.ProxyStatusResponse: + if responseMessage.IsActive { + c.JSON(http.StatusInternalServerError, gin.H{ + "error": "failed to stop proxy", + }) + + return + } + default: + log.Errorf("Got illegal response type for backend #%d: %T", proxy.BackendID, responseMessage) + + c.JSON(http.StatusInternalServerError, gin.H{ + "error": "Got invalid response from backend. Proxy was still successfully deleted", + }) + + return + } + + c.JSON(http.StatusOK, gin.H{ + "success": true, }) } diff --git a/backend/api/main.go b/backend/api/main.go index 77677c9..57f4894 100644 --- a/backend/api/main.go +++ b/backend/api/main.go @@ -11,7 +11,6 @@ import ( "git.terah.dev/imterah/hermes/api/backendruntime" "git.terah.dev/imterah/hermes/api/controllers/v1/backends" - "git.terah.dev/imterah/hermes/api/controllers/v1/forward" "git.terah.dev/imterah/hermes/api/controllers/v1/proxies" "git.terah.dev/imterah/hermes/api/controllers/v1/users" "git.terah.dev/imterah/hermes/api/dbcore" @@ -202,7 +201,7 @@ func entrypoint(cCtx *cli.Context) error { engine.POST("/api/v1/forward/remove", proxies.RemoveProxy) engine.POST("/api/v1/forward/start", proxies.StartProxy) engine.POST("/api/v1/forward/stop", proxies.StopProxy) - engine.POST("/api/v1/forward/connections", forward.GetConnections) + engine.POST("/api/v1/forward/connections", proxies.GetConnections) log.Infof("Listening on '%s'", listeningAddress) err = engine.Run(listeningAddress) diff --git a/backend/backendutil/application.go b/backend/backendutil/application.go index 926f000..2631209 100644 --- a/backend/backendutil/application.go +++ b/backend/backendutil/application.go @@ -38,7 +38,6 @@ func (helper *BackendApplicationHelper) Start() error { switch commandType { case "start": - // TODO: implement response logic command, ok := commandRaw.(*commonbackend.Start) if !ok { @@ -75,7 +74,6 @@ func (helper *BackendApplicationHelper) Start() error { helper.socket.Write(responseMarshalled) case "stop": - // TODO: implement response logic _, ok := commandRaw.(*commonbackend.Stop) if !ok { @@ -112,7 +110,6 @@ func (helper *BackendApplicationHelper) Start() error { helper.socket.Write(responseMarshalled) case "addProxy": - // TODO: implement response logic command, ok := commandRaw.(*commonbackend.AddProxy) if !ok { @@ -148,14 +145,40 @@ func (helper *BackendApplicationHelper) Start() error { helper.socket.Write(responseMarshalled) case "removeProxy": - // TODO: implement response logic command, ok := commandRaw.(*commonbackend.RemoveProxy) if !ok { return fmt.Errorf("failed to typecast") } - _, _ = helper.Backend.StopProxy(command) + ok, err = helper.Backend.StopProxy(command) + var hasAnyFailed bool + + if !ok { + log.Warnf("failed to remove proxy (%s:%d -> remote:%d): RemoveProxy returned into failure state", command.SourceIP, command.SourcePort, command.DestPort) + hasAnyFailed = true + } else if err != nil { + log.Warnf("failed to remove proxy (%s:%d -> remote:%d): %s", command.SourceIP, command.SourcePort, command.DestPort, err.Error()) + hasAnyFailed = true + } + + response := &commonbackend.ProxyStatusResponse{ + Type: "proxyStatusResponse", + SourceIP: command.SourceIP, + SourcePort: command.SourcePort, + DestPort: command.DestPort, + Protocol: command.Protocol, + IsActive: hasAnyFailed, + } + + responseMarshalled, err := commonbackend.Marshal(response.Type, response) + + if err != nil { + log.Error("failed to marshal response: %s", err.Error()) + continue + } + + helper.socket.Write(responseMarshalled) case "proxyConnectionsRequest": _, ok := commandRaw.(*commonbackend.ProxyConnectionsRequest) @@ -180,7 +203,6 @@ func (helper *BackendApplicationHelper) Start() error { return err } case "checkClientParameters": - // TODO: implement response logic command, ok := commandRaw.(*commonbackend.CheckClientParameters) if !ok { @@ -201,7 +223,6 @@ func (helper *BackendApplicationHelper) Start() error { return err } case "checkServerParameters": - // TODO: implement response logic command, ok := commandRaw.(*commonbackend.CheckServerParameters) if !ok { diff --git a/routes/Hermes API/Forward/Create.bru b/routes/Hermes API/Forward/Create.bru index 985fd9d..9251be6 100644 --- a/routes/Hermes API/Forward/Create.bru +++ b/routes/Hermes API/Forward/Create.bru @@ -5,24 +5,24 @@ meta { } post { - url: http://127.0.0.1:3000/api/v1/forward/create + url: http://127.0.0.1:8000/api/v1/forward/create body: json auth: none } body:json { { - "token": "914abf2223f84375eed884671bfaefd7755d378af496b345f322214e75b51ed4465f11e26c944914c9b4fcc35c53250325fbc6530853ddfed8f72976d6fc5", + "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiMSJdLCJleHAiOjE3MzUwNzY0MTEsIm5iZiI6MTczNDk5MDAxMSwiaWF0IjoxNzM0OTkwMDExfQ.N9TLraX4peHt7FKv8tPcHuEzL0K7T2IBEw3piQS_4OY", "name": "Test Route", "description": "This is a test route for SSH", "protocol": "tcp", "sourceIP": "127.0.0.1", - "sourcePort": "8000", + "sourcePort": 8000, - "destinationPort": "9000", + "destinationPort": 9000, - "providerID": "1" + "providerID": 2 } } diff --git a/routes/Hermes API/Forward/Get Inbound Connections.bru b/routes/Hermes API/Forward/Get Inbound Connections.bru index b61a7c4..9442285 100644 --- a/routes/Hermes API/Forward/Get Inbound Connections.bru +++ b/routes/Hermes API/Forward/Get Inbound Connections.bru @@ -5,14 +5,14 @@ meta { } post { - url: http://127.0.0.1:3000/api/v1/forward/connections + url: http://127.0.0.1:8000/api/v1/forward/connections body: json auth: none } body:json { { - "token": "914abf2223f84375eed884671bfaefd7755d378af496b345f322214e75b51ed4465f11e26c944914c9b4fcc35c53250325fbc6530853ddfed8f72976d6fc5", - "id": "1" + "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiMSJdLCJleHAiOjE3MzUwNzY0MTEsIm5iZiI6MTczNDk5MDAxMSwiaWF0IjoxNzM0OTkwMDExfQ.N9TLraX4peHt7FKv8tPcHuEzL0K7T2IBEw3piQS_4OY", + "id": 1 } } diff --git a/routes/Hermes API/Forward/Lookup.bru b/routes/Hermes API/Forward/Lookup.bru index a8d60b3..54e1b5c 100644 --- a/routes/Hermes API/Forward/Lookup.bru +++ b/routes/Hermes API/Forward/Lookup.bru @@ -5,14 +5,14 @@ meta { } post { - url: http://127.0.0.1:3000/api/v1/forward/lookup + url: http://127.0.0.1:8000/api/v1/forward/lookup body: json auth: none } body:json { { - "token": "535c80825631c04b9add7a8682e06799d62ba57b5089b557f5bab2183fc9926b187b3b8d96da8ef16c67ec80f2917cf81bc21337f47728534f58ac9c4ed5f3fe", + "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiMSJdLCJleHAiOjE3MzUwNzY0MTEsIm5iZiI6MTczNDk5MDAxMSwiaWF0IjoxNzM0OTkwMDExfQ.N9TLraX4peHt7FKv8tPcHuEzL0K7T2IBEw3piQS_4OY", "protocol": "tcp" } } diff --git a/routes/Hermes API/Forward/Remove.bru b/routes/Hermes API/Forward/Remove.bru index 4d6b8e5..897b37b 100644 --- a/routes/Hermes API/Forward/Remove.bru +++ b/routes/Hermes API/Forward/Remove.bru @@ -5,22 +5,14 @@ meta { } post { - url: http://127.0.0.1:3000/api/v1/forward/remove + url: http://127.0.0.1:8000/api/v1/forward/remove body: json auth: none } body:json { { - "token": "f1b89cc337073476289ade17ffbe7a6419b4bd52aa7ede26114bffd76fa263b5cb1bcaf389462e1d9e7acb7f4b6a7c28152a9cc9af83e3ec862f1892b1", - "name": "Test Route", - "description": "This is a test route for portcopier.", - - "sourceIP": "127.0.0.1", - "sourcePort": "8000", - - "destinationPort": "9000", - - "providerID": "1" + "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiMSJdLCJleHAiOjE3MzUwNzY0MTEsIm5iZiI6MTczNDk5MDAxMSwiaWF0IjoxNzM0OTkwMDExfQ.N9TLraX4peHt7FKv8tPcHuEzL0K7T2IBEw3piQS_4OY", + "id": 1 } } diff --git a/routes/Hermes API/Forward/Start.bru b/routes/Hermes API/Forward/Start.bru index 65accf8..5ea3d25 100644 --- a/routes/Hermes API/Forward/Start.bru +++ b/routes/Hermes API/Forward/Start.bru @@ -5,14 +5,14 @@ meta { } post { - url: http://127.0.0.1:3000/api/v1/forward/start + url: http://127.0.0.1:8000/api/v1/forward/start body: json auth: none } body:json { { - "token": "914abf2223f84375eed884671bfaefd7755d378af496b345f322214e75b51ed4465f11e26c944914c9b4fcc35c53250325fbc6530853ddfed8f72976d6fc5", - "id": "1" + "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiMSJdLCJleHAiOjE3MzUwNzY0MTEsIm5iZiI6MTczNDk5MDAxMSwiaWF0IjoxNzM0OTkwMDExfQ.N9TLraX4peHt7FKv8tPcHuEzL0K7T2IBEw3piQS_4OY", + "id": 1 } } diff --git a/routes/Hermes API/Forward/Stop.bru b/routes/Hermes API/Forward/Stop.bru index 896fc71..c2fd445 100644 --- a/routes/Hermes API/Forward/Stop.bru +++ b/routes/Hermes API/Forward/Stop.bru @@ -5,14 +5,14 @@ meta { } post { - url: http://127.0.0.1:3000/api/v1/forward/stop + url: http://127.0.0.1:8000/api/v1/forward/stop body: json auth: none } body:json { { - "token": "914abf2223f84375eed884671bfaefd7755d378af496b345f322214e75b51ed4465f11e26c944914c9b4fcc35c53250325fbc6530853ddfed8f72976d6fc5", - "id": "1" + "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiMSJdLCJleHAiOjE3MzUwNzY0MTEsIm5iZiI6MTczNDk5MDAxMSwiaWF0IjoxNzM0OTkwMDExfQ.N9TLraX4peHt7FKv8tPcHuEzL0K7T2IBEw3piQS_4OY", + "id": 1 } }