Public IP endpoint with GET /ip fixing #319

This commit is contained in:
Quentin McGaw
2020-12-27 21:06:00 +00:00
parent 2dc674559e
commit 82a02287ac
7 changed files with 92 additions and 5 deletions

View File

@@ -0,0 +1,17 @@
package publicip
import "net"
func (l *looper) GetPublicIP() (publicIP net.IP) {
l.ipMutex.RLock()
defer l.ipMutex.RUnlock()
publicIP = make(net.IP, len(l.ip))
copy(publicIP, l.ip)
return publicIP
}
func (l *looper) setPublicIP(publicIP net.IP) {
l.ipMutex.Lock()
defer l.ipMutex.Unlock()
l.ip = publicIP
}