mirror of
https://github.com/qdm12/gluetun.git
synced 2026-06-20 02:14:08 +02:00
Maint: loopstate package used in Openvpn state
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package state
|
||||
|
||||
type PortForwardedGetterSetter interface {
|
||||
GetPortForwarded() (port uint16)
|
||||
SetPortForwarded(port uint16)
|
||||
}
|
||||
|
||||
// GetPortForwarded is used by the control HTTP server
|
||||
// to obtain the port currently forwarded.
|
||||
func (s *State) GetPortForwarded() (port uint16) {
|
||||
s.portForwardedMu.RLock()
|
||||
defer s.portForwardedMu.RUnlock()
|
||||
return s.portForwarded
|
||||
}
|
||||
|
||||
// SetPortForwarded is only used from within the OpenVPN loop
|
||||
// to set the port forwarded.
|
||||
func (s *State) SetPortForwarded(port uint16) {
|
||||
s.portForwardedMu.Lock()
|
||||
defer s.portForwardedMu.Unlock()
|
||||
s.portForwarded = port
|
||||
}
|
||||
Reference in New Issue
Block a user