Skip to content
File

Blob: spec/tun/key.go

go42 lines
1package tun
2 
3import (
4 "fmt"
5 
6 "go.miragespace.co/specter/spec/protocol"
7)
8 
9func DestinationByChordKey(chord *protocol.Node) string {
10 return fmt.Sprintf("/destination/chord/%s", chord.GetAddress())
11}
12 
13func DestinationByTunnelKey(tunnel *protocol.Node) string {
14 return fmt.Sprintf("/destination/tunnel/%s", tunnel.GetAddress())
15}
16 
17func RoutingKey(hostname string, num int) string {
18 return fmt.Sprintf("/tunnel/bundle/%s/%d", hostname, num)
19}
20 
21func ClientTokenKey(token *protocol.ClientToken) string {
22 return fmt.Sprintf("/tunnel/client/token/%s", token.GetToken())
23}
24 
25func ClientHostnamesPrefix(token *protocol.ClientToken) string {
26 return fmt.Sprintf("/tunnel/client/hostnames/%s", token.GetToken())
27}
28 
29func ClientLeaseKey(token *protocol.ClientToken) string {
30 return fmt.Sprintf("/tunnel/client/lease/%s", token.GetToken())
31}
32 
33func CustomHostnameKey(hostname string) string {
34 return fmt.Sprintf("/tunnel/client/custom/%s", hostname)
35}
36 
37func DelegationKey(id string) string { return "/tunnel/delegation/" + id }
38 
39func ClientDelegationsPrefix(token *protocol.ClientToken) string {
40 return fmt.Sprintf("/tunnel/client/delegations/%s", token.GetToken())
41}