Added new DNS::Resolve static method and organized it per OS.
This commit is contained in:
18
include/ehs/io/socket/BaseDNS.h
Normal file
18
include/ehs/io/socket/BaseDNS.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "Socket.h"
|
||||
#include "ehs/Str.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
class BaseDNS
|
||||
{
|
||||
public:
|
||||
static Str_8 Resolve(AddrType type, const Str_8 &hostname);
|
||||
|
||||
/// Resolves a hostname to an ip address.
|
||||
/// @param [in] hostname The given hostname to resolve.
|
||||
/// @returns The resulting ip address.
|
||||
static Str_8 Resolve(const Str_8 &hostname);
|
||||
};
|
||||
}
|
@@ -146,6 +146,10 @@ namespace ehs
|
||||
/// @returns The result.
|
||||
virtual bool IsBlocking() const = 0;
|
||||
|
||||
virtual void SetIPv6Only(bool value) = 0;
|
||||
|
||||
virtual bool IsIPv6Only() const = 0;
|
||||
|
||||
/// Retrieves whether or not this socket was initialized.
|
||||
/// @returns The result.
|
||||
virtual bool IsValid() const = 0;
|
||||
|
@@ -69,6 +69,10 @@ namespace ehs
|
||||
/// @returns The result.
|
||||
virtual bool IsBlocking() const = 0;
|
||||
|
||||
virtual void SetIPv6Only(bool value) = 0;
|
||||
|
||||
virtual bool IsIPv6Only() const = 0;
|
||||
|
||||
/// Retrieves the bound ip version.
|
||||
/// @returns The result.
|
||||
AddrType GetLocalAddressType() const;
|
||||
|
@@ -1,17 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "ehs/EHS.h"
|
||||
#include "ehs/Str.h"
|
||||
#include "Socket.h"
|
||||
#include "ehs/system/OS.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
class DNS
|
||||
{
|
||||
public:
|
||||
/// Resolves a hostname to an ip address.
|
||||
/// @param [in] hostname The given hostname to resolve.
|
||||
/// @returns The resulting ip address.
|
||||
static Str_8 Resolve(const Str_8& hostname);
|
||||
};
|
||||
}
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
#include "DNS_W32.h"
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
#include "DNS_LNX.h"
|
||||
#endif
|
17
include/ehs/io/socket/DNS_LNX.h
Normal file
17
include/ehs/io/socket/DNS_LNX.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "BaseDNS.h"
|
||||
#include "ehs/EHS.h"
|
||||
#include "ehs/Str.h"
|
||||
#include "Socket.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
class DNS final : public BaseDNS
|
||||
{
|
||||
public:
|
||||
static Str_8 Resolve(AddrType type, const Str_8 &hostname);
|
||||
|
||||
static Str_8 Resolve(const Str_8 &hostname);
|
||||
};
|
||||
}
|
14
include/ehs/io/socket/DNS_W32.h
Normal file
14
include/ehs/io/socket/DNS_W32.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "BaseDNS.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
class DNS final : public BaseDNS
|
||||
{
|
||||
public:
|
||||
static Str_8 Resolve(AddrType type, const Str_8 &hostname);
|
||||
|
||||
static Str_8 Resolve(const Str_8 &hostname);
|
||||
};
|
||||
}
|
@@ -80,6 +80,10 @@ namespace ehs
|
||||
/// @returns The result.
|
||||
bool IsBlocking() const override;
|
||||
|
||||
void SetIPv6Only(bool value) override;
|
||||
|
||||
bool IsIPv6Only() const override;
|
||||
|
||||
bool IsValid() const override;
|
||||
|
||||
private:
|
||||
|
@@ -80,6 +80,10 @@ namespace ehs
|
||||
/// @returns The result.
|
||||
bool IsBlocking() const override;
|
||||
|
||||
void SetIPv6Only(bool value) override;
|
||||
|
||||
bool IsIPv6Only() const override;
|
||||
|
||||
bool IsValid() const override;
|
||||
|
||||
private:
|
||||
|
@@ -68,6 +68,10 @@ namespace ehs
|
||||
/// @returns The result.
|
||||
bool IsBlocking() const override;
|
||||
|
||||
void SetIPv6Only(bool value) override;
|
||||
|
||||
bool IsIPv6Only() const override;
|
||||
|
||||
bool IsValid() const override;
|
||||
|
||||
private:
|
||||
|
@@ -68,6 +68,10 @@ namespace ehs
|
||||
/// @returns The result.
|
||||
bool IsBlocking() const override;
|
||||
|
||||
void SetIPv6Only(bool value) override;
|
||||
|
||||
bool IsIPv6Only() const override;
|
||||
|
||||
bool IsValid() const override;
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user