make the skin renderer less bad (thanks bray)
Some checks failed
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Failing after 17s
Some checks failed
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Failing after 17s
This commit is contained in:
29
src/main/java/cc/fascinated/model/dns/DNSRecord.java
Normal file
29
src/main/java/cc/fascinated/model/dns/DNSRecord.java
Normal file
@ -0,0 +1,29 @@
|
||||
package cc.fascinated.model.dns;
|
||||
|
||||
import io.micrometer.common.lang.NonNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Setter @Getter
|
||||
@NoArgsConstructor @AllArgsConstructor
|
||||
public abstract class DNSRecord {
|
||||
/**
|
||||
* The type of this record.
|
||||
*/
|
||||
@NonNull
|
||||
private Type type;
|
||||
|
||||
/**
|
||||
* The TTL (Time To Live) of this record.
|
||||
*/
|
||||
private long ttl;
|
||||
|
||||
/**
|
||||
* Types of a record.
|
||||
*/
|
||||
public enum Type {
|
||||
A, SRV
|
||||
}
|
||||
}
|
24
src/main/java/cc/fascinated/model/dns/impl/ARecord.java
Normal file
24
src/main/java/cc/fascinated/model/dns/impl/ARecord.java
Normal file
@ -0,0 +1,24 @@
|
||||
package cc.fascinated.model.dns.impl;
|
||||
|
||||
import cc.fascinated.model.dns.DNSRecord;
|
||||
import io.micrometer.common.lang.NonNull;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
@Setter @Getter
|
||||
@NoArgsConstructor
|
||||
public final class ARecord extends DNSRecord {
|
||||
/**
|
||||
* The address of this record, null if unresolved.
|
||||
*/
|
||||
private String address;
|
||||
|
||||
public ARecord(@NonNull org.xbill.DNS.ARecord bootstrap) {
|
||||
super(Type.A, bootstrap.getTTL());
|
||||
InetAddress address = bootstrap.getAddress();
|
||||
this.address = address == null ? null : address.getHostAddress();
|
||||
}
|
||||
}
|
53
src/main/java/cc/fascinated/model/dns/impl/SRVRecord.java
Normal file
53
src/main/java/cc/fascinated/model/dns/impl/SRVRecord.java
Normal file
@ -0,0 +1,53 @@
|
||||
package cc.fascinated.model.dns.impl;
|
||||
|
||||
import cc.fascinated.model.dns.DNSRecord;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.micrometer.common.lang.NonNull;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
@Setter @Getter
|
||||
@NoArgsConstructor
|
||||
public final class SRVRecord extends DNSRecord {
|
||||
/**
|
||||
* The priority of this record.
|
||||
*/
|
||||
private int priority;
|
||||
|
||||
/**
|
||||
* The weight of this record.
|
||||
*/
|
||||
private int weight;
|
||||
|
||||
/**
|
||||
* The port of this record.
|
||||
*/
|
||||
private int port;
|
||||
|
||||
/**
|
||||
* The target of this record.
|
||||
*/
|
||||
@NonNull private String target;
|
||||
|
||||
public SRVRecord(@NonNull org.xbill.DNS.SRVRecord bootstrap) {
|
||||
super(Type.SRV, bootstrap.getTTL());
|
||||
priority = bootstrap.getPriority();
|
||||
weight = bootstrap.getWeight();
|
||||
port = bootstrap.getPort();
|
||||
target = bootstrap.getTarget().toString().replaceFirst("\\.$", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a socket address from
|
||||
* the target and port.
|
||||
*
|
||||
* @return the socket address
|
||||
*/
|
||||
@NonNull @JsonIgnore
|
||||
public InetSocketAddress getSocketAddress() {
|
||||
return new InetSocketAddress(target, port);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user