Skip to content

Commit

Permalink
WebSocket: Port to LibMain :^)
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Nov 23, 2021
1 parent c2b90ba commit c6a581f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Userland/Services/WebSocket/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ set(SOURCES
)

serenity_bin(WebSocket)
target_link_libraries(WebSocket LibCore LibIPC LibWebSocket)
target_link_libraries(WebSocket LibCore LibIPC LibWebSocket LibMain)
24 changes: 7 additions & 17 deletions Userland/Services/WebSocket/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,23 @@
#include <LibCore/EventLoop.h>
#include <LibCore/LocalServer.h>
#include <LibIPC/ClientConnection.h>
#include <LibMain/Main.h>
#include <LibSystem/Wrappers.h>
#include <LibTLS/Certificate.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) {
perror("pledge");
return 1;
}
TRY(System::pledge("stdio inet unix rpath sendfd recvfd", nullptr));

// Ensure the certificates are read out here.
[[maybe_unused]] auto& certs = DefaultRootCACertificates::the();

Core::EventLoop event_loop;
// FIXME: Establish a connection to LookupServer and then drop "unix"?
if (pledge("stdio inet unix sendfd recvfd", nullptr) < 0) {
perror("pledge");
return 1;
}
if (unveil("/tmp/portal/lookup", "rw") < 0) {
perror("unveil");
return 1;
}
if (unveil(nullptr, nullptr) < 0) {
perror("unveil");
return 1;
}
TRY(System::pledge("stdio inet unix sendfd recvfd", nullptr));
TRY(System::unveil("/tmp/portal/lookup", "rw"));
TRY(System::unveil(nullptr, nullptr));

auto socket = Core::LocalSocket::take_over_accepted_socket_from_system_server();
VERIFY(socket);
Expand Down

0 comments on commit c6a581f

Please sign in to comment.