|
Entropic 2.14.3
Local-first agentic inference engine
|
Streamable-HTTP front end for the external bridge (gh#204). More...
#include "http_listener.h"#include <entropic/mcp/external_bridge.h>#include <entropic/types/logging.h>#include <httplib.h>#include <nlohmann/json.hpp>#include <cerrno>#include <cstdio>#include <cstdlib>#include <cstring>#include <fcntl.h>#include <poll.h>#include <sys/random.h>#include <sys/socket.h>#include <sys/stat.h>#include <unistd.h>
Go to the source code of this file.
Classes | |
| struct | entropic::http::HttpListener::Impl |
| httplib state, kept out of the header (no third-party headers). More... | |
Namespaces | |
| namespace | entropic |
| Activate model on GPU (WARM → ACTIVE). | |
Functions | |
| std::string | entropic::http::generate_token () |
| A fresh bearer token: 256 bits from getrandom(), hex-encoded. | |
| bool | entropic::http::tokens_equal (const std::string &a, const std::string &b) |
| Compare two tokens in time independent of where they differ. | |
| bool | entropic::http::host_allowed (const std::string &host, int port) |
| Whether a Host header names this listener's loopback endpoint. | |
| std::string | entropic::http::bearer_token (const std::string &header) |
The token in an Authorization: Bearer <t> header, or "". | |
| std::filesystem::path | entropic::http::token_path_for (int port) |
| Where the token for a port is written. | |
| bool | entropic::http::prepare_private_dir (const std::filesystem::path &dir, std::string &err) |
| Create or verify the token directory: 0700, ours, not a symlink. | |
| bool | entropic::http::write_token_file (const std::filesystem::path &path, const std::string &token, std::string &err) |
Write token to path atomically (temp + rename), mode 0600. | |
| static void | entropic::http::configure_server (HttpListener::Impl &impl, ExternalBridge *bridge, const std::atomic< int > &port) |
| Install routes, limits and the worker pool on the server. | |
| static int | entropic::http::bind_loopback (httplib::Server &server, int port) |
Bind 127.0.0.1 on port, or on any free port when it is 0. | |
Streamable-HTTP front end for the external bridge (gh#204).
See http_listener.h for the transport and the security bar.
Definition in file http_listener.cpp.
| ENTROPIC_EXPORT std::string entropic::http::bearer_token | ( | const std::string & | header | ) |
The token in an Authorization: Bearer <t> header, or "".
| header | Authorization header value. |
Definition at line 119 of file http_listener.cpp.
|
static |
Bind 127.0.0.1 on port, or on any free port when it is 0.
| server | The server. |
| port | Requested port. |
Definition at line 449 of file http_listener.cpp.
|
static |
Install routes, limits and the worker pool on the server.
| impl | Server state. |
| bridge | Bridge to dispatch to. |
| port | Bound port (for the Host check). @utility |
Definition at line 417 of file http_listener.cpp.
| ENTROPIC_EXPORT std::string entropic::http::generate_token | ( | ) |
A fresh bearer token: 256 bits from getrandom(), hex-encoded.
Definition at line 62 of file http_listener.cpp.
Whether a Host header names this listener's loopback endpoint.
| host | Host header value ("" when absent). |
| port | Listening port. |
127.0.0.1:<port> or localhost:<port>. @utility Definition at line 107 of file http_listener.cpp.
| ENTROPIC_EXPORT bool entropic::http::prepare_private_dir | ( | const std::filesystem::path & | dir, |
| std::string & | err | ||
| ) |
Create or verify the token directory: 0700, ours, not a symlink.
| dir | Directory to prepare. | |
| [out] | err | Why it is unusable. |
Definition at line 146 of file http_listener.cpp.
| ENTROPIC_EXPORT std::filesystem::path entropic::http::token_path_for | ( | int | port | ) |
Where the token for a port is written.
| port | Listening port. |
$HOME/.entropic/serve/<port>.token. @utility Definition at line 132 of file http_listener.cpp.
Compare two tokens in time independent of where they differ.
| a | First value. |
| b | Second value. |
Definition at line 88 of file http_listener.cpp.
| ENTROPIC_EXPORT bool entropic::http::write_token_file | ( | const std::filesystem::path & | path, |
| const std::string & | token, | ||
| std::string & | err | ||
| ) |
Write token to path atomically (temp + rename), mode 0600.
| path | Destination. | |
| token | Token text. | |
| [out] | err | Why the write failed. |
Definition at line 171 of file http_listener.cpp.
| int read_fd = -1 |
Our end.
Definition at line 244 of file http_listener.cpp.
| std::thread worker |
Runs dispatch()
Definition at line 245 of file http_listener.cpp.