mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-23 11:44:53 +00:00
More detailed debug log - show ip/port for sender and receiver
This commit is contained in:
1 parent
f7ff571c5f
commit
8ebb3bc37b
4 files changed
+41
-14
No files matched your search
@@ -19,14 +19,18 @@ int mg_printf(struct mg_connection *c, const char *fmt, ...) {
|
||||
return len;
|
||||
}
|
||||
|
||||
char *mg_straddr(struct mg_connection *c, char *buf, size_t len) {
|
||||
char tmp[100];
|
||||
const char *fmt = c->peer.is_ip6 ? "[%s]:%d" : "%s:%d";
|
||||
mg_ntoa(&c->peer, tmp, sizeof(tmp));
|
||||
snprintf(buf, len, fmt, tmp, (int) mg_ntohs(c->peer.port));
|
||||
char *mg_addr_to_str(struct mg_addr *a, char *buf, size_t len) {
|
||||
char tmp[30];
|
||||
const char *fmt = a->is_ip6 ? "[%s]:%d" : "%s:%d";
|
||||
mg_ntoa(a, tmp, sizeof(tmp));
|
||||
snprintf(buf, len, fmt, tmp, (int) mg_ntohs(a->port));
|
||||
return buf;
|
||||
}
|
||||
|
||||
char *mg_straddr(struct mg_connection *c, char *buf, size_t len) {
|
||||
return mg_addr_to_str(&c->peer, buf, len);
|
||||
}
|
||||
|
||||
char *mg_ntoa(const struct mg_addr *addr, char *buf, size_t len) {
|
||||
if (addr->is_ip6) {
|
||||
uint16_t *p = (uint16_t *) addr->ip6;
|
||||
|
||||
Reference in new issue
Block a user