ESP8266-based WiFi serial modem emulator ROM
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

syslog: Add syslog_buf to log a buffer of arbitrary size

+34 -22
+3 -22
SocksClient.cpp
··· 378 378 state = STATE_PROXY; 379 379 } 380 380 381 - #ifdef SOCKS_TRACE 382 - void 383 - SocksClient::dump_buf(size_t len) 384 - { 385 - char tbuf[(64 * 3) + 1]; 386 - size_t tbufl = 0; 387 - 388 - if (len > 64) 389 - len = 64; 390 - 391 - for (size_t i = 0; i < len; i++) { 392 - sprintf(tbuf + tbufl, " %02x", buf[i]); 393 - tbufl += 3; 394 - } 395 - 396 - syslog.logf(LOG_DEBUG, "[%d] %s", slot, tbuf); 397 - } 398 - #endif 399 - 400 381 void 401 382 SocksClient::proxy() 402 383 { ··· 415 396 syslog.logf(LOG_DEBUG, "[%d] read %d bytes from client in, " 416 397 "sending to client out %s", slot, len, 417 398 (tls() ? "tls" : "")); 418 - dump_buf(len); 399 + syslog_buf(buf, len); 419 400 #endif 420 401 if (tls()) 421 402 client_out_tls.write(buf, len); ··· 430 411 syslog.logf(LOG_DEBUG, "[%d] read %d bytes from " 431 412 "client out tls, sending to client in", 432 413 slot, len); 433 - dump_buf(len); 414 + syslog_buf(buf, len); 434 415 #endif 435 416 client_in.write(buf, len); 436 417 } ··· 440 421 #ifdef SOCKS_TRACE 441 422 syslog.logf(LOG_DEBUG, "[%d] read %d bytes from " 442 423 "client out, sending to client in", slot, len); 443 - dump_buf(len); 424 + syslog_buf(buf, len); 444 425 #endif 445 426 client_in.write(buf, len); 446 427 }
+30
util.cpp
··· 174 174 175 175 return ret; 176 176 } 177 + 178 + void 179 + syslog_buf(const char *buf, size_t len) 180 + { 181 + static char tbuf[(64 * 4) + 1]; 182 + size_t tbufl = 0; 183 + 184 + if (len > 64) 185 + len = 64; 186 + 187 + for (size_t i = 0; i < len; i++) { 188 + if (buf[i] == '\n') { 189 + tbuf[tbufl++] = '\\'; 190 + tbuf[tbufl++] = 'n'; 191 + } else if (buf[i] == '\r') { 192 + tbuf[tbufl++] = '\\'; 193 + tbuf[tbufl++] = 'r'; 194 + } else if (buf[i] == ' ') { 195 + tbuf[tbufl++] = ' '; 196 + } else if (buf[i] < '!' || buf[i] > '~') { 197 + sprintf(tbuf + tbufl, "[%02x]", buf[i]); 198 + tbufl += 4; 199 + } else { 200 + tbuf[tbufl++] = buf[i]; 201 + } 202 + } 203 + tbuf[tbufl] = '\0'; 204 + 205 + syslog.log(LOG_DEBUG, tbuf); 206 + }
+1
wifippp.h
··· 147 147 int output(char); 148 148 int output(const char *); 149 149 int output(String); 150 + void syslog_buf(const char *, size_t); 150 151 151 152 /* wifippp.ino */ 152 153 void exec_cmd(char *, size_t);