1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:27:43 +00:00

LookupServer: Introduce DNSName

This is a wrapper around a string representing a domain name (such as
"example.com"). It never has a trailing dot.

For now, this class doesn't do much except wrap the raw string. Subsequent
commits will add or move more functionality to it.
This commit is contained in:
Sergey Bugaev 2021-02-14 15:02:02 +03:00 committed by Andreas Kling
parent de811faf55
commit ae1e82fd2f
9 changed files with 117 additions and 38 deletions

View file

@ -26,12 +26,14 @@
#pragma once
#include <AK/String.h>
#include "DNSName.h"
#include <AK/Types.h>
namespace LookupServer {
class DNSQuestion {
public:
DNSQuestion(const String& name, u16 record_type, u16 class_code)
DNSQuestion(const DNSName& name, u16 record_type, u16 class_code)
: m_name(name)
, m_record_type(record_type)
, m_class_code(class_code)
@ -40,20 +42,12 @@ public:
u16 record_type() const { return m_record_type; }
u16 class_code() const { return m_class_code; }
const String& name() const { return m_name; }
bool operator==(const DNSQuestion& other) const
{
return m_name == other.m_name && m_record_type == other.m_record_type && m_class_code == other.m_class_code;
}
bool operator!=(const DNSQuestion& other) const
{
return !(*this == other);
}
const DNSName& name() const { return m_name; }
private:
String m_name;
DNSName m_name;
u16 m_record_type { 0 };
u16 m_class_code { 0 };
};
}