-
Notifications
You must be signed in to change notification settings - Fork 0
/
structs.go
55 lines (46 loc) · 1.12 KB
/
structs.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
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"net"
"time"
)
// Network represents a network that can be accessed through the portal
type Network struct {
Name string
net.IPNet
}
// Device represents a device that can access the portal
type Device struct {
Name string
net.HardwareAddr
}
// ListNetworks can enumnerate its networks
type ListNetworks interface {
Networks() []Network
}
// Networks can ListNetworks and add/remove networks
type Networks interface {
ListNetworks
AddNetwork(network Network)
RemoveNetwork(network Network)
}
// Devices can manage devices
type Devices interface {
HWAddrExists(hw net.HardwareAddr) bool
AddDevice(networks []string, device Device) // error?
RemoveDevice(device Device) // error?
}
// Backend represents a firewall interface, e.g. iptables
type Backend interface {
Networks
Devices
Open()
Close()
}
// Token represents a token which can be used to gain access to networks by devices
type Token struct {
Name string `json:"name"`
Duration string `json:"duration"`
Keys []string `json:"keys"`
NetworkNames []string `json:"networks"`
duration time.Duration
}