2023-08-01 14:39:19 -06:00
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
|
2023-08-01 14:39:19 -06:00
|
|
|
* Copyright (c) 2023, Andrew Kaster <akaster@serenityos.org>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
2025-07-06 10:10:24 -06:00
|
|
|
#include <AK/ByteString.h>
|
|
|
|
|
#include <AK/Format.h>
|
|
|
|
|
#include <AK/StringView.h>
|
|
|
|
|
#include <AK/Vector.h>
|
2023-08-01 14:39:19 -06:00
|
|
|
#include <LibCore/ArgsParser.h>
|
|
|
|
|
#include <LibCore/EventLoop.h>
|
2024-08-01 07:03:03 -04:00
|
|
|
#include <LibCore/Process.h>
|
2023-08-01 14:39:19 -06:00
|
|
|
#include <LibIPC/SingleServer.h>
|
|
|
|
|
#include <LibMain/Main.h>
|
|
|
|
|
#include <RequestServer/ConnectionFromClient.h>
|
|
|
|
|
|
2024-04-22 12:57:38 -04:00
|
|
|
#if defined(AK_OS_MACOS)
|
|
|
|
|
# include <LibCore/Platform/ProcessStatisticsMach.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2024-09-05 13:20:09 +02:00
|
|
|
namespace RequestServer {
|
2025-05-13 07:06:33 -04:00
|
|
|
|
2024-09-05 13:20:09 +02:00
|
|
|
extern ByteString g_default_certificate_path;
|
2025-05-13 07:06:33 -04:00
|
|
|
|
2024-09-05 13:20:09 +02:00
|
|
|
}
|
|
|
|
|
|
2023-08-01 14:39:19 -06:00
|
|
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|
|
|
|
{
|
2023-12-11 11:19:41 -07:00
|
|
|
AK::set_rich_debug_enabled(true);
|
|
|
|
|
|
2024-02-05 09:34:51 -07:00
|
|
|
Vector<ByteString> certificates;
|
2024-04-22 12:57:38 -04:00
|
|
|
StringView mach_server_name;
|
2024-08-01 07:03:03 -04:00
|
|
|
bool wait_for_debugger = false;
|
2023-08-01 14:39:19 -06:00
|
|
|
|
|
|
|
|
Core::ArgsParser args_parser;
|
2024-02-05 09:34:51 -07:00
|
|
|
args_parser.add_option(certificates, "Path to a certificate file", "certificate", 'C', "certificate");
|
2024-04-22 12:57:38 -04:00
|
|
|
args_parser.add_option(mach_server_name, "Mach server name", "mach-server-name", 0, "mach_server_name");
|
2024-08-01 07:03:03 -04:00
|
|
|
args_parser.add_option(wait_for_debugger, "Wait for debugger", "wait-for-debugger");
|
2023-08-01 14:39:19 -06:00
|
|
|
args_parser.parse(arguments);
|
|
|
|
|
|
2024-08-01 07:03:03 -04:00
|
|
|
if (wait_for_debugger)
|
|
|
|
|
Core::Process::wait_for_debugger_and_break();
|
|
|
|
|
|
2025-07-06 09:11:28 -06:00
|
|
|
// FIXME: Update RequestServer to support multiple custom root certificates.
|
|
|
|
|
if (!certificates.is_empty())
|
2024-09-05 13:20:09 +02:00
|
|
|
RequestServer::g_default_certificate_path = certificates.first();
|
|
|
|
|
|
2023-08-01 14:39:19 -06:00
|
|
|
Core::EventLoop event_loop;
|
|
|
|
|
|
2024-04-22 12:57:38 -04:00
|
|
|
#if defined(AK_OS_MACOS)
|
|
|
|
|
if (!mach_server_name.is_empty())
|
|
|
|
|
Core::Platform::register_with_mach_server(mach_server_name);
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-08-01 14:39:19 -06:00
|
|
|
auto client = TRY(IPC::take_over_accepted_client_from_system_server<RequestServer::ConnectionFromClient>());
|
|
|
|
|
|
2024-03-05 15:15:41 -07:00
|
|
|
return event_loop.exec();
|
2023-08-01 14:39:19 -06:00
|
|
|
}
|