Debug log cheat: add exclamation sign to filename and get separate debug log for each session
This commit is contained in:
parent
441f4021c2
commit
f131ba864f
@ -483,7 +483,7 @@ exit:
|
||||
#ifdef DEBUG
|
||||
if( debug_isopened() ) debug_close();
|
||||
#endif
|
||||
|
||||
DEB((D_FREE, "good exit"));
|
||||
exit(rc);
|
||||
}
|
||||
|
||||
|
@ -106,11 +106,6 @@ int log_open(const char *logname, const char *ext, const char *tty)
|
||||
|
||||
if( logname )
|
||||
{
|
||||
/* Reset previous settings */
|
||||
*log_name = '\0';
|
||||
*log_extension = '\0';
|
||||
*log_ttyname = '\0';
|
||||
|
||||
strnxcpy(log_name, logname, sizeof(log_name));
|
||||
|
||||
if( tty && *tty )
|
||||
@ -122,14 +117,9 @@ int log_open(const char *logname, const char *ext, const char *tty)
|
||||
strnxcat(log_name, ".", sizeof(log_name));
|
||||
strnxcat(log_name, ext, sizeof(log_name));
|
||||
}
|
||||
|
||||
if( (log_fp = fopen(log_name, "a")) == NULL )
|
||||
{
|
||||
logerr("can't open log file \"%s\"", log_name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if( log_name )
|
||||
|
||||
if( log_name )
|
||||
{
|
||||
/* Open previously set log file */
|
||||
|
||||
@ -462,7 +452,29 @@ int debug_open()
|
||||
|
||||
if( debug_name )
|
||||
{
|
||||
if( (debug_fp = fopen(debug_name, "a")) == NULL )
|
||||
|
||||
char log_name[PATH_MAX];
|
||||
char *marker;
|
||||
/* Reset previous settings */
|
||||
*log_name = '\0';
|
||||
*log_extension = '\0';
|
||||
*log_ttyname = '\0';
|
||||
|
||||
if (marker = strchr(debug_name, '!')) {
|
||||
struct timespec xtm;
|
||||
struct tm btm;
|
||||
clock_gettime(CLOCK_REALTIME, &xtm);
|
||||
gmtime_r(&xtm.tv_sec, &btm);
|
||||
// hope sysop will not DoS his own node
|
||||
memcpy(log_name, debug_name, marker-debug_name);
|
||||
sprintf( log_name + (marker-debug_name) + strftime(log_name + (marker-debug_name), 100, ".%Y-%m-%d.%H.%M.%S.", &btm), "%09ld.%s", xtm.tv_nsec, marker+1);
|
||||
// I'm too lazy to add variable
|
||||
}
|
||||
else {
|
||||
strcpy(log_name, debug_name);
|
||||
}
|
||||
|
||||
if( (debug_fp = fopen(log_name, "a")) == NULL )
|
||||
{
|
||||
/* Don't try to open it next time */
|
||||
debug_invalid_name = TRUE;
|
||||
|
@ -360,6 +360,7 @@ case 0: // MD5 challenge
|
||||
}
|
||||
|
||||
case 1: // send sysinfo
|
||||
DEB((D_24554, "send sysinfo"));
|
||||
my_sf = bstate->subphase;
|
||||
bstate->subphase+=1;
|
||||
*block_type = BINKP_BLK_CMD;
|
||||
@ -450,7 +451,7 @@ case 3: // send password on outgoing or pw confirmation on incoming
|
||||
// special empty password is sent if there is no password for the remote addr
|
||||
if (bstate->mode==bmode_incoming_handshake) {
|
||||
if (bstate->password_received) {
|
||||
DEB((D_24554, "password verified"));
|
||||
DEB((D_24554, "send OK, password verified"));
|
||||
buf[0] = BPMSG_OK;
|
||||
*block_type = BINKP_BLK_CMD;
|
||||
*block_length = 1;
|
||||
@ -465,7 +466,7 @@ case 3: // send password on outgoing or pw confirmation on incoming
|
||||
DEB((D_24554, "address not received still"));
|
||||
return 0;
|
||||
}
|
||||
DEB((D_24554, "sending password"));
|
||||
DEB((D_24554, "send password"));
|
||||
|
||||
buf[0] = BPMSG_PWD;
|
||||
*block_type = BINKP_BLK_CMD;
|
||||
@ -550,6 +551,7 @@ case 4:
|
||||
case 2: //send file data
|
||||
n = p_tx_readfile (buf, 4096, bstate->pi); // BINKP_MAXBLOCK
|
||||
if (n>0) {
|
||||
DEB((D_24554, "send data block len=%d", n));
|
||||
*block_type = BINKP_BLK_DATA;
|
||||
*block_length = n;
|
||||
bstate->pi->send->bytes_sent += n;
|
||||
|
@ -165,21 +165,33 @@ void init_state(s_state *pstate)
|
||||
void deinit_state(s_state *pstate)
|
||||
{
|
||||
DEB((D_FREE, "deinit_state begin"));
|
||||
|
||||
DEB((D_FREE, "deinit_state linename"));
|
||||
if (pstate->linename) free(pstate->linename);
|
||||
DEB((D_FREE, "deinit_state cidstr"));
|
||||
if (pstate->cidstr) free(pstate->cidstr);
|
||||
DEB((D_FREE, "deinit_state peername"));
|
||||
if (pstate->peername) free(pstate->peername);
|
||||
DEB((D_FREE, "deinit_state connstr"));
|
||||
if (pstate->connstr) free(pstate->connstr);
|
||||
DEB((D_FREE, "deinit_state inbound"));
|
||||
if (pstate->inbound) free(pstate->inbound);
|
||||
DEB((D_FREE, "deinit_state tinbound"));
|
||||
if (pstate->tinbound) free(pstate->tinbound);
|
||||
DEB((D_FREE, "deinit_state mailfor"));
|
||||
if (pstate->mailfor) deinit_falist(pstate->mailfor);
|
||||
|
||||
DEB((D_FREE, "deinit_state fsqueue"));
|
||||
deinit_fsqueue(&pstate->queue);
|
||||
|
||||
DEB((D_FREE, "deinit_state handshake"));
|
||||
if (state.handshake && state.handshake->deinit) {
|
||||
state.handshake->deinit(state.handshake);
|
||||
}
|
||||
|
||||
DEB((D_FREE, "deinit_state remotedata"));
|
||||
if (pstate->remoteaddrs) free (pstate->remoteaddrs);
|
||||
DEB((D_FREE, "deinit_state localdata"));
|
||||
if (pstate->localaddrs) free (pstate->localaddrs);
|
||||
|
||||
memset(pstate, '\0', sizeof(s_state));
|
||||
|
Loading…
x
Reference in New Issue
Block a user