As it currently stands, the OptAnswer Answer type is a problem for this code because it is the only type that lacks a data key in its object definition.
This caused intractable type issues when attempting to do things like
src/server/types.ts: Updated the PacketWrapper class to use SupportedAnswer instead of dnsPacket.Answer for better type safety.
src/server/types.ts: Updated the DNSResponse class to use SupportedAnswer instead of dnsPacket.Answer for the answer method.
src/index.ts and tests/server.spec.ts: Removed non-null assertion operators from res.packet.answers in multiple locations. [1][2][3][4]
Type Definition Updates:
src/types/dnsLibTypes.ts: Added new type definitions SupportedAnswer and SupportedRecordType to exclude unsupported answers and define supported record types. [1][2]
As it currently stands, the
OptAnswer
Answer type is a problem for this code because it is the only type that lacks adata
key in its object definition.This caused intractable type issues when attempting to do things like
This pull request notably introduces an exclusion of support for the OPT query type for now.
This PR also replaces non-null assertion operators and updates a few type definitions.
Type Safety Improvements:
src/common/logger/consoleLogger.ts
: Removed non-null assertion operators fromres.packet.answers
and simplified the logging statement.src/server/types.ts
: Updated thePacketWrapper
class to useSupportedAnswer
instead ofdnsPacket.Answer
for better type safety.src/server/types.ts
: Updated theDNSResponse
class to useSupportedAnswer
instead ofdnsPacket.Answer
for theanswer
method.src/index.ts
andtests/server.spec.ts
: Removed non-null assertion operators fromres.packet.answers
in multiple locations. [1] [2] [3] [4]Type Definition Updates:
src/types/dnsLibTypes.ts
: Added new type definitionsSupportedAnswer
andSupportedRecordType
to exclude unsupported answers and define supported record types. [1] [2]Code Readability Improvements:
src/common/store/trieStore.spec.ts
: Reformatted code for better readability in test cases involving wildcard matches. [1] [2]src/common/store/trieStore.ts
: Removed an unnecessary blank line in theAnswerTrie
class.