mirror of
https://github.com/qdm12/gluetun.git
synced 2026-06-20 11:02:59 +02:00
Maint: rework publicip package
- Use loopstate package - Loop interface composition - Return concrete struct from constructors - Split into more files - Add publicip/state package
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package state
|
||||
|
||||
import (
|
||||
"net"
|
||||
)
|
||||
|
||||
type PublicIPGetSetter interface {
|
||||
PublicIPGetter
|
||||
SetPublicIP(publicIP net.IP)
|
||||
}
|
||||
|
||||
type PublicIPGetter interface {
|
||||
GetPublicIP() (publicIP net.IP)
|
||||
}
|
||||
|
||||
func (s *State) GetPublicIP() (publicIP net.IP) {
|
||||
s.publicIPMu.RLock()
|
||||
defer s.publicIPMu.RUnlock()
|
||||
publicIP = make(net.IP, len(s.publicIP))
|
||||
copy(publicIP, s.publicIP)
|
||||
return publicIP
|
||||
}
|
||||
|
||||
func (s *State) SetPublicIP(publicIP net.IP) {
|
||||
s.settingsMu.Lock()
|
||||
defer s.settingsMu.Unlock()
|
||||
s.publicIP = make(net.IP, len(publicIP))
|
||||
copy(s.publicIP, publicIP)
|
||||
}
|
||||
Reference in New Issue
Block a user