Fix #1888: add %I *printf specifier for IP address. Remove mg_ntoa, mg_straddr

This commit is contained in:
cpq committed 2022-12-03 14:27:07 +00:00
1 parent 89fb3a3d6e
commit b01989f041
12 files changed
+105 -144

No files matched your search

+2 -4
View File
@@ -24,14 +24,12 @@ static void wcb(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
mg_printf(c, "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n");
mg_http_printf_chunk(c, "ID PROTO TYPE LOCAL REMOTE\n");
for (struct mg_connection *t = c->mgr->conns; t != NULL; t = t->next) {
char loc[40], rem[40];
mg_http_printf_chunk(c, "%-3lu %4s %s %-15s %s\n", t->id,
mg_http_printf_chunk(c, "%-3lu %4s %s %I %I\n", t->id,
t->is_udp ? "UDP" : "TCP",
t->is_listening ? "LISTENING"
: t->is_accepted ? "ACCEPTED "
: "CONNECTED",
mg_straddr(&t->loc, loc, sizeof(loc)),
mg_straddr(&t->rem, rem, sizeof(rem)));
4, &t->loc.ip, 4, &t->rem.ip);
}
mg_http_printf_chunk(c, ""); // Don't forget the last empty chunk
} else {