Skip to content

Commit

Permalink
Code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
hjdhjd authored and donavanbecker committed Jul 5, 2024
1 parent 9b12b99 commit b189bb3
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/coder/records/ARecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import net from "net";
import { DNSLabelCoder } from "../DNSLabelCoder";
import { DecodedData, RType } from "../DNSPacket";
import { RecordRepresentation, ResourceRecord } from "../ResourceRecord";
import { getIPFromV4Mapped, isIPv4Mapped } from "../../util/v4mapped";

export class ARecord extends ResourceRecord {

Expand All @@ -21,13 +20,9 @@ export class ARecord extends ResourceRecord {
super(name);
}

// Adjust validation to accept IPv4-mapped IPv6 addresses
const isIPv4 = net.isIPv4(ipAddress);
const isV4Mapped = isIPv4Mapped(ipAddress);
assert(isIPv4 || isV4Mapped, "IP address is not in v4 or IPv4-mapped v6 format!");
assert(net.isIPv4(ipAddress), "IP address is not in v4 or IPv4-mapped v6 format!");

// Store the original IP address or convert IPv4-mapped IPv6 to IPv4
this.ipAddress = isV4Mapped ? getIPFromV4Mapped(ipAddress) as string : ipAddress;
this.ipAddress = ipAddress;
}

protected getRDataEncodingLength(): number {
Expand Down

0 comments on commit b189bb3

Please sign in to comment.