[+] (dummy!) ISocketServerLimits.hpp
[+] (dummy!) ISocketChannelLimits.hpp [+] ISocketChannel::GetChannelLimits [+] ISocketBase::GetLockedWorkerThread [+] ISocket::GetSocketServer
This commit is contained in:
parent
216aa01717
commit
dcf94a8b23
@ -11,6 +11,7 @@ namespace Aurora::IO::Net
|
|||||||
{
|
{
|
||||||
struct ISocketChannel;
|
struct ISocketChannel;
|
||||||
struct ISocketDriver;
|
struct ISocketDriver;
|
||||||
|
struct ISocketServer;
|
||||||
|
|
||||||
struct ISocket : virtual ISocketBase
|
struct ISocket : virtual ISocketBase
|
||||||
{
|
{
|
||||||
@ -19,5 +20,7 @@ namespace Aurora::IO::Net
|
|||||||
virtual const NetEndpoint &GetRemoteEndpoint() = 0;
|
virtual const NetEndpoint &GetRemoteEndpoint() = 0;
|
||||||
|
|
||||||
virtual AuSPtr<ISocketDriver> GetUserDriver() = 0;
|
virtual AuSPtr<ISocketDriver> GetUserDriver() = 0;
|
||||||
|
|
||||||
|
virtual AuSPtr<ISocketServer> GetSocketServer() = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
namespace Aurora::IO::Net
|
namespace Aurora::IO::Net
|
||||||
{
|
{
|
||||||
|
struct INetWorker;
|
||||||
|
|
||||||
struct ISocketBase
|
struct ISocketBase
|
||||||
{
|
{
|
||||||
virtual const NetError &GetError() = 0;
|
virtual const NetError &GetError() = 0;
|
||||||
@ -19,6 +21,8 @@ namespace Aurora::IO::Net
|
|||||||
|
|
||||||
virtual AuUInt ToPlatformHandle() = 0;
|
virtual AuUInt ToPlatformHandle() = 0;
|
||||||
|
|
||||||
|
virtual AuSPtr<INetWorker> GetLockedWorkerThread() = 0;
|
||||||
|
|
||||||
AURT_ADD_USR_DATA;
|
AURT_ADD_USR_DATA;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -15,6 +15,7 @@ namespace Aurora::IO::Protocol
|
|||||||
namespace Aurora::IO::Net
|
namespace Aurora::IO::Net
|
||||||
{
|
{
|
||||||
struct ISocket;
|
struct ISocket;
|
||||||
|
struct ISocketChannelLimits;
|
||||||
struct ISocketChannelEventListener;
|
struct ISocketChannelEventListener;
|
||||||
|
|
||||||
struct ISocketChannel : Protocol::IProtocolBaseReader, Protocol::IProtocolBaseWriter
|
struct ISocketChannel : Protocol::IProtocolBaseReader, Protocol::IProtocolBaseWriter
|
||||||
@ -231,6 +232,8 @@ namespace Aurora::IO::Net
|
|||||||
*/
|
*/
|
||||||
virtual void RemoveEventListener(const AuSPtr<ISocketChannelEventListener> &pListener) = 0;
|
virtual void RemoveEventListener(const AuSPtr<ISocketChannelEventListener> &pListener) = 0;
|
||||||
|
|
||||||
|
virtual AuSPtr<ISocketChannelLimits> GetChannelLimits() = 0;
|
||||||
|
|
||||||
AURT_ADD_USR_DATA;
|
AURT_ADD_USR_DATA;
|
||||||
};
|
};
|
||||||
}
|
}
|
26
Include/Aurora/IO/Net/ISocketChannelLimits.hpp
Normal file
26
Include/Aurora/IO/Net/ISocketChannelLimits.hpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/***
|
||||||
|
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||||
|
|
||||||
|
File: ISocketChannelLimits.hpp
|
||||||
|
Date: 2023-11-29
|
||||||
|
Author: Reece
|
||||||
|
***/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Aurora::IO::Net
|
||||||
|
{
|
||||||
|
struct ISocketChannelLimits
|
||||||
|
{
|
||||||
|
virtual AuOptional<AuUInt32> GetBeforeDDoSDCAverageThroughputLimit() = 0;
|
||||||
|
virtual AuOptional<AuUInt32> SetBeforeDDoSDCAverageThroughputLimit(AuOptional<AuUInt32> uNextValue) = 0;
|
||||||
|
|
||||||
|
virtual AuOptional<AuUInt32> GetBeforeDDoSDCFrameTimeMS() = 0;
|
||||||
|
virtual AuOptional<AuUInt32> SetBeforeDDoSDCFrameTimeMS(AuOptional<AuUInt32> uNextValue) = 0;
|
||||||
|
|
||||||
|
virtual AuOptional<AuUInt32> GetBeforeDDoSTickFrameLimitCount() = 0;
|
||||||
|
virtual AuOptional<AuUInt32> SetBeforeDDoSTickFrameLimitCount(AuOptional<AuUInt32> uNextValue) = 0;
|
||||||
|
|
||||||
|
virtual AuOptional<AuUInt32> GetBeforeDDoSTickFrameTimeMS() = 0;
|
||||||
|
virtual AuOptional<AuUInt32> SetBeforeDDoSTickFrameTimeMS(AuOptional<AuUInt32> uNextValue) = 0;
|
||||||
|
};
|
||||||
|
}
|
@ -11,6 +11,8 @@ namespace Aurora::IO::Net
|
|||||||
{
|
{
|
||||||
struct ISocketServer : virtual ISocketBase
|
struct ISocketServer : virtual ISocketBase
|
||||||
{
|
{
|
||||||
|
virtual AuList<AuSPtr<ISocket>> GetChildren() = 0;
|
||||||
|
virtual AuSPtr<ISocketServerLimits> GetLimits() = 0;
|
||||||
virtual AuSPtr<ISocketServerDriver> GetServerDriver() = 0;
|
virtual AuSPtr<ISocketServerDriver> GetServerDriver() = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
44
Include/Aurora/IO/Net/ISocketServerLimits.hpp
Normal file
44
Include/Aurora/IO/Net/ISocketServerLimits.hpp
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/***
|
||||||
|
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||||
|
|
||||||
|
File: ISocketServerLimits.hpp
|
||||||
|
Date: 2023-11-29
|
||||||
|
Author: Reece
|
||||||
|
***/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Aurora::IO::Net
|
||||||
|
{
|
||||||
|
struct ISocketServerLimits
|
||||||
|
{
|
||||||
|
virtual AuOptional<AuUInt32> GetMaxConnectionsPerIp() = 0;
|
||||||
|
virtual AuOptional<AuUInt32> SetMaxConnectionsPerIp(AuOptional<AuUInt32> optNextValue) = 0;
|
||||||
|
|
||||||
|
virtual AuOptional<AuUInt32> GetMaxConnections() = 0;
|
||||||
|
virtual AuOptional<AuUInt32> SetMaxConnections(AuOptional<AuUInt32> optNextValue) = 0;
|
||||||
|
|
||||||
|
virtual AuList<IPAddress> GetWhitelist() = 0;
|
||||||
|
virtual void SetWhitelist(AuList<IPAddress> whitelist) = 0;
|
||||||
|
|
||||||
|
virtual AuList<IPAddress> GetBlacklist() = 0;
|
||||||
|
virtual void SetBlacklist(AuList<IPAddress> blacklist) = 0;
|
||||||
|
|
||||||
|
virtual AuOptional<AuUInt32> GetBeforeDDoSDCAverageThroughputLimit() = 0;
|
||||||
|
virtual AuOptional<AuUInt32> SetBeforeDDoSDCAverageThroughputLimit(AuOptional<AuUInt32> optNextValue) = 0;
|
||||||
|
|
||||||
|
virtual AuOptional<AuUInt32> GetBeforeDDoSDCFrameTimeMS() = 0;
|
||||||
|
virtual AuOptional<AuUInt32> SetBeforeDDoSDCFrameTimeMS(AuOptional<AuUInt32> optNextValue) = 0;
|
||||||
|
|
||||||
|
virtual AuOptional<AuUInt32> GetBeforeDDoSTickFrameLimitCount() = 0;
|
||||||
|
virtual AuOptional<AuUInt32> SetBeforeDDoSTickFrameLimitCount(AuOptional<AuUInt32> optNextValue) = 0;
|
||||||
|
|
||||||
|
virtual AuOptional<AuUInt32> GetBeforeDDoSTickFrameTimeMS() = 0;
|
||||||
|
virtual AuOptional<AuUInt32> SetBeforeDDoSTickFrameTimeMS(AuOptional<AuUInt32> optNextValue) = 0;
|
||||||
|
|
||||||
|
virtual AuOptional<bool> GetAutoBanOnDDoSDetectA() = 0;
|
||||||
|
virtual AuOptional<bool> SetAutoBanOnDDoSDetectA(AuOptional<bool> optNextValue) = 0;
|
||||||
|
|
||||||
|
virtual AuOptional<AuUInt32> GetAutoBanTimeSecs() = 0;
|
||||||
|
virtual AuOptional<AuUInt32> SetAutoBanTimeSecs(AuOptional<AuUInt32> optNextValue) = 0;
|
||||||
|
};
|
||||||
|
}
|
@ -28,6 +28,8 @@
|
|||||||
#include "ISocketChannel.hpp"
|
#include "ISocketChannel.hpp"
|
||||||
#include "ISocketDriverFactory.hpp"
|
#include "ISocketDriverFactory.hpp"
|
||||||
#include "ISocketServerDriver.hpp"
|
#include "ISocketServerDriver.hpp"
|
||||||
|
#include "ISocketServerLimits.hpp"
|
||||||
|
#include "ISocketChannelLimits.hpp"
|
||||||
#include "ISocketServer.hpp"
|
#include "ISocketServer.hpp"
|
||||||
|
|
||||||
#include "IDatagramDriver.hpp"
|
#include "IDatagramDriver.hpp"
|
||||||
|
52
Source/IO/Net/AuNetChannelLimits.cpp
Normal file
52
Source/IO/Net/AuNetChannelLimits.cpp
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/***
|
||||||
|
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||||
|
|
||||||
|
File: AuNetChannelLimits.cpp
|
||||||
|
Date: 2023-11-29
|
||||||
|
Author: Reece
|
||||||
|
***/
|
||||||
|
#include "Networking.hpp"
|
||||||
|
#include "AuNetChannelLimits.hpp"
|
||||||
|
|
||||||
|
namespace Aurora::IO::Net
|
||||||
|
{
|
||||||
|
AuOptional<AuUInt32> NetChannelLimits::GetBeforeDDoSDCAverageThroughputLimit()
|
||||||
|
{
|
||||||
|
return this->optBeforeDDoSDCAverageThroughputLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> NetChannelLimits::SetBeforeDDoSDCAverageThroughputLimit(AuOptional<AuUInt32> uNextValue)
|
||||||
|
{
|
||||||
|
return AuExchange(this->optBeforeDDoSDCAverageThroughputLimit, uNextValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> NetChannelLimits::GetBeforeDDoSDCFrameTimeMS()
|
||||||
|
{
|
||||||
|
return this->optBeforeDDoSDCFrameTimeMS;
|
||||||
|
}
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> NetChannelLimits::SetBeforeDDoSDCFrameTimeMS(AuOptional<AuUInt32> uNextValue)
|
||||||
|
{
|
||||||
|
return AuExchange(this->optBeforeDDoSDCFrameTimeMS, uNextValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> NetChannelLimits::GetBeforeDDoSTickFrameLimitCount()
|
||||||
|
{
|
||||||
|
return this->optBeforeDDoSTickFrameLimitCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> NetChannelLimits::SetBeforeDDoSTickFrameLimitCount(AuOptional<AuUInt32> uNextValue)
|
||||||
|
{
|
||||||
|
return AuExchange(this->optBeforeDDoSTickFrameLimitCount, uNextValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> NetChannelLimits::GetBeforeDDoSTickFrameTimeMS()
|
||||||
|
{
|
||||||
|
return this->optBeforeDDoSTickFrameTimeMS;
|
||||||
|
}
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> NetChannelLimits::SetBeforeDDoSTickFrameTimeMS(AuOptional<AuUInt32> uNextValue)
|
||||||
|
{
|
||||||
|
return AuExchange(this->optBeforeDDoSTickFrameTimeMS, uNextValue);
|
||||||
|
}
|
||||||
|
}
|
31
Source/IO/Net/AuNetChannelLimits.hpp
Normal file
31
Source/IO/Net/AuNetChannelLimits.hpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/***
|
||||||
|
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||||
|
|
||||||
|
File: AuNetChannelLimits.hpp
|
||||||
|
Date: 2023-11-29
|
||||||
|
Author: Reece
|
||||||
|
***/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Aurora::IO::Net
|
||||||
|
{
|
||||||
|
struct NetChannelLimits : ISocketChannelLimits
|
||||||
|
{
|
||||||
|
AuOptional<AuUInt32> GetBeforeDDoSDCAverageThroughputLimit() override;
|
||||||
|
AuOptional<AuUInt32> SetBeforeDDoSDCAverageThroughputLimit(AuOptional<AuUInt32> uNextValue) override;
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> GetBeforeDDoSDCFrameTimeMS() override;
|
||||||
|
AuOptional<AuUInt32> SetBeforeDDoSDCFrameTimeMS(AuOptional<AuUInt32> uNextValue) override;
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> GetBeforeDDoSTickFrameLimitCount() override;
|
||||||
|
AuOptional<AuUInt32> SetBeforeDDoSTickFrameLimitCount(AuOptional<AuUInt32> uNextValue) override;
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> GetBeforeDDoSTickFrameTimeMS() override;
|
||||||
|
AuOptional<AuUInt32> SetBeforeDDoSTickFrameTimeMS(AuOptional<AuUInt32> uNextValue) override;
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> optBeforeDDoSTickFrameTimeMS;
|
||||||
|
AuOptional<AuUInt32> optBeforeDDoSTickFrameLimitCount;
|
||||||
|
AuOptional<AuUInt32> optBeforeDDoSDCFrameTimeMS;
|
||||||
|
AuOptional<AuUInt32> optBeforeDDoSDCAverageThroughputLimit;
|
||||||
|
};
|
||||||
|
}
|
@ -24,8 +24,10 @@ namespace Aurora::IO::Net
|
|||||||
Socket::Socket(struct NetInterface *pInterface,
|
Socket::Socket(struct NetInterface *pInterface,
|
||||||
struct NetWorker *pWorker,
|
struct NetWorker *pWorker,
|
||||||
const AuSPtr<ISocketDriver> &pSocketDriver,
|
const AuSPtr<ISocketDriver> &pSocketDriver,
|
||||||
AuUInt osHandle) :
|
AuUInt osHandle,
|
||||||
SocketBase(pInterface, pWorker, pSocketDriver, osHandle)
|
AuSPtr<ISocketServer> pParent,
|
||||||
|
SocketServer *pParent2) :
|
||||||
|
SocketBase(pInterface, pWorker, pSocketDriver, osHandle, pParent, pParent2)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,9 @@ namespace Aurora::IO::Net
|
|||||||
Socket(struct NetInterface *pInterface,
|
Socket(struct NetInterface *pInterface,
|
||||||
struct NetWorker *pWorker,
|
struct NetWorker *pWorker,
|
||||||
const AuSPtr<ISocketDriver> &pSocketDriver,
|
const AuSPtr<ISocketDriver> &pSocketDriver,
|
||||||
AuUInt osHandle);
|
AuUInt osHandle,
|
||||||
|
AuSPtr<ISocketServer> pParent = {},
|
||||||
|
SocketServer *pParent2 = {});
|
||||||
|
|
||||||
Socket(struct NetInterface *pInterface,
|
Socket(struct NetInterface *pInterface,
|
||||||
struct NetWorker *pWorker,
|
struct NetWorker *pWorker,
|
||||||
|
@ -28,8 +28,9 @@ namespace Aurora::IO::Net
|
|||||||
Socket::Socket(struct NetInterface *pInterface,
|
Socket::Socket(struct NetInterface *pInterface,
|
||||||
struct NetWorker *pWorker,
|
struct NetWorker *pWorker,
|
||||||
const AuSPtr<ISocketDriver> &pSocketDriver,
|
const AuSPtr<ISocketDriver> &pSocketDriver,
|
||||||
AuUInt osHandle) :
|
AuUInt osHandle,
|
||||||
SocketBase(pInterface, pWorker, pSocketDriver, osHandle)
|
AuSPtr<ISocketServer> pParent) :
|
||||||
|
SocketBase(pInterface, pWorker, pSocketDriver, osHandle, pParent)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,9 @@ namespace Aurora::IO::Net
|
|||||||
Socket(struct NetInterface *pInterface,
|
Socket(struct NetInterface *pInterface,
|
||||||
struct NetWorker *pWorker,
|
struct NetWorker *pWorker,
|
||||||
const AuSPtr<ISocketDriver> &pSocketDriver,
|
const AuSPtr<ISocketDriver> &pSocketDriver,
|
||||||
AuUInt osHandle);
|
AuUInt osHandle,
|
||||||
|
AuSPtr<ISocketServer> pParent = {},
|
||||||
|
SocketServer *pParent2 = {});
|
||||||
|
|
||||||
Socket(struct NetInterface *pInterface,
|
Socket(struct NetInterface *pInterface,
|
||||||
struct NetWorker *pWorker,
|
struct NetWorker *pWorker,
|
||||||
|
@ -30,15 +30,18 @@ namespace Aurora::IO::Net
|
|||||||
}
|
}
|
||||||
|
|
||||||
SocketBase::SocketBase(struct NetInterface *pInterface,
|
SocketBase::SocketBase(struct NetInterface *pInterface,
|
||||||
struct NetWorker *pWorker,
|
struct NetWorker *pWorker,
|
||||||
const AuSPtr<ISocketDriver> &pSocketDriver,
|
const AuSPtr<ISocketDriver> &pSocketDriver,
|
||||||
AuUInt osHandle) :
|
AuUInt osHandle,
|
||||||
|
AuSPtr<ISocketServer> pParent,
|
||||||
|
SocketServer *pParent2) :
|
||||||
connectOperation(this),
|
connectOperation(this),
|
||||||
socketChannel_(this),
|
socketChannel_(this),
|
||||||
pInterface_(pInterface),
|
pInterface_(pInterface),
|
||||||
pWorker_(pWorker),
|
pWorker_(pWorker),
|
||||||
pSocketDriver_(pSocketDriver),
|
pSocketDriver_(pSocketDriver),
|
||||||
osHandle_(osHandle)
|
osHandle_(osHandle),
|
||||||
|
wpParent2_(pParent2)
|
||||||
{
|
{
|
||||||
this->pWorker_->AddSocket(this);
|
this->pWorker_->AddSocket(this);
|
||||||
|
|
||||||
@ -55,6 +58,10 @@ namespace Aurora::IO::Net
|
|||||||
this->osHandleOwner_->InitFromPairMove((int)this->osHandle_, (int)this->osHandle_);
|
this->osHandleOwner_->InitFromPairMove((int)this->osHandle_, (int)this->osHandle_);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (pParent)
|
||||||
|
{
|
||||||
|
pParent2->OnNotifyChildCreated(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SocketBase::SocketBase(struct NetInterface *pInterface,
|
SocketBase::SocketBase(struct NetInterface *pInterface,
|
||||||
@ -262,6 +269,11 @@ namespace Aurora::IO::Net
|
|||||||
return this->pSocketDriver_;
|
return this->pSocketDriver_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AuSPtr<INetWorker> SocketBase::GetLockedWorkerThread()
|
||||||
|
{
|
||||||
|
return this->pWorker_->SharedFromThis();
|
||||||
|
}
|
||||||
|
|
||||||
const NetEndpoint &SocketBase::GetRemoteEndpoint()
|
const NetEndpoint &SocketBase::GetRemoteEndpoint()
|
||||||
{
|
{
|
||||||
return this->remoteEndpoint_;
|
return this->remoteEndpoint_;
|
||||||
@ -272,6 +284,11 @@ namespace Aurora::IO::Net
|
|||||||
return this->localEndpoint_;
|
return this->localEndpoint_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AuSPtr<ISocketServer> SocketBase::GetSocketServer()
|
||||||
|
{
|
||||||
|
return AuTryLockMemoryType(this->wpParent_);
|
||||||
|
}
|
||||||
|
|
||||||
void SocketBase::ConnectFinished()
|
void SocketBase::ConnectFinished()
|
||||||
{
|
{
|
||||||
this->UpdateLocalEndpoint();
|
this->UpdateLocalEndpoint();
|
||||||
@ -523,6 +540,11 @@ namespace Aurora::IO::Net
|
|||||||
|
|
||||||
void SocketBase::Destroy()
|
void SocketBase::Destroy()
|
||||||
{
|
{
|
||||||
|
if (auto pParent = AuTryLockMemoryType(this->wpParent_))
|
||||||
|
{
|
||||||
|
this->wpParent2_->OnNotifyChildRemoved(this);
|
||||||
|
}
|
||||||
|
|
||||||
this->SendFinalize();
|
this->SendFinalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -626,7 +648,12 @@ namespace Aurora::IO::Net
|
|||||||
|
|
||||||
this->pSocketDriver_.reset();
|
this->pSocketDriver_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (auto pParent = AuTryLockMemoryType(this->wpParent_))
|
||||||
|
{
|
||||||
|
this->wpParent2_->OnNotifyChildRemoved(this);
|
||||||
|
}
|
||||||
|
|
||||||
auto pWriteTransaction = this->socketChannel_.outputChannel.ToWriteTransaction();
|
auto pWriteTransaction = this->socketChannel_.outputChannel.ToWriteTransaction();
|
||||||
|
|
||||||
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||||
|
@ -22,15 +22,18 @@ namespace Aurora::IO::Net
|
|||||||
struct SocketBase;
|
struct SocketBase;
|
||||||
struct SocketConnectOperation;
|
struct SocketConnectOperation;
|
||||||
struct SocketServerAcceptReadOperation;
|
struct SocketServerAcceptReadOperation;
|
||||||
|
struct SocketServer;
|
||||||
|
|
||||||
struct SocketBase : virtual ISocket, AuEnableSharedFromThis<SocketBase>
|
struct SocketBase : virtual ISocket, AuEnableSharedFromThis<SocketBase>
|
||||||
{
|
{
|
||||||
friend struct SocketServerAcceptReadOperation;
|
friend struct SocketServerAcceptReadOperation;
|
||||||
|
|
||||||
SocketBase(struct NetInterface *pInterface,
|
SocketBase(struct NetInterface *pInterface,
|
||||||
struct NetWorker *pWorker,
|
struct NetWorker *pWorker,
|
||||||
const AuSPtr<ISocketDriver> &pSocketDriver,
|
const AuSPtr<ISocketDriver> &pSocketDriver,
|
||||||
AuUInt osHandle);
|
AuUInt osHandle,
|
||||||
|
AuSPtr<ISocketServer> pParent,
|
||||||
|
SocketServer *pParent2);
|
||||||
|
|
||||||
SocketBase(struct NetInterface *pInterface,
|
SocketBase(struct NetInterface *pInterface,
|
||||||
struct NetWorker *pWorker,
|
struct NetWorker *pWorker,
|
||||||
@ -59,10 +62,14 @@ namespace Aurora::IO::Net
|
|||||||
|
|
||||||
AuSPtr<ISocketDriver> GetUserDriver() override;
|
AuSPtr<ISocketDriver> GetUserDriver() override;
|
||||||
|
|
||||||
|
AuSPtr<INetWorker> GetLockedWorkerThread();
|
||||||
|
|
||||||
const NetEndpoint &GetRemoteEndpoint() override;
|
const NetEndpoint &GetRemoteEndpoint() override;
|
||||||
const NetEndpoint &GetLocalEndpoint() override;
|
const NetEndpoint &GetLocalEndpoint() override;
|
||||||
|
|
||||||
const NetError &GetError() override;
|
const NetError &GetError() override;
|
||||||
|
|
||||||
|
AuSPtr<ISocketServer> GetSocketServer() override;
|
||||||
|
|
||||||
void ConnectFinished();
|
void ConnectFinished();
|
||||||
void ConnectFailed(const NetError &error);
|
void ConnectFailed(const NetError &error);
|
||||||
@ -128,6 +135,8 @@ namespace Aurora::IO::Net
|
|||||||
|
|
||||||
NetEndpoint remoteEndpoint_;
|
NetEndpoint remoteEndpoint_;
|
||||||
NetEndpoint localEndpoint_;
|
NetEndpoint localEndpoint_;
|
||||||
|
AuWPtr<ISocketServer> wpParent_ {};
|
||||||
|
SocketServer *wpParent2_ {};
|
||||||
|
|
||||||
bool bForceFailConstruct_ {};
|
bool bForceFailConstruct_ {};
|
||||||
|
|
||||||
|
@ -349,6 +349,11 @@ namespace Aurora::IO::Net
|
|||||||
bool(this->inputChannel.IsValid());
|
bool(this->inputChannel.IsValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AuSPtr<ISocketChannelLimits> SocketChannel::GetChannelLimits()
|
||||||
|
{
|
||||||
|
return AuSPtr<ISocketChannelLimits>(this->pParent_->SharedFromThis(), &this->channelSecurity_);
|
||||||
|
}
|
||||||
|
|
||||||
bool SocketChannel::SpecifyBufferSize(AuUInt uBytes,
|
bool SocketChannel::SpecifyBufferSize(AuUInt uBytes,
|
||||||
const AuSPtr<AuAsync::PromiseCallback<AuNullS, AuNullS>> &pCallbackOptional)
|
const AuSPtr<AuAsync::PromiseCallback<AuNullS, AuNullS>> &pCallbackOptional)
|
||||||
{
|
{
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "AuNetSocketChannelInput.hpp"
|
#include "AuNetSocketChannelInput.hpp"
|
||||||
#include "AuNetSocketChannelOutput.hpp"
|
#include "AuNetSocketChannelOutput.hpp"
|
||||||
#include "AuSocketStats.hpp"
|
#include "AuSocketStats.hpp"
|
||||||
|
#include "AuNetChannelLimits.hpp"
|
||||||
|
|
||||||
namespace Aurora::IO::Net
|
namespace Aurora::IO::Net
|
||||||
{
|
{
|
||||||
@ -81,6 +82,8 @@ namespace Aurora::IO::Net
|
|||||||
|
|
||||||
void RemoveEventListener(const AuSPtr<ISocketChannelEventListener> &pListener) override;
|
void RemoveEventListener(const AuSPtr<ISocketChannelEventListener> &pListener) override;
|
||||||
|
|
||||||
|
AuSPtr<ISocketChannelLimits> GetChannelLimits() override;
|
||||||
|
|
||||||
SocketStats & GetSendStatsEx();
|
SocketStats & GetSendStatsEx();
|
||||||
SocketStats & GetRecvStatsEx();
|
SocketStats & GetRecvStatsEx();
|
||||||
|
|
||||||
@ -116,6 +119,7 @@ namespace Aurora::IO::Net
|
|||||||
AuSPtr<IO::IStreamReader> pCachedReader;
|
AuSPtr<IO::IStreamReader> pCachedReader;
|
||||||
AuSPtr<IO::IStreamWriter> pCachedWriter;
|
AuSPtr<IO::IStreamWriter> pCachedWriter;
|
||||||
|
|
||||||
|
|
||||||
AuThreadPrimitives::SpinLock spinLock;
|
AuThreadPrimitives::SpinLock spinLock;
|
||||||
AuList<AuSPtr<ISocketChannelEventListener>> eventListeners;
|
AuList<AuSPtr<ISocketChannelEventListener>> eventListeners;
|
||||||
|
|
||||||
@ -128,5 +132,6 @@ namespace Aurora::IO::Net
|
|||||||
SocketBase * pParent_;
|
SocketBase * pParent_;
|
||||||
SocketStats sendStats_;
|
SocketStats sendStats_;
|
||||||
SocketStats recvStats_;
|
SocketStats recvStats_;
|
||||||
|
NetChannelLimits channelSecurity_;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -17,7 +17,7 @@ namespace Aurora::IO::Net
|
|||||||
const AuSPtr<ISocketServerDriver> &pDriver,
|
const AuSPtr<ISocketServerDriver> &pDriver,
|
||||||
const AuSPtr<ISocketDriverFactory> &pSocketDriverFactory,
|
const AuSPtr<ISocketDriverFactory> &pSocketDriverFactory,
|
||||||
AuUInt32 uMaxConnections,
|
AuUInt32 uMaxConnections,
|
||||||
AuUInt32 uDefaultInputStreamSize,
|
AuUInt32 uDefaultInputStreamSize,
|
||||||
bool bMultiThreaded) :
|
bool bMultiThreaded) :
|
||||||
SocketServer(pInterface,
|
SocketServer(pInterface,
|
||||||
pWorker,
|
pWorker,
|
||||||
@ -104,7 +104,7 @@ namespace Aurora::IO::Net
|
|||||||
|
|
||||||
We need a sane number between the two. 512 seems reasonable
|
We need a sane number between the two. 512 seems reasonable
|
||||||
*/
|
*/
|
||||||
if (::listen(this->osHandle_, 512) != 0)
|
if (::listen(this->osHandle_, this->uBacklog) != 0)
|
||||||
{
|
{
|
||||||
NetError error;
|
NetError error;
|
||||||
NetError_SetCurrent(error);
|
NetError_SetCurrent(error);
|
||||||
|
@ -122,7 +122,7 @@ namespace Aurora::IO::Net
|
|||||||
|
|
||||||
We need a sane number between the two. 512 seems reasonable
|
We need a sane number between the two. 512 seems reasonable
|
||||||
*/
|
*/
|
||||||
if (::listen(this->osHandle_, 512) != 0)
|
if (::listen(this->osHandle_, this->uBacklog) != 0)
|
||||||
{
|
{
|
||||||
NetError error;
|
NetError error;
|
||||||
NetError_SetCurrent(error);
|
NetError_SetCurrent(error);
|
||||||
|
@ -130,6 +130,47 @@ namespace Aurora::IO::Net
|
|||||||
return this->pFactory_;
|
return this->pFactory_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AuSPtr<ISocketServerLimits> SocketServer::GetLimits()
|
||||||
|
{
|
||||||
|
return AuSPtr<ISocketServerLimits>(this->SharedFromThis(), &this->serverLimits_);
|
||||||
|
}
|
||||||
|
|
||||||
|
AuList<AuSPtr<ISocket>> SocketServer::GetChildren()
|
||||||
|
{
|
||||||
|
AuList<AuSPtr<ISocket>> ret;
|
||||||
|
AU_LOCK_GUARD(this->childrenMutex);
|
||||||
|
for (const auto &pChild : this->childrenSockets)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ret.push_back(pChild->SharedFromThis());
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SocketServer::OnNotifyChildCreated(SocketBase *pSocket)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
AU_LOCK_GUARD(this->childrenMutex);
|
||||||
|
this->childrenSockets.push_back(pSocket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SocketServer::OnNotifyChildRemoved(SocketBase *pSocket)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
AU_LOCK_GUARD(this->childrenMutex);
|
||||||
|
AuTryRemove(this->childrenSockets, pSocket);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->serverLimits_.NotifyChildRemoved();
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
// ISocketDriver
|
// ISocketDriver
|
||||||
|
|
||||||
|
@ -13,9 +13,12 @@
|
|||||||
#pragma warning(disable: 4250)
|
#pragma warning(disable: 4250)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "AuNetSocketServerLimits.hpp"
|
||||||
|
|
||||||
namespace Aurora::IO::Net
|
namespace Aurora::IO::Net
|
||||||
{
|
{
|
||||||
struct SocketServer;
|
struct SocketServer;
|
||||||
|
struct SocketBase;
|
||||||
|
|
||||||
struct SocketServer : virtual Socket, virtual ISocketDriver, virtual ISocketServer
|
struct SocketServer : virtual Socket, virtual ISocketDriver, virtual ISocketServer
|
||||||
{
|
{
|
||||||
@ -33,6 +36,8 @@ namespace Aurora::IO::Net
|
|||||||
|
|
||||||
AuSPtr<ISocketServerDriver> GetServerDriver() override;
|
AuSPtr<ISocketServerDriver> GetServerDriver() override;
|
||||||
AuSPtr<ISocketDriverFactory> GetFactory();
|
AuSPtr<ISocketDriverFactory> GetFactory();
|
||||||
|
AuSPtr<ISocketServerLimits> GetLimits() override;
|
||||||
|
AuList<AuSPtr<ISocket>> GetChildren() override;
|
||||||
|
|
||||||
virtual void FinishConstructAsync() override;
|
virtual void FinishConstructAsync() override;
|
||||||
|
|
||||||
@ -51,6 +56,7 @@ namespace Aurora::IO::Net
|
|||||||
|
|
||||||
const bool bMultiThreaded;
|
const bool bMultiThreaded;
|
||||||
const AuUInt32 uDefaultInputStreamSize;
|
const AuUInt32 uDefaultInputStreamSize;
|
||||||
|
AuUInt32 uBacklog { 512 };
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// INTERFACE: base os socket
|
// INTERFACE: base os socket
|
||||||
@ -79,11 +85,19 @@ namespace Aurora::IO::Net
|
|||||||
|
|
||||||
virtual void OnFinalize() override;
|
virtual void OnFinalize() override;
|
||||||
|
|
||||||
|
//
|
||||||
|
void OnNotifyChildCreated(SocketBase *pSocket);
|
||||||
|
void OnNotifyChildRemoved(SocketBase *pSocket);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend struct SocketBase;
|
||||||
|
|
||||||
AuSPtr<ISocketServerDriver> pDriver_;
|
AuSPtr<ISocketServerDriver> pDriver_;
|
||||||
AuUInt32 uMaxConnections_;
|
AuUInt32 uMaxConnections_;
|
||||||
AuSPtr<ISocketDriverFactory> pFactory_;
|
AuSPtr<ISocketDriverFactory> pFactory_;
|
||||||
|
NetSocketServerLimits serverLimits_;
|
||||||
|
AuMutex childrenMutex;
|
||||||
|
AuList<SocketBase *> childrenSockets;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +220,9 @@ namespace Aurora::IO::Net
|
|||||||
nextSocketPtr = AuMakeShared<Socket>(this->pInterface_,
|
nextSocketPtr = AuMakeShared<Socket>(this->pInterface_,
|
||||||
pWorker,
|
pWorker,
|
||||||
pNewDriver,
|
pNewDriver,
|
||||||
(AuUInt)nextSocket);
|
(AuUInt)nextSocket,
|
||||||
|
AuSPtr<ISocketServer>(this->pParent_->SharedFromThis(), this->pParent_),
|
||||||
|
this->pParent_);
|
||||||
if (!bool(nextSocketPtr))
|
if (!bool(nextSocketPtr))
|
||||||
{
|
{
|
||||||
// TODO: schedule retry
|
// TODO: schedule retry
|
||||||
|
@ -97,7 +97,9 @@ namespace Aurora::IO::Net
|
|||||||
this->nextSocketPtr = AuMakeShared<Socket>(this->pInterface_,
|
this->nextSocketPtr = AuMakeShared<Socket>(this->pInterface_,
|
||||||
pWorker,
|
pWorker,
|
||||||
pNewDriver,
|
pNewDriver,
|
||||||
(AuUInt)this->nextSocket);
|
(AuUInt)this->nextSocket,
|
||||||
|
AuSPtr<ISocketServer>(this->pParent_->SharedFromThis(), this->pParent_),
|
||||||
|
this->pParent_);
|
||||||
if (!bool(this->nextSocketPtr))
|
if (!bool(this->nextSocketPtr))
|
||||||
{
|
{
|
||||||
// TODO: schedule retry
|
// TODO: schedule retry
|
||||||
|
115
Source/IO/Net/AuNetSocketServerLimits.cpp
Normal file
115
Source/IO/Net/AuNetSocketServerLimits.cpp
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
/***
|
||||||
|
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||||
|
|
||||||
|
File: AuNetSocketServerLimits.cpp
|
||||||
|
Date: 2023-11-29
|
||||||
|
Author: Reece
|
||||||
|
***/
|
||||||
|
#include "Networking.hpp"
|
||||||
|
#include "AuNetSocketServerLimits.hpp"
|
||||||
|
|
||||||
|
namespace Aurora::IO::Net
|
||||||
|
{
|
||||||
|
void NetSocketServerLimits::NotifyChildRemoved()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> NetSocketServerLimits::GetMaxConnectionsPerIp()
|
||||||
|
{
|
||||||
|
return this->optMaxConnectionsPerIp;
|
||||||
|
}
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> NetSocketServerLimits::SetMaxConnectionsPerIp(AuOptional<AuUInt32> optNextValue)
|
||||||
|
{
|
||||||
|
return AuExchange(this->optMaxConnectionsPerIp, optNextValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> NetSocketServerLimits::GetMaxConnections()
|
||||||
|
{
|
||||||
|
return this->optMaxConnections;
|
||||||
|
}
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> NetSocketServerLimits::SetMaxConnections(AuOptional<AuUInt32> optNextValue)
|
||||||
|
{
|
||||||
|
return AuExchange(this->optMaxConnections, optNextValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
AuList<IPAddress> NetSocketServerLimits::GetWhitelist()
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetSocketServerLimits::SetWhitelist(AuList<IPAddress> whitelist)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
AuList<IPAddress> NetSocketServerLimits::GetBlacklist()
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetSocketServerLimits::SetBlacklist(AuList<IPAddress> blacklist)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> NetSocketServerLimits::GetBeforeDDoSDCAverageThroughputLimit()
|
||||||
|
{
|
||||||
|
return this->optBeforeDDoSDCAverageThroughputLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> NetSocketServerLimits::SetBeforeDDoSDCAverageThroughputLimit(AuOptional<AuUInt32> optNextValue)
|
||||||
|
{
|
||||||
|
return AuExchange(this->optBeforeDDoSDCAverageThroughputLimit, optNextValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> NetSocketServerLimits::GetBeforeDDoSDCFrameTimeMS()
|
||||||
|
{
|
||||||
|
return this->optBeforeDDoSDCFrameTimeMS;
|
||||||
|
}
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> NetSocketServerLimits::SetBeforeDDoSDCFrameTimeMS(AuOptional<AuUInt32> optNextValue)
|
||||||
|
{
|
||||||
|
return AuExchange(this->optBeforeDDoSDCFrameTimeMS, optNextValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> NetSocketServerLimits::GetBeforeDDoSTickFrameLimitCount()
|
||||||
|
{
|
||||||
|
return this->optBeforeDDoSTickFrameLimitCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> NetSocketServerLimits::SetBeforeDDoSTickFrameLimitCount(AuOptional<AuUInt32> optNextValue)
|
||||||
|
{
|
||||||
|
return AuExchange(this->optBeforeDDoSTickFrameLimitCount, optNextValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> NetSocketServerLimits::GetBeforeDDoSTickFrameTimeMS()
|
||||||
|
{
|
||||||
|
return this->optBeforeDDoSTickFrameTimeMS;
|
||||||
|
}
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> NetSocketServerLimits::SetBeforeDDoSTickFrameTimeMS(AuOptional<AuUInt32> optNextValue)
|
||||||
|
{
|
||||||
|
return AuExchange(this->optBeforeDDoSTickFrameTimeMS, optNextValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
AuOptional<bool> NetSocketServerLimits::GetAutoBanOnDDoSDetectA()
|
||||||
|
{
|
||||||
|
return this->optAutoBanOnDDoSDetectA;
|
||||||
|
}
|
||||||
|
|
||||||
|
AuOptional<bool> NetSocketServerLimits::SetAutoBanOnDDoSDetectA(AuOptional<bool> optNextValue)
|
||||||
|
{
|
||||||
|
return AuExchange(this->optAutoBanOnDDoSDetectA, optNextValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> NetSocketServerLimits::GetAutoBanTimeSecs()
|
||||||
|
{
|
||||||
|
return this->optAutoBanOnDDoSDetectA;
|
||||||
|
}
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> NetSocketServerLimits::SetAutoBanTimeSecs(AuOptional<AuUInt32> optNextValue)
|
||||||
|
{
|
||||||
|
return AuExchange(this->optAutoBanOnDDoSDetectA, optNextValue);
|
||||||
|
}
|
||||||
|
}
|
55
Source/IO/Net/AuNetSocketServerLimits.hpp
Normal file
55
Source/IO/Net/AuNetSocketServerLimits.hpp
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/***
|
||||||
|
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||||
|
|
||||||
|
File: AuNetSocketServerLimits.hpp
|
||||||
|
Date: 2023-11-29
|
||||||
|
Author: Reece
|
||||||
|
***/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Aurora::IO::Net
|
||||||
|
{
|
||||||
|
struct NetSocketServerLimits : ISocketServerLimits
|
||||||
|
{
|
||||||
|
void NotifyChildRemoved();
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> GetMaxConnectionsPerIp() override;
|
||||||
|
AuOptional<AuUInt32> SetMaxConnectionsPerIp(AuOptional<AuUInt32> uNextValue) override;
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> GetMaxConnections() override;
|
||||||
|
AuOptional<AuUInt32> SetMaxConnections(AuOptional<AuUInt32> uNextValue) override;
|
||||||
|
|
||||||
|
AuList<IPAddress> GetWhitelist() override;
|
||||||
|
void SetWhitelist(AuList<IPAddress> whitelist) override;
|
||||||
|
|
||||||
|
AuList<IPAddress> GetBlacklist() override;
|
||||||
|
void SetBlacklist(AuList<IPAddress> blacklist) override;
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> GetBeforeDDoSDCAverageThroughputLimit() override;
|
||||||
|
AuOptional<AuUInt32> SetBeforeDDoSDCAverageThroughputLimit(AuOptional<AuUInt32> uNextValue) override;
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> GetBeforeDDoSDCFrameTimeMS() override;
|
||||||
|
AuOptional<AuUInt32> SetBeforeDDoSDCFrameTimeMS(AuOptional<AuUInt32> uNextValue) override;
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> GetBeforeDDoSTickFrameLimitCount() override;
|
||||||
|
AuOptional<AuUInt32> SetBeforeDDoSTickFrameLimitCount(AuOptional<AuUInt32> uNextValue) override;
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> GetBeforeDDoSTickFrameTimeMS() override;
|
||||||
|
AuOptional<AuUInt32> SetBeforeDDoSTickFrameTimeMS(AuOptional<AuUInt32> uNextValue) override;
|
||||||
|
|
||||||
|
AuOptional<bool> GetAutoBanOnDDoSDetectA() override;
|
||||||
|
AuOptional<bool> SetAutoBanOnDDoSDetectA(AuOptional<bool> optNextValue) override;
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> GetAutoBanTimeSecs() override;
|
||||||
|
AuOptional<AuUInt32> SetAutoBanTimeSecs(AuOptional<AuUInt32> optNextValue) override;
|
||||||
|
|
||||||
|
AuOptional<AuUInt32> optBeforeDDoSTickFrameTimeMS;
|
||||||
|
AuOptional<AuUInt32> optBeforeDDoSTickFrameLimitCount;
|
||||||
|
AuOptional<AuUInt32> optBeforeDDoSDCFrameTimeMS;
|
||||||
|
AuOptional<AuUInt32> optBeforeDDoSDCAverageThroughputLimit;
|
||||||
|
AuOptional<AuUInt32> optMaxConnectionsPerIp;
|
||||||
|
AuOptional<AuUInt32> optMaxConnections;
|
||||||
|
AuOptional<bool> optAutoBanOnDDoSDetectA;
|
||||||
|
AuOptional<AuUInt32> optAutoBanTimeSecs;
|
||||||
|
};
|
||||||
|
}
|
@ -209,6 +209,11 @@ namespace Aurora::IO::Net
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (netBind.uMaxAcceptBacklog)
|
||||||
|
{
|
||||||
|
pSocket->uBacklog = netBind.uMaxAcceptBacklog;
|
||||||
|
}
|
||||||
|
|
||||||
if (!pWorker->TryScheduleInternalTemplate<AuNullS>([=](const AuSPtr<AuAsync::PromiseCallback<AuNullS>> &info)
|
if (!pWorker->TryScheduleInternalTemplate<AuNullS>([=](const AuSPtr<AuAsync::PromiseCallback<AuNullS>> &info)
|
||||||
{
|
{
|
||||||
pSocket->FinishConstructAsync();
|
pSocket->FinishConstructAsync();
|
||||||
|
@ -4,7 +4,9 @@ namespace Aurora::IO::Net
|
|||||||
{
|
{
|
||||||
struct NetSrvWorkers;
|
struct NetSrvWorkers;
|
||||||
|
|
||||||
struct NetWorker : INetWorker
|
struct NetWorker :
|
||||||
|
INetWorker,
|
||||||
|
AuEnableSharedFromThis<NetWorker>
|
||||||
{
|
{
|
||||||
NetWorker(NetSrvWorkers *pParent,
|
NetWorker(NetSrvWorkers *pParent,
|
||||||
AuUInt8 workerIndex,
|
AuUInt8 workerIndex,
|
||||||
|
@ -39,7 +39,12 @@ namespace Aurora::IO::Net
|
|||||||
|
|
||||||
AuSPtr<ISocketChannel> NetDatagramEmulatorISocket::ToChannel()
|
AuSPtr<ISocketChannel> NetDatagramEmulatorISocket::ToChannel()
|
||||||
{
|
{
|
||||||
return this->pParent->ToChannel();
|
if (auto pParent = this->pParent)
|
||||||
|
{
|
||||||
|
return pParent->ToChannel();
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const NetEndpoint &NetDatagramEmulatorISocket::GetRemoteEndpoint()
|
const NetEndpoint &NetDatagramEmulatorISocket::GetRemoteEndpoint()
|
||||||
@ -49,6 +54,34 @@ namespace Aurora::IO::Net
|
|||||||
|
|
||||||
AuSPtr<ISocketDriver> NetDatagramEmulatorISocket::GetUserDriver()
|
AuSPtr<ISocketDriver> NetDatagramEmulatorISocket::GetUserDriver()
|
||||||
{
|
{
|
||||||
return this->pParent->GetUserDriver();
|
if (auto pParent = this->pParent)
|
||||||
|
{
|
||||||
|
return pParent->GetUserDriver();
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
AuSPtr<INetWorker> NetDatagramEmulatorISocket::GetLockedWorkerThread()
|
||||||
|
{
|
||||||
|
if (auto pParent = this->pParent)
|
||||||
|
{
|
||||||
|
return pParent->pWorker;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
AuSPtr<ISocketServer> NetDatagramEmulatorISocket::GetSocketServer()
|
||||||
|
{
|
||||||
|
if (auto pParent = this->pParent)
|
||||||
|
{
|
||||||
|
if (auto pParent2 = AuTryLockMemoryType(pParent->pParentServer))
|
||||||
|
{
|
||||||
|
return pParent2->ToSocketServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -32,5 +32,9 @@ namespace Aurora::IO::Net
|
|||||||
const NetEndpoint &GetRemoteEndpoint() override;
|
const NetEndpoint &GetRemoteEndpoint() override;
|
||||||
|
|
||||||
AuSPtr<ISocketDriver> GetUserDriver() override;
|
AuSPtr<ISocketDriver> GetUserDriver() override;
|
||||||
|
|
||||||
|
AuSPtr<ISocketServer> GetSocketServer() override;
|
||||||
|
|
||||||
|
AuSPtr<INetWorker> GetLockedWorkerThread() override;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -22,21 +22,70 @@ namespace Aurora::IO::Net
|
|||||||
|
|
||||||
void NetDatagramEmulatorISocketServer::Shutdown(bool bNow)
|
void NetDatagramEmulatorISocketServer::Shutdown(bool bNow)
|
||||||
{
|
{
|
||||||
this->pParent->Shutdown(bNow);
|
if (auto pParent = this->pParent)
|
||||||
|
{
|
||||||
|
return pParent->Shutdown(bNow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetDatagramEmulatorISocketServer::Destroy()
|
void NetDatagramEmulatorISocketServer::Destroy()
|
||||||
{
|
{
|
||||||
this->pParent->Destroy();
|
if (auto pParent = this->pParent)
|
||||||
|
{
|
||||||
|
return pParent->Destroy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AuUInt NetDatagramEmulatorISocketServer::ToPlatformHandle()
|
AuUInt NetDatagramEmulatorISocketServer::ToPlatformHandle()
|
||||||
{
|
{
|
||||||
return this->pParent->ToPlatformHandle();
|
if (auto pParent = this->pParent)
|
||||||
|
{
|
||||||
|
return pParent->ToPlatformHandle();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AuSPtr<ISocketServerDriver> NetDatagramEmulatorISocketServer::GetServerDriver()
|
AuSPtr<ISocketServerDriver> NetDatagramEmulatorISocketServer::GetServerDriver()
|
||||||
{
|
{
|
||||||
return this->pParent->GetUserServerDriver();
|
if (auto pParent = this->pParent)
|
||||||
|
{
|
||||||
|
return pParent->GetUserServerDriver();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AuSPtr<ISocketServerLimits> NetDatagramEmulatorISocketServer::GetLimits()
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
AuList<AuSPtr<ISocket>> NetDatagramEmulatorISocketServer::GetChildren()
|
||||||
|
{
|
||||||
|
if (auto pParent = this->pParent)
|
||||||
|
{
|
||||||
|
return pParent->GetAllChildren();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AuSPtr<INetWorker> NetDatagramEmulatorISocketServer::GetLockedWorkerThread()
|
||||||
|
{
|
||||||
|
if (auto pParent = this->pParent)
|
||||||
|
{
|
||||||
|
return pParent->GetLockedWorkerThread();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -28,5 +28,8 @@ namespace Aurora::IO::Net
|
|||||||
AuUInt ToPlatformHandle() override;
|
AuUInt ToPlatformHandle() override;
|
||||||
|
|
||||||
AuSPtr<ISocketServerDriver> GetServerDriver() override;
|
AuSPtr<ISocketServerDriver> GetServerDriver() override;
|
||||||
|
AuSPtr<ISocketServerLimits> GetLimits() override;
|
||||||
|
AuList<AuSPtr<ISocket>> GetChildren() override;
|
||||||
|
AuSPtr<INetWorker> GetLockedWorkerThread() override;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -204,6 +204,40 @@ namespace Aurora::IO::Net
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AuList<AuSPtr<ISocket>> NetDatagramSocketServer::GetAllChildren()
|
||||||
|
{
|
||||||
|
AuList<AuSPtr<ISocket>> ret;
|
||||||
|
|
||||||
|
{
|
||||||
|
AU_LOCK_GUARD(this->mutex_);
|
||||||
|
|
||||||
|
for (const auto &[a, list] : this->sessions)
|
||||||
|
{
|
||||||
|
for (const auto &pItem : list)
|
||||||
|
{
|
||||||
|
if (pItem)
|
||||||
|
{
|
||||||
|
ret.push_back(pItem->ToSocket());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
AuSPtr<INetWorker> NetDatagramSocketServer::GetLockedWorkerThread()
|
||||||
|
{
|
||||||
|
if (auto pWorker = this->pWorker_)
|
||||||
|
{
|
||||||
|
return pWorker->SharedFromThis();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NetDatagramSocketServer::Shutdown(bool bNow)
|
void NetDatagramSocketServer::Shutdown(bool bNow)
|
||||||
{
|
{
|
||||||
this->eviction.EvictAll();
|
this->eviction.EvictAll();
|
||||||
|
@ -38,12 +38,14 @@ namespace Aurora::IO::Net
|
|||||||
AuSPtr<NetDatagramSocketServerSession> GetSession(const NetEndpoint &endpoint);
|
AuSPtr<NetDatagramSocketServerSession> GetSession(const NetEndpoint &endpoint);
|
||||||
void Cleanup(const AuSPtr<NetDatagramSocketServerSession> &pSession);
|
void Cleanup(const AuSPtr<NetDatagramSocketServerSession> &pSession);
|
||||||
AuList<AuSPtr<NetDatagramSocketServerSession>> GetAllSessions();
|
AuList<AuSPtr<NetDatagramSocketServerSession>> GetAllSessions();
|
||||||
|
AuList<AuSPtr<ISocket>> GetAllChildren();
|
||||||
|
|
||||||
AuSPtr<NetDatagramSocketServerDriver> ToDriver();
|
AuSPtr<NetDatagramSocketServerDriver> ToDriver();
|
||||||
AuSPtr<ISocketServer> ToSocketServer();
|
AuSPtr<ISocketServer> ToSocketServer();
|
||||||
|
|
||||||
const NetError &GetError() override;
|
const NetError &GetError() override;
|
||||||
const NetEndpoint &GetLocalEndpoint() override;
|
const NetEndpoint &GetLocalEndpoint() override;
|
||||||
|
AuSPtr<INetWorker> GetLockedWorkerThread() override;
|
||||||
|
|
||||||
void OnError(const NetError &error);
|
void OnError(const NetError &error);
|
||||||
void OnFatalErrorReported(const NetError &error);
|
void OnFatalErrorReported(const NetError &error);
|
||||||
|
@ -425,6 +425,11 @@ namespace Aurora::IO::Net
|
|||||||
return this->pBuffer->RemainingBytes();
|
return this->pBuffer->RemainingBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AuSPtr<ISocketChannelLimits> NetDatagramSocketServerChannel::GetChannelLimits()
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
SocketStats &NetDatagramSocketServerChannel::GetSendStatsEx()
|
SocketStats &NetDatagramSocketServerChannel::GetSendStatsEx()
|
||||||
{
|
{
|
||||||
return this->sendStats_;
|
return this->sendStats_;
|
||||||
|
@ -74,6 +74,8 @@ namespace Aurora::IO::Net
|
|||||||
|
|
||||||
AuUInt GetNextFrameTargetLength() override;
|
AuUInt GetNextFrameTargetLength() override;
|
||||||
|
|
||||||
|
AuSPtr<ISocketChannelLimits> GetChannelLimits() override;
|
||||||
|
|
||||||
SocketStats &GetSendStatsEx();
|
SocketStats &GetSendStatsEx();
|
||||||
SocketStats &GetRecvStatsEx();
|
SocketStats &GetRecvStatsEx();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user