summaryrefslogtreecommitdiffhomepage
path: root/src/routing.go
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2017-06-28 23:45:45 +0200
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2017-06-28 23:45:45 +0200
commit1f0976a26c1d0a6b5eb2c0aa993f12d89f96eed2 (patch)
tree36771e8468214583a5c3f3441b36662c4108a58c /src/routing.go
parent8236f3afa2eca0aae6c5da9560301c04d882c81b (diff)
Work on UAPI
Cross-platform API (get operation) Handshake initiation creation process Outbound packet flow Fixes from code-review
Diffstat (limited to 'src/routing.go')
-rw-r--r--src/routing.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/routing.go b/src/routing.go
index 4189c25..6a5e1f3 100644
--- a/src/routing.go
+++ b/src/routing.go
@@ -12,9 +12,20 @@ type RoutingTable struct {
mutex sync.RWMutex
}
+func (table *RoutingTable) AllowedIPs(peer *Peer) []net.IPNet {
+ table.mutex.RLock()
+ defer table.mutex.RUnlock()
+
+ allowed := make([]net.IPNet, 10)
+ table.IPv4.AllowedIPs(peer, allowed)
+ table.IPv6.AllowedIPs(peer, allowed)
+ return allowed
+}
+
func (table *RoutingTable) Reset() {
table.mutex.Lock()
defer table.mutex.Unlock()
+
table.IPv4 = nil
table.IPv6 = nil
}
@@ -22,6 +33,7 @@ func (table *RoutingTable) Reset() {
func (table *RoutingTable) RemovePeer(peer *Peer) {
table.mutex.Lock()
defer table.mutex.Unlock()
+
table.IPv4 = table.IPv4.RemovePeer(peer)
table.IPv6 = table.IPv6.RemovePeer(peer)
}