Fix deserialization of DNS records not working
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m39s

This commit is contained in:
Braydon 2024-04-10 10:29:32 -04:00
parent 0cb6d3f028
commit 27beec9dc7
3 changed files with 17 additions and 21 deletions

@ -23,27 +23,24 @@
*/ */
package me.braydon.mc.model.dns; package me.braydon.mc.model.dns;
import lombok.AllArgsConstructor; import lombok.*;
import lombok.Getter;
import lombok.NonNull;
import lombok.ToString;
/** /**
* A representation of a DNS record. * A representation of a DNS record.
* *
* @author Braydon * @author Braydon
*/ */
@AllArgsConstructor @Getter @ToString @NoArgsConstructor @AllArgsConstructor @Setter @Getter @ToString
public abstract class DNSRecord { public abstract class DNSRecord {
/** /**
* The type of this record. * The type of this record.
*/ */
@NonNull private final Type type; @NonNull private Type type;
/** /**
* The TTL (Time To Live) of this record. * The TTL (Time To Live) of this record.
*/ */
private final long ttl; private long ttl;
/** /**
* Types of a record. * Types of a record.

@ -23,25 +23,26 @@
*/ */
package me.braydon.mc.model.dns.impl; package me.braydon.mc.model.dns.impl;
import lombok.Getter; import lombok.*;
import lombok.NonNull;
import lombok.ToString;
import me.braydon.mc.model.dns.DNSRecord; import me.braydon.mc.model.dns.DNSRecord;
import java.net.InetAddress;
/** /**
* An A record implementation. * An A record implementation.
* *
* @author Braydon * @author Braydon
*/ */
@Getter @ToString(callSuper = true) @NoArgsConstructor @Setter @Getter @ToString(callSuper = true)
public final class ARecord extends DNSRecord { public final class ARecord extends DNSRecord {
/** /**
* The address of this record, null if unresolved. * The address of this record, null if unresolved.
*/ */
private final String address; private String address;
public ARecord(@NonNull org.xbill.DNS.ARecord bootstrap) { public ARecord(@NonNull org.xbill.DNS.ARecord bootstrap) {
super(Type.A, bootstrap.getTTL()); super(Type.A, bootstrap.getTTL());
address = bootstrap.getAddress().getHostAddress(); InetAddress address = bootstrap.getAddress();
this.address = address == null ? null : address.getHostAddress();
} }
} }

@ -24,9 +24,7 @@
package me.braydon.mc.model.dns.impl; package me.braydon.mc.model.dns.impl;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter; import lombok.*;
import lombok.NonNull;
import lombok.ToString;
import me.braydon.mc.model.dns.DNSRecord; import me.braydon.mc.model.dns.DNSRecord;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
@ -36,27 +34,27 @@ import java.net.InetSocketAddress;
* *
* @author Braydon * @author Braydon
*/ */
@Getter @ToString(callSuper = true) @NoArgsConstructor @Setter @Getter @ToString(callSuper = true)
public final class SRVRecord extends DNSRecord { public final class SRVRecord extends DNSRecord {
/** /**
* The priority of this record. * The priority of this record.
*/ */
private final int priority; private int priority;
/** /**
* The weight of this record. * The weight of this record.
*/ */
private final int weight; private int weight;
/** /**
* The port of this record. * The port of this record.
*/ */
private final int port; private int port;
/** /**
* The target of this record. * The target of this record.
*/ */
@NonNull private final String target; @NonNull private String target;
public SRVRecord(@NonNull org.xbill.DNS.SRVRecord bootstrap) { public SRVRecord(@NonNull org.xbill.DNS.SRVRecord bootstrap) {
super(Type.SRV, bootstrap.getTTL()); super(Type.SRV, bootstrap.getTTL());