Skip to content

Commit

Permalink
reduced verbosity of the http responses and log the errors as a warni…
Browse files Browse the repository at this point in the history
…ngs instead
  • Loading branch information
jagaimoworks committed Nov 29, 2024
1 parent 25fd6ff commit 32a7f1f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/server/openvpn.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package server
import (
"context"
"encoding/json"
"fmt"
"net/http"
"strings"

Expand Down Expand Up @@ -149,7 +150,8 @@ func (h *openvpnHandler) setPortForwarded(w http.ResponseWriter, r *http.Request

decoder := json.NewDecoder(r.Body)
if err := decoder.Decode(&data); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
h.warner.Warn(fmt.Sprintf("failed setting forwarded ports: %s", err))
http.Error(w, "failed setting forwarded ports", http.StatusBadRequest)
return
}

Expand All @@ -159,7 +161,8 @@ func (h *openvpnHandler) setPortForwarded(w http.ResponseWriter, r *http.Request
}

if err := h.pf.SetPortsForwarded(data.Ports); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
h.warner.Warn(fmt.Sprintf("failed setting forwarded ports: %s", err))
http.Error(w, "failed setting forwarded ports", http.StatusInternalServerError)
return
}

Expand Down

0 comments on commit 32a7f1f

Please sign in to comment.