summaryrefslogtreecommitdiff
path: root/src/main/java/io/trygvis
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2021-01-06 10:16:51 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2021-01-06 10:16:51 +0100
commit9eac79348242b5dc33f4cccdd86beda2a4ed4746 (patch)
tree95eaed3ba80ce4e39c3843f5c39cafe27479861b /src/main/java/io/trygvis
parent2dcbdffc28b9eeaab68eb7c90eb8813899bd9546 (diff)
downloadrules-sandbox-9eac79348242b5dc33f4cccdd86beda2a4ed4746.tar.gz
rules-sandbox-9eac79348242b5dc33f4cccdd86beda2a4ed4746.tar.bz2
rules-sandbox-9eac79348242b5dc33f4cccdd86beda2a4ed4746.tar.xz
rules-sandbox-9eac79348242b5dc33f4cccdd86beda2a4ed4746.zip
Implementing VPN connections.
Diffstat (limited to 'src/main/java/io/trygvis')
-rw-r--r--src/main/java/io/trygvis/rules/engine/Main.java11
-rw-r--r--src/main/java/io/trygvis/rules/network/Ipv4Address.java24
2 files changed, 29 insertions, 6 deletions
diff --git a/src/main/java/io/trygvis/rules/engine/Main.java b/src/main/java/io/trygvis/rules/engine/Main.java
index 6f04a98..7c96be6 100644
--- a/src/main/java/io/trygvis/rules/engine/Main.java
+++ b/src/main/java/io/trygvis/rules/engine/Main.java
@@ -41,11 +41,12 @@ public class Main {
io.dump("phase-1", session.getFactHandles());
io.dump("vpn0", session.getFactHandles(), (Object o) ->
- o.getClass().getName().contains("Wg") ||
- o instanceof Machine ||
- o instanceof DnsEntry ||
- o instanceof Ipv4Cidr ||
- o instanceof Ipv4Address);
+ o.getClass().getName().contains("Wg")
+ || o instanceof Machine
+ || o instanceof DnsEntry
+ || o instanceof Ipv4Cidr
+ || o instanceof Ipv4Address
+ );
session.dispose();
}
diff --git a/src/main/java/io/trygvis/rules/network/Ipv4Address.java b/src/main/java/io/trygvis/rules/network/Ipv4Address.java
index 071bca9..7ca9ca5 100644
--- a/src/main/java/io/trygvis/rules/network/Ipv4Address.java
+++ b/src/main/java/io/trygvis/rules/network/Ipv4Address.java
@@ -6,9 +6,10 @@ import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.io.IOException;
+import java.util.Objects;
@JsonSerialize(using = Ipv4Address.Serializer.class)
-public class Ipv4Address {
+public class Ipv4Address implements Comparable<Ipv4Address> {
public final int address;
public Ipv4Address(int address) {
@@ -16,6 +17,27 @@ public class Ipv4Address {
}
@Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+
+ if (o instanceof Ipv4Address other) {
+ return address == other.address;
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(address);
+ }
+
+ @Override
+ public int compareTo(Ipv4Address o) {
+ return address - o.address;
+ }
+
+ @Override
public String toString() {
return "%d.%d.%d.%d".formatted(
address >> 24 & 0xff,