/
ips.go
42 lines (31 loc) · 862 Bytes
/
ips.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package models
import (
"fmt"
"net"
)
// IPs ...
type IPs []net.IP
// Save persists the IPs to the database
func (ips *IPs) Save() error {
// Since there is only ever ips single auth value, we'll use the registry
if err := put("registry", "ips", ips); err != nil {
return fmt.Errorf("failed to save auth: %s", err.Error())
}
return nil
}
// Delete deletes the auth record from the database
func (ips *IPs) Delete() error {
// Since there is only ever a single auth value, we'll use the registry
if err := destroy("registry", "ips"); err != nil {
return fmt.Errorf("failed to delete auth: %s", err.Error())
}
return nil
}
// LoadIPs loads the auth entry
func LoadIPs() (IPs, error) {
ips := IPs{}
if err := get("registry", "ips", &ips); err != nil {
return ips, fmt.Errorf("failed to load ips: %s", err.Error())
}
return ips, nil
}