wip: prepare peer

This commit is contained in:
Christoph Haas 2023-06-22 19:15:29 +02:00
parent c1735a27ce
commit e38c48bede

View File

@ -630,6 +630,7 @@ func (m Manager) PreparePeer(ctx context.Context, id domain.InterfaceIdentifier)
peerMode = domain.InterfaceTypeServer peerMode = domain.InterfaceTypeServer
} }
peerId := domain.PeerIdentifier(uuid.New().String())
freshPeer := &domain.Peer{ freshPeer := &domain.Peer{
BaseModel: domain.BaseModel{ BaseModel: domain.BaseModel{
CreatedBy: string(currentUser.Id), CreatedBy: string(currentUser.Id),
@ -637,14 +638,14 @@ func (m Manager) PreparePeer(ctx context.Context, id domain.InterfaceIdentifier)
CreatedAt: time.Now(), CreatedAt: time.Now(),
UpdatedAt: time.Now(), UpdatedAt: time.Now(),
}, },
Endpoint: domain.StringConfigOption{}, Endpoint: domain.NewStringConfigOption(iface.PeerDefEndpoint, true),
EndpointPublicKey: "", EndpointPublicKey: iface.PublicKey,
AllowedIPsStr: domain.StringConfigOption{}, AllowedIPsStr: domain.NewStringConfigOption(iface.PeerDefAllowedIPsStr, true),
ExtraAllowedIPsStr: "", ExtraAllowedIPsStr: "",
PresharedKey: pk, PresharedKey: pk,
PersistentKeepalive: domain.IntConfigOption{}, PersistentKeepalive: domain.NewIntConfigOption(iface.PeerDefPersistentKeepalive, true),
DisplayName: "", DisplayName: fmt.Sprintf("Peer %s", peerId[0:8]),
Identifier: domain.PeerIdentifier(uuid.New().String()), Identifier: peerId,
UserIdentifier: currentUser.Id, UserIdentifier: currentUser.Id,
InterfaceIdentifier: iface.Identifier, InterfaceIdentifier: iface.Identifier,
Disabled: nil, Disabled: nil,
@ -654,17 +655,17 @@ func (m Manager) PreparePeer(ctx context.Context, id domain.InterfaceIdentifier)
Interface: domain.PeerInterfaceConfig{ Interface: domain.PeerInterfaceConfig{
KeyPair: kp, KeyPair: kp,
Type: peerMode, Type: peerMode,
Addresses: nil, Addresses: nil, // TODO
CheckAliveAddress: "", CheckAliveAddress: "",
DnsStr: domain.StringConfigOption{}, DnsStr: domain.NewStringConfigOption(iface.PeerDefDnsStr, true),
DnsSearchStr: domain.StringConfigOption{}, DnsSearchStr: domain.NewStringConfigOption(iface.PeerDefDnsSearchStr, true),
Mtu: domain.IntConfigOption{}, Mtu: domain.NewIntConfigOption(iface.PeerDefMtu, true),
FirewallMark: domain.Int32ConfigOption{}, FirewallMark: domain.NewInt32ConfigOption(iface.PeerDefFirewallMark, true),
RoutingTable: domain.StringConfigOption{}, RoutingTable: domain.NewStringConfigOption(iface.PeerDefRoutingTable, true),
PreUp: domain.StringConfigOption{}, PreUp: domain.NewStringConfigOption(iface.PeerDefPreUp, true),
PostUp: domain.StringConfigOption{}, PostUp: domain.NewStringConfigOption(iface.PeerDefPostUp, true),
PreDown: domain.StringConfigOption{}, PreDown: domain.NewStringConfigOption(iface.PeerDefPreUp, true),
PostDown: domain.StringConfigOption{}, PostDown: domain.NewStringConfigOption(iface.PeerDefPostUp, true),
}, },
} }