mirror of
https://github.com/qdm12/gluetun.git
synced 2026-05-09 20:29:23 +02:00
fix(server/portforward): use port and ports for both single port and multiple ports forwarded
This commit is contained in:
@@ -37,14 +37,9 @@ func (h *portForwardHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
func (h *portForwardHandler) getPortForwarded(w http.ResponseWriter) {
|
func (h *portForwardHandler) getPortForwarded(w http.ResponseWriter) {
|
||||||
ports := h.portForward.GetPortsForwarded()
|
ports := h.portForward.GetPortsForwarded()
|
||||||
encoder := json.NewEncoder(w)
|
encoder := json.NewEncoder(w)
|
||||||
var data any
|
data := portsWrapper{Ports: ports}
|
||||||
switch len(ports) {
|
if len(ports) > 0 {
|
||||||
case 0:
|
data.Port = ports[0] // TODO v4 remove
|
||||||
data = portWrapper{Port: 0} // TODO v4 change to portsWrapper
|
|
||||||
case 1:
|
|
||||||
data = portWrapper{Port: ports[0]} // TODO v4 change to portsWrapper
|
|
||||||
default:
|
|
||||||
data = portsWrapper{Ports: ports}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err := encoder.Encode(data)
|
err := encoder.Encode(data)
|
||||||
|
|||||||
@@ -25,11 +25,8 @@ func (sw *statusWrapper) getStatus() (status models.LoopStatus, err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type portWrapper struct { // TODO v4 remove
|
|
||||||
Port uint16 `json:"port"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type portsWrapper struct {
|
type portsWrapper struct {
|
||||||
|
Port uint16 `json:"port"` // TODO v4 remove
|
||||||
Ports []uint16 `json:"ports"`
|
Ports []uint16 `json:"ports"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user