Skip to content
Open
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 src/mesh/api/ServerAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
template <typename T>
ServerAPI<T>::ServerAPI(T &_client) : StreamAPI(&client), concurrency::OSThread("ServerAPI"), client(_client)
{
LOG_INFO("Incoming API connection");
auto ip = client.remoteIP();
LOG_INFO("Incoming API connection from %u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]);
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IP logging here is hard-coded to IPv4 octets ("%u.%u.%u.%u"). If this code ever runs on an IPv6-capable stack, the output will be incorrect/misleading. Consider formatting via toString() when available (with an ARCH_PORTDUINO fallback), ideally via a shared helper to keep formatting consistent across API servers.

Suggested change
LOG_INFO("Incoming API connection from %u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]);
LOG_INFO("Incoming API connection from %s", ip.toString().c_str());

Copilot uses AI. Check for mistakes.
}

template <typename T> ServerAPI<T>::~ServerAPI()
Expand Down
3 changes: 2 additions & 1 deletion src/mesh/api/WiFiServerAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ void deInitApiServer()
WiFiServerAPI::WiFiServerAPI(WiFiClient &_client) : ServerAPI(_client)
{
api_type = TYPE_WIFI;
LOG_INFO("Incoming wifi connection");
auto ip = _client.remoteIP();
LOG_INFO("Incoming wifi connection from %u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]);
Comment on lines +29 to +30
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This repeats IPv4-only octet formatting for the remote address. To avoid duplication (and to support IPv6 where possible), consider using a shared IP formatting helper (or toString() with an ARCH_PORTDUINO fallback) so all API connection logs are consistent across WiFi/Ethernet/base ServerAPI.

Suggested change
auto ip = _client.remoteIP();
LOG_INFO("Incoming wifi connection from %u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]);
auto ip = _client.remoteIP();
#ifdef ARCH_PORTDUINO
// ARCH_PORTDUINO may not support IPv6 or IPAddress::toString(), so use octet formatting.
LOG_INFO("Incoming wifi connection from %u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]);
#else
LOG_INFO("Incoming wifi connection from %s", ip.toString().c_str());
#endif

Copilot uses AI. Check for mistakes.
}

WiFiServerPort::WiFiServerPort(int port) : APIServerPort(port) {}
Expand Down
3 changes: 2 additions & 1 deletion src/mesh/api/ethServerAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ void initApiServer(int port)

ethServerAPI::ethServerAPI(EthernetClient &_client) : ServerAPI(_client)
{
LOG_INFO("Incoming ethernet connection");
auto ip = _client.remoteIP();
LOG_INFO("Incoming ethernet connection from %u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]);
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This repeats IPv4-only octet formatting for the remote address. Consider routing all API-server IP logging through a shared helper (or toString() with appropriate fallbacks) so formatting is consistent and easier to extend (e.g., IPv6) across server implementations.

Suggested change
LOG_INFO("Incoming ethernet connection from %u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]);
LOG_INFO("Incoming ethernet connection from %s", ip.toString().c_str());

Copilot uses AI. Check for mistakes.
api_type = TYPE_ETH;
}

Expand Down
Loading