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

RequestServer: Avoid using gethostbyname

Replace gethostbyname with Core::Socket::resolve_host in
RequestServer::ConnectionFromClient::ensure_connection.

Resolved #22199.
This commit is contained in:
mobounya 2024-01-29 10:20:58 +01:00 committed by Ali Mohammad Pur
parent 38164411f0
commit 7326d00baa
2 changed files with 18 additions and 14 deletions

View file

@ -20,6 +20,16 @@ namespace Core {
/// classes. Sockets are non-seekable streams which can be read byte-wise.
class Socket : public Stream {
public:
enum class PreventSIGPIPE {
No,
Yes,
};
enum class SocketType {
Stream,
Datagram,
};
Socket(Socket&&) = default;
Socket& operator=(Socket&&) = default;
@ -46,12 +56,11 @@ public:
/// Conversely, set_notifications_enabled(true) will re-enable notifications.
virtual void set_notifications_enabled(bool) { }
Function<void()> on_ready_to_read;
// FIXME: This will need to be updated when IPv6 socket arrives. Perhaps a
// base class for all address types is appropriate.
static ErrorOr<IPv4Address> resolve_host(ByteString const&, SocketType);
enum class PreventSIGPIPE {
No,
Yes,
};
Function<void()> on_ready_to_read;
protected:
enum class SocketDomain {
@ -59,20 +68,12 @@ protected:
Inet,
};
enum class SocketType {
Stream,
Datagram,
};
Socket(PreventSIGPIPE prevent_sigpipe = PreventSIGPIPE::No)
: m_prevent_sigpipe(prevent_sigpipe == PreventSIGPIPE::Yes)
{
}
static ErrorOr<int> create_fd(SocketDomain, SocketType);
// FIXME: This will need to be updated when IPv6 socket arrives. Perhaps a
// base class for all address types is appropriate.
static ErrorOr<IPv4Address> resolve_host(ByteString const&, SocketType);
static ErrorOr<void> connect_local(int fd, ByteString const& path);
static ErrorOr<void> connect_inet(int fd, SocketAddress const&);