summaryrefslogtreecommitdiffhomepage
path: root/src/routing.go
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2017-06-01 21:31:30 +0200
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2017-06-01 21:31:30 +0200
commitec3d656bebb9ee7c38724500779b7ad322ba0377 (patch)
tree766c47aa8bcd69e6d6db1383dfdf62fc861723c1 /src/routing.go
parent8ce921987fbc91064cf4a14839ef792fecbb0d80 (diff)
Inital implementation of trie
Diffstat (limited to 'src/routing.go')
-rw-r--r--src/routing.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/routing.go b/src/routing.go
new file mode 100644
index 0000000..99b180c
--- /dev/null
+++ b/src/routing.go
@@ -0,0 +1,22 @@
+package main
+
+import (
+ "sync"
+)
+
+/* Thread-safe high level functions for cryptkey routing.
+ *
+ */
+
+type RoutingTable struct {
+ IPv4 *Trie
+ IPv6 *Trie
+ mutex sync.RWMutex
+}
+
+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)
+}