From 27beec9dc748f0a202601c79c12c0ee3aa7dffcc Mon Sep 17 00:00:00 2001 From: Rainnny7 Date: Wed, 10 Apr 2024 10:29:32 -0400 Subject: [PATCH] Fix deserialization of DNS records not working --- .../java/me/braydon/mc/model/dns/DNSRecord.java | 11 ++++------- .../java/me/braydon/mc/model/dns/impl/ARecord.java | 13 +++++++------ .../me/braydon/mc/model/dns/impl/SRVRecord.java | 14 ++++++-------- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/main/java/me/braydon/mc/model/dns/DNSRecord.java b/src/main/java/me/braydon/mc/model/dns/DNSRecord.java index 7949d43..c6fc98a 100644 --- a/src/main/java/me/braydon/mc/model/dns/DNSRecord.java +++ b/src/main/java/me/braydon/mc/model/dns/DNSRecord.java @@ -23,27 +23,24 @@ */ package me.braydon.mc.model.dns; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NonNull; -import lombok.ToString; +import lombok.*; /** * A representation of a DNS record. * * @author Braydon */ -@AllArgsConstructor @Getter @ToString +@NoArgsConstructor @AllArgsConstructor @Setter @Getter @ToString public abstract class DNSRecord { /** * The type of this record. */ - @NonNull private final Type type; + @NonNull private Type type; /** * The TTL (Time To Live) of this record. */ - private final long ttl; + private long ttl; /** * Types of a record. diff --git a/src/main/java/me/braydon/mc/model/dns/impl/ARecord.java b/src/main/java/me/braydon/mc/model/dns/impl/ARecord.java index cc7f45c..63c67f4 100644 --- a/src/main/java/me/braydon/mc/model/dns/impl/ARecord.java +++ b/src/main/java/me/braydon/mc/model/dns/impl/ARecord.java @@ -23,25 +23,26 @@ */ package me.braydon.mc.model.dns.impl; -import lombok.Getter; -import lombok.NonNull; -import lombok.ToString; +import lombok.*; import me.braydon.mc.model.dns.DNSRecord; +import java.net.InetAddress; + /** * An A record implementation. * * @author Braydon */ -@Getter @ToString(callSuper = true) +@NoArgsConstructor @Setter @Getter @ToString(callSuper = true) public final class ARecord extends DNSRecord { /** * The address of this record, null if unresolved. */ - private final String address; + private String address; public ARecord(@NonNull org.xbill.DNS.ARecord bootstrap) { super(Type.A, bootstrap.getTTL()); - address = bootstrap.getAddress().getHostAddress(); + InetAddress address = bootstrap.getAddress(); + this.address = address == null ? null : address.getHostAddress(); } } \ No newline at end of file diff --git a/src/main/java/me/braydon/mc/model/dns/impl/SRVRecord.java b/src/main/java/me/braydon/mc/model/dns/impl/SRVRecord.java index e0ff499..ec6f2e7 100644 --- a/src/main/java/me/braydon/mc/model/dns/impl/SRVRecord.java +++ b/src/main/java/me/braydon/mc/model/dns/impl/SRVRecord.java @@ -24,9 +24,7 @@ package me.braydon.mc.model.dns.impl; import com.fasterxml.jackson.annotation.JsonIgnore; -import lombok.Getter; -import lombok.NonNull; -import lombok.ToString; +import lombok.*; import me.braydon.mc.model.dns.DNSRecord; import java.net.InetSocketAddress; @@ -36,27 +34,27 @@ import java.net.InetSocketAddress; * * @author Braydon */ -@Getter @ToString(callSuper = true) +@NoArgsConstructor @Setter @Getter @ToString(callSuper = true) public final class SRVRecord extends DNSRecord { /** * The priority of this record. */ - private final int priority; + private int priority; /** * The weight of this record. */ - private final int weight; + private int weight; /** * The port of this record. */ - private final int port; + private int port; /** * The target of this record. */ - @NonNull private final String target; + @NonNull private String target; public SRVRecord(@NonNull org.xbill.DNS.SRVRecord bootstrap) { super(Type.SRV, bootstrap.getTTL());