1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-19 14:12:11 +00:00

WebSocket: Port to LibMain :^)

This commit is contained in:
Andreas Kling 2021-11-23 10:38:52 +01:00
parent c2b90bab9f
commit c6a581f267
2 changed files with 8 additions and 18 deletions

View file

@ -14,4 +14,4 @@ set(SOURCES
) )
serenity_bin(WebSocket) serenity_bin(WebSocket)
target_link_libraries(WebSocket LibCore LibIPC LibWebSocket) target_link_libraries(WebSocket LibCore LibIPC LibWebSocket LibMain)

View file

@ -7,33 +7,23 @@
#include <LibCore/EventLoop.h> #include <LibCore/EventLoop.h>
#include <LibCore/LocalServer.h> #include <LibCore/LocalServer.h>
#include <LibIPC/ClientConnection.h> #include <LibIPC/ClientConnection.h>
#include <LibMain/Main.h>
#include <LibSystem/Wrappers.h>
#include <LibTLS/Certificate.h> #include <LibTLS/Certificate.h>
#include <WebSocket/ClientConnection.h> #include <WebSocket/ClientConnection.h>
int main(int, char**) ErrorOr<int> serenity_main(Main::Arguments)
{ {
if (pledge("stdio inet unix rpath sendfd recvfd", nullptr) < 0) { TRY(System::pledge("stdio inet unix rpath sendfd recvfd", nullptr));
perror("pledge");
return 1;
}
// Ensure the certificates are read out here. // Ensure the certificates are read out here.
[[maybe_unused]] auto& certs = DefaultRootCACertificates::the(); [[maybe_unused]] auto& certs = DefaultRootCACertificates::the();
Core::EventLoop event_loop; Core::EventLoop event_loop;
// FIXME: Establish a connection to LookupServer and then drop "unix"? // FIXME: Establish a connection to LookupServer and then drop "unix"?
if (pledge("stdio inet unix sendfd recvfd", nullptr) < 0) { TRY(System::pledge("stdio inet unix sendfd recvfd", nullptr));
perror("pledge"); TRY(System::unveil("/tmp/portal/lookup", "rw"));
return 1; TRY(System::unveil(nullptr, nullptr));
}
if (unveil("/tmp/portal/lookup", "rw") < 0) {
perror("unveil");
return 1;
}
if (unveil(nullptr, nullptr) < 0) {
perror("unveil");
return 1;
}
auto socket = Core::LocalSocket::take_over_accepted_socket_from_system_server(); auto socket = Core::LocalSocket::take_over_accepted_socket_from_system_server();
VERIFY(socket); VERIFY(socket);