64 lines
1.7 KiB
C++
64 lines
1.7 KiB
C++
|
/***
|
||
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||
|
|
||
|
File: AuNetResolver.Unix.hpp
|
||
|
Date: 2022-8-26
|
||
|
Author: Reece
|
||
|
***/
|
||
|
#pragma once
|
||
|
|
||
|
#include "AuNetSocketOverlappedOperation.hpp"
|
||
|
#include "AuNetSocket.hpp"
|
||
|
|
||
|
namespace Aurora::IO::Net
|
||
|
{
|
||
|
struct Socket;
|
||
|
struct ThreadLocalCaughtCompletion;
|
||
|
|
||
|
struct NetResolver :
|
||
|
SocketOverlappedOperation,
|
||
|
IResolver,
|
||
|
AuEnableSharedFromThis<NetResolver>
|
||
|
{
|
||
|
NetResolver(const AuSPtr<INetWorker> &pWorker);
|
||
|
NetResolver(const AuSPtr<INetWorker> &pWorker,
|
||
|
const AuSPtr<AuAsync::PromiseCallback<AuList<IPAddress>, NetError>> &pCompletion);
|
||
|
~NetResolver();
|
||
|
|
||
|
bool bA {};
|
||
|
bool bAAAA {};
|
||
|
AuString hostname;
|
||
|
|
||
|
bool Start();
|
||
|
|
||
|
void SetCompletion(const AuSPtr<AuAsync::PromiseCallback<AuList<IPAddress>, NetError>> &callback);
|
||
|
|
||
|
void OnOverlappedComplete() override;
|
||
|
void OnOverlappedFailure(const NetError &error) override;
|
||
|
|
||
|
bool HasFinished() override;
|
||
|
void Cancel() override;
|
||
|
const NetError &GetError() override;
|
||
|
|
||
|
bool UnpackEarly();
|
||
|
bool Unpack();
|
||
|
|
||
|
AuSPtr<Loop::ILSEvent> pEvent;
|
||
|
|
||
|
private:
|
||
|
AuSPtr<INetWorker> pWorker_;
|
||
|
AuList<IPAddress> processedIps_;
|
||
|
AuSPtr<AuAsync::PromiseCallback<AuList<IPAddress>, NetError>> pCompletion_;
|
||
|
bool bHasCompleted_ {};
|
||
|
bool bHasUnpackedEarly {};
|
||
|
NetError error_;
|
||
|
|
||
|
addrinfo infoEx { 0 };
|
||
|
|
||
|
gaicb gnuAsyncOperation {}; // freetarded
|
||
|
bool CheckAsync();
|
||
|
friend struct ThreadLocalCaughtCompletion;
|
||
|
};
|
||
|
|
||
|
void InitFreetardedResolver();
|
||
|
}
|