blob: e5ab9a1ce31c7ed6ba4d60e25adc4afa5ed23b86 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package com.yahoo.vespa.hosted.node.admin.wireguard;
import com.yahoo.config.provision.HostName;
import com.yahoo.config.provision.WireguardKeyWithTimestamp;
import com.yahoo.vespa.hosted.node.admin.task.util.network.VersionedIpAddress;
import java.util.List;
/**
* A wireguard peer. Sorted by hostname. IP addresses are sorted by version, IPv6 first.
* The public key should always be non-null.
*
* @author gjoranv
*/
public record WireguardPeer(HostName hostname,
List<VersionedIpAddress> ipAddresses,
WireguardKeyWithTimestamp keyWithTimestamp) implements Comparable<WireguardPeer> {
public WireguardPeer {
if (ipAddresses.isEmpty()) throw new IllegalArgumentException("No IP addresses for peer node " + hostname.value());
ipAddresses = ipAddresses.stream().sorted().toList();
}
@Override
public int compareTo(WireguardPeer o) {
return hostname.value().compareTo(o.hostname.value());
}
}
|