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