Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/http-api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ The following webserver related configuration items are available:

.. warning::

To achieve defense-in-depth, expose the webserver only to client addresses that have a real need for access.
To achieve defense-in-depth, expose the webserver only to client addresses that have a real need for access, and configure a webserver password.
Network access is configured by setting :ref:`setting-webserver-address` and :ref:`setting-webserver-allow-from`.
Password protection is configured by setting :ref:`setting-webserver-password`.


Metrics Endpoint
Expand Down
44 changes: 22 additions & 22 deletions docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2138,6 +2138,28 @@ IP Address for webserver/API to listen on.
Webserver/API access is only allowed from these subnets.
Ignored if ``webserver-address`` is set to a UNIX domain socket.

.. _setting-webserver-connection-timeout:

``webserver-connection-timeout``
--------------------------------
.. versionadded:: 4.8.5

- Integer
- Default: 5

Request/response timeout in seconds.

.. _setting-webserver-cross-origin-request-header:

``webserver-cross-origin-request-header``
-----------------------------------------
.. versionadded:: 5.1.0

- String
- Default: empty

The value if the access-control-allow-origin HTTP header to include. This header is not included if the value is empty.

.. _setting-webserver-hash-plaintext-credentials:

``webserver-hash-plaintext-credentials``
Expand Down Expand Up @@ -2212,17 +2234,6 @@ Maximum request/response body size in megabytes.

Maximum number of allowed concurrent connections to the web server.

.. _setting-webserver-connection-timeout:

``webserver-connection-timeout``
--------------------------------
.. versionadded:: 4.8.5

- Integer
- Default: 5

Request/response timeout in seconds.

.. _setting-webserver-password:

``webserver-password``
Expand Down Expand Up @@ -2255,17 +2266,6 @@ Ignored if ``webserver-address`` is set to a UNIX domain socket.

If the webserver should print arguments.

.. _setting-webserver-cross-origin-request-header:

``webserver-cross-origin-request-header``
-----------------------------------------
.. versionadded:: 5.1.0

- String
- Default: empty

The value if the access-control-allow-origin HTTP header to include. This header is not included if the value is empty.

.. _setting-write-pid:

``write-pid``
Expand Down
2 changes: 1 addition & 1 deletion modules/bindbackend/binddnssec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ bool Bind2Backend::addDomainKey(const ZoneName& name, const KeyData& key, int64_
SSqlStatement::row_t row;
d_GetLastInsertedKeyIdQuery_stmt->nextRow(row);
ASSERT_ROW_COLUMNS("get-last-inserted-key-id-query", row, 1);
keyId = std::stoi(row[0]);
pdns::checked_stoi_into(keyId, row[0]);
d_GetLastInsertedKeyIdQuery_stmt->reset();
if (keyId == 0) {
// No insert took place, report as error.
Expand Down
2 changes: 1 addition & 1 deletion modules/pipebackend/pipebackend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ bool PipeBackend::get(DNSResourceRecord& r)
}

if (d_abiVersion >= 3) {
r.scopeMask = std::stoi(parts[1]);
pdns::checked_stoi_into(r.scopeMask, parts[1]);
r.auth = (parts[2] == "1");
parts.erase(parts.begin() + 1, parts.begin() + 3);
}
Expand Down
4 changes: 2 additions & 2 deletions pdns/backends/gsql/gsqlbackend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ bool GSQLBackend::addDomainKey(const ZoneName& name, const KeyData& key, int64_t
if (d_AddDomainKeyQuery_stmt->hasNextRow()) {
SSqlStatement::row_t row;
d_AddDomainKeyQuery_stmt->nextRow(row);
keyId = std::stoi(row[0]);
pdns::checked_stoi_into(keyId, row[0]);
d_AddDomainKeyQuery_stmt->reset();
return true;
} else {
Expand All @@ -1088,7 +1088,7 @@ bool GSQLBackend::addDomainKey(const ZoneName& name, const KeyData& key, int64_t
SSqlStatement::row_t row;
d_GetLastInsertedKeyIdQuery_stmt->nextRow(row);
ASSERT_ROW_COLUMNS("get-last-inserted-key-id-query", row, 1);
keyId = std::stoi(row[0]);
pdns::checked_stoi_into(keyId, row[0]);
d_GetLastInsertedKeyIdQuery_stmt->reset();
if (keyId == 0) {
// No insert took place, report as error.
Expand Down
2 changes: 1 addition & 1 deletion pdns/dnssecinfra.cc
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ static map<string, string> ISCStringtoMap(const string& argStr)
continue;
}
if (pdns_iequals(key,"slot")) {
int slot = std::stoi(value);
auto slot = pdns::checked_stoi<int>(value);
stormap["slot"]=std::to_string(slot);
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion pdns/json.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static inline int intFromJsonInternal(const Json& container, const std::string&

if (val.is_string()) {
try {
return std::stoi(val.string_value());
return pdns::checked_stoi<int>(val.string_value());
} catch (std::logic_error&) {
throw JsonException("Key '" + string(key) + "' is not a valid number");
}
Expand Down
6 changes: 2 additions & 4 deletions pdns/minicurl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,8 @@ void MiniCurl::setupURL(const std::string& str, const ComboAddress* rem, const C
std::size_t found = host4.find(':');
vector<uint16_t> ports{80, 443};
if (found != std::string::npos) {
int port = std::stoi(host4.substr(found + 1));
if (port <= 0 || port > 65535)
throw std::overflow_error("Invalid port number");
ports = {(uint16_t)port};
auto port = pdns::checked_stoi<uint16_t>(host4.substr(found + 1));
ports = {port};
host4 = host4.substr(0, found);
}

Expand Down
2 changes: 1 addition & 1 deletion pdns/pkcs11signers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ CK_RV Pkcs11Slot::HuntSlot(Logr::log_t slog, const string& tokenId, CK_SLOT_ID &

// see if we can find it with slotId
try {
slotId = std::stoi(tokenId);
pdns::checked_stoi_into(slotId, tokenId);
if ((err = functions->C_GetSlotInfo(slotId, info))) {
SLOG(g_log<<Logger::Warning<<"C_GetSlotInfo("<<slotId<<", info) = " << err << std::endl,
slog->info(Logr::Warning, "C_GetSlotInfo failed", "slotId", Logging::Loggable(slotId), "errorcode", Logging::Loggable(err)));
Expand Down
9 changes: 7 additions & 2 deletions pdns/ws-auth.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1352,7 +1352,7 @@ static inline int getInquireKeyId(HttpRequest* req, const ZoneName& zonename, DN
{
int inquireKeyId = -1;
if (req->parameters.count("key_id") == 1) {
inquireKeyId = std::stoi(req->parameters["key_id"]);
pdns::checked_stoi_into(inquireKeyId, req->parameters["key_id"]);
apiZoneCryptoKeysCheckKeyExists(zonename, inquireKeyId, dnsseckeeper);
}
return inquireKeyId;
Expand Down Expand Up @@ -2906,7 +2906,12 @@ static void apiServerSearchData(HttpRequest* req, HttpResponse* resp)
throw ApiException("Query q can't be blank");
}
if (!sMaxVar.empty()) {
maxEnts = std::stoi(sMaxVar);
try {
pdns::checked_stoi_into(maxEnts, sMaxVar);
}
catch (std::logic_error&) {
throw ApiException("Invalid value for maximum entries");
}
}
if (maxEnts < 1) {
throw ApiException("Maximum entries must be larger than 0");
Expand Down
Loading