mirror of
https://github.com/qdm12/gluetun.git
synced 2026-05-06 20:10:11 +02:00
feat(server): PUT /v1/portforward route to set ports forwarded (#2392)
This commit is contained in:
committed by
Quentin McGaw
parent
199ad77ec9
commit
724cd3a15e
@@ -2,6 +2,7 @@ package portforward
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sync"
|
||||
@@ -166,6 +167,16 @@ func (l *Loop) GetPortsForwarded() (ports []uint16) {
|
||||
return l.service.GetPortsForwarded()
|
||||
}
|
||||
|
||||
var ErrServiceNotStarted = errors.New("port forwarding service not started")
|
||||
|
||||
func (l *Loop) SetPortsForwarded(ports []uint16) (err error) {
|
||||
if l.service == nil {
|
||||
return fmt.Errorf("%w", ErrServiceNotStarted)
|
||||
}
|
||||
|
||||
return l.service.SetPortsForwarded(l.runCtx, ports)
|
||||
}
|
||||
|
||||
func ptrTo[T any](value T) *T {
|
||||
return &value
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user