event/ServerSocket: move GetPeerCredentials() call to ClientListener::OnAccept()
This commit is contained in:
parent
a0825e6ce0
commit
7adda0aa66
src
client
event
output/plugins
@ -4,6 +4,7 @@
|
||||
#include "Listener.hxx"
|
||||
#include "Client.hxx"
|
||||
#include "Permission.hxx"
|
||||
#include "net/PeerCredentials.hxx"
|
||||
#include "net/UniqueSocketDescriptor.hxx"
|
||||
#include "net/SocketAddress.hxx"
|
||||
#include "config.h"
|
||||
@ -29,8 +30,10 @@ GetPermissions(SocketAddress address, int uid) noexcept
|
||||
|
||||
void
|
||||
ClientListener::OnAccept(UniqueSocketDescriptor fd,
|
||||
SocketAddress address, int uid) noexcept
|
||||
SocketAddress address) noexcept
|
||||
{
|
||||
const auto cred = fd.GetPeerCredentials();
|
||||
const int uid = cred.IsDefined() ? static_cast<int>(cred.GetUid()) : -1;
|
||||
|
||||
client_new(GetEventLoop(), partition,
|
||||
std::move(fd), address, uid,
|
||||
|
@ -17,7 +17,7 @@ public:
|
||||
|
||||
private:
|
||||
void OnAccept(UniqueSocketDescriptor fd,
|
||||
SocketAddress address, int uid) noexcept override;
|
||||
SocketAddress address) noexcept override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "net/IPv6Address.hxx"
|
||||
#include "net/StaticSocketAddress.hxx"
|
||||
#include "net/AllocatedSocketAddress.hxx"
|
||||
#include "net/PeerCredentials.hxx"
|
||||
#include "net/SocketUtil.hxx"
|
||||
#include "net/SocketError.hxx"
|
||||
#include "net/UniqueSocketDescriptor.hxx"
|
||||
@ -102,16 +101,6 @@ private:
|
||||
|
||||
static constexpr Domain server_socket_domain("server_socket");
|
||||
|
||||
static int
|
||||
get_remote_uid(SocketDescriptor s) noexcept
|
||||
{
|
||||
const auto cred = s.GetPeerCredentials();
|
||||
if (!cred.IsDefined())
|
||||
return -1;
|
||||
|
||||
return cred.GetUid();
|
||||
}
|
||||
|
||||
inline void
|
||||
ServerSocket::OneServerSocket::Accept() noexcept
|
||||
{
|
||||
@ -131,9 +120,7 @@ ServerSocket::OneServerSocket::Accept() noexcept
|
||||
(const char *)msg);
|
||||
}
|
||||
|
||||
const auto uid = get_remote_uid(peer_fd);
|
||||
|
||||
parent.OnAccept(std::move(peer_fd), peer_address, uid);
|
||||
parent.OnAccept(std::move(peer_fd), peer_address);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -134,7 +134,7 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void OnAccept(UniqueSocketDescriptor fd,
|
||||
SocketAddress address, int uid) noexcept = 0;
|
||||
SocketAddress address) noexcept = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -251,7 +251,7 @@ private:
|
||||
void OnDeferredBroadcast() noexcept;
|
||||
|
||||
void OnAccept(UniqueSocketDescriptor fd,
|
||||
SocketAddress address, int uid) noexcept override;
|
||||
SocketAddress address) noexcept override;
|
||||
};
|
||||
|
||||
extern const class Domain httpd_output_domain;
|
||||
|
@ -113,7 +113,7 @@ HttpdOutput::OnDeferredBroadcast() noexcept
|
||||
|
||||
void
|
||||
HttpdOutput::OnAccept(UniqueSocketDescriptor fd,
|
||||
SocketAddress, [[maybe_unused]] int uid) noexcept
|
||||
SocketAddress) noexcept
|
||||
{
|
||||
/* the listener socket has become readable - a client has
|
||||
connected */
|
||||
|
@ -184,7 +184,7 @@ private:
|
||||
|
||||
/* virtual methods from class ServerSocket */
|
||||
void OnAccept(UniqueSocketDescriptor fd,
|
||||
SocketAddress address, int uid) noexcept override;
|
||||
SocketAddress address) noexcept override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -95,7 +95,7 @@ SnapcastOutput::AddClient(UniqueSocketDescriptor fd) noexcept
|
||||
|
||||
void
|
||||
SnapcastOutput::OnAccept(UniqueSocketDescriptor fd,
|
||||
SocketAddress, int) noexcept
|
||||
SocketAddress) noexcept
|
||||
{
|
||||
/* the listener socket has become readable - a client has
|
||||
connected */
|
||||
|
Loading…
x
Reference in New Issue
Block a user