Skip to content
Snippets Groups Projects
Commit 7461adf7 authored by kaiyou's avatar kaiyou
Browse files

Improve the readability of the VPN code

parent ffe2c8c9
No related branches found
No related tags found
No related merge requests found
......@@ -72,12 +72,10 @@ type Cluster struct {
type Unit = daeman.Unit[*Cluster]
func NewManager(settings *ClusterSettings, node *HeptoMeta, logger logr.Logger) *daeman.Manager[*Cluster] {
networking := NewClusterNetworking(settings.Name, node.Name)
node.VpnIP = networking.NodeAddress
cluster := &Cluster{
settings: settings,
thisNode: node,
networking: networking,
networking: NewClusterNetworking(settings.Name, node.Name),
loopbackToken: uuid.NewString(),
nodes: []*HeptoMeta{},
state: &HeptoState{
......
......@@ -13,9 +13,9 @@ type HeptoMeta struct {
Name string `json:"name"`
// Public address of the node
PublicIP netip.Addr `json:"ip"`
// Address of the node over the VPN
// Address of the node over the VPN, set once the VPN is up
VpnIP netip.Prefix `json:"vpnIP"`
// Public key for the wireguard mesh VPN
// Public key for the wireguard mesh VPN, set once the VPN is up
VpnKey string `json:"vpnKey"`
// Node role inside the cluster
Role string `json:"role"`
......@@ -35,6 +35,7 @@ func (m *HeptoMeta) OverlayIP() netip.Prefix {
}
func (m *HeptoMeta) Routes() []netip.Prefix {
// We do not currently support exposing additional routes
return []netip.Prefix{}
}
......
......@@ -28,6 +28,7 @@ var vpn = &Unit{
return err
}
c.settings.Logger.Info("initialized vpn", "key", vpn.PubKey.String())
c.thisNode.VpnIP = c.networking.NodeAddress
c.thisNode.VpnKey = vpn.PubKey.String()
c.vpn = vpn
return nil
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment