2020-01-18 05:38:21 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 05:38:21 -03:00
|
|
|
*/
|
|
|
|
|
|
2021-08-31 05:19:20 -03:00
|
|
|
#include <AK/OwnPtr.h>
|
2020-02-06 11:04:03 -03:00
|
|
|
#include <LibCore/EventLoop.h>
|
|
|
|
|
#include <LibCore/LocalServer.h>
|
2020-02-06 10:54:09 -03:00
|
|
|
#include <LibIPC/ClientConnection.h>
|
2020-10-30 05:27:32 -03:00
|
|
|
#include <LibTLS/Certificate.h>
|
2021-04-23 17:45:52 -03:00
|
|
|
#include <RequestServer/ClientConnection.h>
|
|
|
|
|
#include <RequestServer/GeminiProtocol.h>
|
|
|
|
|
#include <RequestServer/HttpProtocol.h>
|
|
|
|
|
#include <RequestServer/HttpsProtocol.h>
|
2019-11-23 17:45:33 -03:00
|
|
|
|
|
|
|
|
int main(int, char**)
|
|
|
|
|
{
|
2021-05-13 18:20:26 -03:00
|
|
|
if (pledge("stdio inet accept unix rpath sendfd recvfd", nullptr) < 0) {
|
2020-01-11 17:31:19 -03:00
|
|
|
perror("pledge");
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2020-10-30 05:27:32 -03:00
|
|
|
|
|
|
|
|
// Ensure the certificates are read out here.
|
2020-12-20 20:09:48 -03:00
|
|
|
[[maybe_unused]] auto& certs = DefaultRootCACertificates::the();
|
2020-10-30 05:27:32 -03:00
|
|
|
|
2020-02-02 08:34:39 -03:00
|
|
|
Core::EventLoop event_loop;
|
2020-01-17 07:12:06 -03:00
|
|
|
// FIXME: Establish a connection to LookupServer and then drop "unix"?
|
2021-01-17 04:18:11 -03:00
|
|
|
if (pledge("stdio inet accept unix sendfd recvfd", nullptr) < 0) {
|
2020-01-11 17:31:19 -03:00
|
|
|
perror("pledge");
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2020-05-04 13:48:20 -03:00
|
|
|
if (unveil("/tmp/portal/lookup", "rw") < 0) {
|
|
|
|
|
perror("unveil");
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
if (unveil(nullptr, nullptr) < 0) {
|
|
|
|
|
perror("unveil");
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-31 05:19:20 -03:00
|
|
|
[[maybe_unused]] auto gemini = make<RequestServer::GeminiProtocol>();
|
|
|
|
|
[[maybe_unused]] auto http = make<RequestServer::HttpProtocol>();
|
|
|
|
|
[[maybe_unused]] auto https = make<RequestServer::HttpsProtocol>();
|
2020-07-06 08:27:25 -03:00
|
|
|
|
|
|
|
|
auto socket = Core::LocalSocket::take_over_accepted_socket_from_system_server();
|
2021-02-23 16:42:32 -03:00
|
|
|
VERIFY(socket);
|
2021-04-23 17:45:52 -03:00
|
|
|
IPC::new_client_connection<RequestServer::ClientConnection>(socket.release_nonnull(), 1);
|
2021-09-05 14:31:39 -03:00
|
|
|
auto result = event_loop.exec();
|
|
|
|
|
|
|
|
|
|
// FIXME: We exit instead of returning, so that protocol destructors don't get called.
|
|
|
|
|
// The Protocol base class should probably do proper de-registration instead of
|
|
|
|
|
// just VERIFY_NOT_REACHED().
|
|
|
|
|
exit(result);
|
2019-11-23 17:45:33 -03:00
|
|
|
}
|