summaryrefslogtreecommitdiff
path: root/Userland/Services/LookupServer
AgeCommit message (Collapse)Author
2022-07-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
2022-07-06LookupServer: Use _POSIX_HOST_NAME_MAX instead of HOST_NAME_MAXTimon Kruiper
HOST_NAME_MAX is not defined on the BSDs, including macOS. Use _POSIX_HOST_NAME_MAX instead, which is defined on all the platforms.
2022-07-06LookupServer: Use designated initializers for sockaddr_inAndrew Kaster
At least macOS has a non-standard sin_len field at the front of the struct that Linux and Serenity do not. On BSDs, the sin_len field must be initialized to the size of the structure. Co-Authored-By: Timon Kruiper <timonkruiper@gmail.com>
2022-07-06AK: Use an enum instead of a bool for String::replace(all_occurences)DexesTTP
This commit has no behavior changes. In particular, this does not fix any of the wrong uses of the previous default parameter (which used to be 'false', meaning "only replace the first occurence in the string"). It simply replaces the default uses by String::replace(..., ReplaceMode::FirstOnly), leaving them incorrect.
2022-07-02LookupServer: Try other available DNS nameservers on network errorsIdan Horowitz
We were accidentally short-circuting DNS lookup on network errors when contacting the first DNS server, instead of trying the other available options.
2022-04-16LibCore+Everywhere: Make Core::Stream::read() return BytesSam Atkins
A mistake I've repeatedly made is along these lines: ```c++ auto nread = TRY(source_file->read(buffer)); TRY(destination_file->write(buffer)); ``` It's a little clunky to have to create a Bytes or StringView from the buffer's data pointer and the nread, and easy to forget and just use the buffer. So, this patch changes the read() function to return a Bytes of the data that were just read. The other read_foo() methods will be modified in the same way in subsequent commits. Fixes #13687
2022-04-15LibDNS: Remove the 'DNS' prefix from the various type and class namesTom
Since all types and class names live in the DNS namespace, we don't need to spell it out twice each time.
2022-04-15LookupServer: Move DNS related code into new LibDNS libraryTom
This allows other code to use the DNSPacket class, e.g. when sent over IPC.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-27LookupServer: Fix confusing copy/paste error in debug messageLinus Groh
2022-03-27LookupServer: Use case-insensitive comparison for domain namesTimur Sultanov
Some ISPs may MITM DNS requests coming from clients, changing the case of domain name in response. LookupServer will refuse responses from any DNS server in that case. This commit changes the behaviour to perform a case-insensitive equality check.
2022-03-24Services: Use default constructors/destructorsLenny Maiorani
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
2022-03-20LookupServer: Return with failure result when lookup failssin-ack
This was missed in 4ca0669d1e732b1697a7944a7899b2250bb81cf1 and the error condition would still fall through to an ErrorOr unwrapping which caused a crash.
2022-02-25Userland: Rename IPC ClientConnection => ConnectionFromClientItamar
This was done with CLion's automatic rename feature and with: find . -name ClientConnection.h | rename 's/ClientConnection\.h/ConnectionFromClient.h/' find . -name ClientConnection.cpp | rename 's/ClientConnection\.cpp/ConnectionFromClient.cpp/'
2022-02-16LibCore+Everywhere: Return ErrorOr from ConfigFile factory methodsSam Atkins
I've attempted to handle the errors gracefully where it was clear how to do so, and simple, but a lot of this was just adding `release_value_but_fixme_should_propagate_errors()` in places.
2022-02-14LookupServer: Convert to Core::Stream::UDPSocketsin-ack
2022-01-15LibCore+LibIPC+Everywhere: Return Stream::LocalSocket from LocalServersin-ack
This change unfortunately cannot be atomically made without a single commit changing everything. Most of the important changes are in LibIPC/Connection.cpp, LibIPC/ServerConnection.cpp and LibCore/LocalServer.cpp. The notable changes are: - IPCCompiler now generates the decode and decode_message functions such that they take a Core::Stream::LocalSocket instead of the socket fd. - IPC::Decoder now uses the receive_fd method of LocalSocket instead of doing system calls directly on the fd. - IPC::ConnectionBase and related classes now use the Stream API functions. - IPC::ServerConnection no longer constructs the socket itself; instead, a convenience macro, IPC_CLIENT_CONNECTION, is used in place of C_OBJECT and will generate a static try_create factory function for the ServerConnection subclass. The subclass is now responsible for passing the socket constructed in this function to its ServerConnection base; the socket is passed as the first argument to the constructor (as a NonnullOwnPtr<Core::Stream::LocalServer>) before any other arguments. - The functionality regarding taking over sockets from SystemServer has been moved to LibIPC/SystemServerTakeover.cpp. The Core::LocalSocket implementation of this functionality hasn't been deleted due to my intention of removing this class in the near future and to reduce noise on this (already quite noisy) PR.
2022-01-01LookupServer: Avoid unnecessary copiesBen Wiederhake
2021-12-16LibCore+LookupServer: Implement and use UDPServer::sendsin-ack
2021-12-06LibIPC: Add IPC::MultiServer convenience classAndreas Kling
This encapsulates what our multi-client IPC servers typically do on startup: 1. Create a Core::LocalServer 2. Take over a listening socket file descriptor from SystemServer 3. Set up an accept handler for incoming connections IPC::MultiServer does all this for you! All you have to do is provide the relevant client connection type as a template argument.
2021-12-06LibCore: Make LocalServer::take_over_from_system_server() return ErrorOrAndreas Kling
This allows us to use TRY() or MUST() when calling it.
2021-12-05Services: Cast unused IPC::new_client_connection() results to voidSam Atkins
These ones all manage their storage internally, whereas the WebContent and ImageDecoder ones require the caller to manage their lifetime. This distinction is not obvious to the user without looking through the code, so an API that makes this clearer would be nice.
2021-11-30LookupServer: Remove unused this capture in a lambda functionHendiadyoin1
this was causing CI to fail
2021-11-30LibCore: Change Core::LocalServer::on_ready_to_accept => on_acceptAndreas Kling
Everyone used this hook in the same way: immediately accept() on the socket and then do something with the newly accepted fd. This patch simplifies the hook by having LocalServer do the accepting automatically.
2021-11-28Everywhere: Use default execpromises argument for Core::System::pledgeBrian Gianforcaro
2021-11-23LookupServer: Port to LibMain :^)Andreas Kling
2021-11-17AK: Convert AK::Format formatting helpers to returning ErrorOr<void>Andreas Kling
This isn't a complete conversion to ErrorOr<void>, but a good chunk. The end goal here is to propagate buffer allocation failures to the caller, and allow the use of TRY() with formatting functions.
2021-11-17AK: Make JSON parser return ErrorOr<JsonValue> (instead of Optional)Andreas Kling
Also add slightly richer parse errors now that we can include a string literal with returned errors. This will allow us to use TRY() when working with JSON data.
2021-11-10AK+Everywhere: Stop including Vector.h from StringView.hAndreas Kling
Preparation for using Error.h from Vector.h. This required moving some things out of line.
2021-11-05LibC+LookupServer: Use u32 for the endpoint magicBen Wiederhake
That's how LibIPC treats it, too.
2021-11-05LibC+LookupServer: Compute magic number to avoid hardcodingBen Wiederhake
2021-11-02Services: Fix visibility of Object-derivative constructorsBen Wiederhake
Derivatives of Core::Object should be constructed through ClassName::construct(), to avoid handling ref-counted objects with refcount zero. Fixing the visibility means that misuses like this are more difficult.
2021-10-05LookupServer: Fix to handle whitespaces and tabs in /etc/hostsfleximus
2021-09-04LookupServer: Use HashMap::ensure() in load_etc_hosts()Andreas Kling
2021-08-22Everywhere: Rename get in ConfigFile::get_for_{lib,app,system} to opennetworkException
This patch brings the ConfigFile helpers for opening lib, app and system configs more inline with the regular ConfigFile::open functions.
2021-08-01Services: Remove unused header includesBrian Gianforcaro
2021-07-08Everywhere: Add braces to aggregate initializersDaniel Bertalan
This fixes a couple of warnings emitted by Clang.
2021-06-24Userland: Remove dummy IPC methodsGunnar Beutner
They're not used anywhere and are unnecessary boilerplate code. So let's remove them and update IPCCompiler to allow for empty endpoint declarations.
2021-06-17Everywhere: Add component declarationsGunnar Beutner
This adds component declarations so that users can select to not build certain parts of the OS.
2021-06-09LookupServer: Watch /etc/hosts for changes during runtimeMax Wipfli
This adds a FileWatcher to the LookupServer which watches '/etc/hosts' for changes during runtime and reloads its contents. If the file is deleted, m_etc_hosts will be cleared. Since we now need to access '/etc/hosts' later during runtime, it needs to be unveiled with read permissions.
2021-06-09LookupServer: Check for hostname after /etc/hostsMax Wipfli
If the hostname is not in /etc/hosts, looking it up should return 127.0.0.1.
2021-06-09LookupServer: Make DNSName::operator== ignore caseMax Wipfli
2021-06-09LookupServer: Modernize load_etc_hosts()Max Wipfli
This reworks the LookupServer::load_etc_hosts() method to use the IPv4Address APIs instead of trying to parse an IPv4 address itself. It also adds a few error checks for invalid entries in /etc/hosts, trims away leading and trailing whitespace from lines and tries to use StringView over String.
2021-05-23LookupServer: Fix missing POSIX includesJean-Baptiste Boric
2021-05-16AK+Userland: Remove nullability feature for the ByteBuffer typeGunnar Beutner
Nobody seems to use this particular feature, in fact there were some bugs which were uncovered by removing operator bool.
2021-05-14Userland: Migrate from arc4random_uniform() to get_random_uniform()Jean-Baptiste Boric
2021-05-13Userland: Tighten a *lot* of pledges! :^)Andreas Kling
Since applications using Core::EventLoop no longer need to create a socket in /tmp/rpc/, and also don't need to listen for incoming connections on this socket, we can remove a whole bunch of pledges!
2021-05-12LibCore+Everywhere: Move OpenMode out of IODeviceAli Mohammad Pur
...and make it an enum class so people don't omit "OpenMode".
2021-05-10LookupServer: Do cache eviction when mDNS cache flush bit is setGunnar Beutner
2021-05-10LookupServer: Track the receive timestamp for DNS answersGunnar Beutner