diff --git a/CHANGES b/CHANGES index aba0735..b28e76e 100644 --- a/CHANGES +++ b/CHANGES @@ -266,3 +266,5 @@ Alexey Khromov (zx@zxalexis.ru) + Daemon mode - fixed working time for tcp nodes (CM) + Fixed some x64 errors in comparisons to integers + Added systemd and xinetd service files to contrib folder + + Fixed flag files creation + + Added flags for TIC files (inctic_flag) and files (incfile_flag) diff --git a/source/bforce/conf_proc.c b/source/bforce/conf_proc.c index 1d7d02a..fc85dbf 100644 --- a/source/bforce/conf_proc.c +++ b/source/bforce/conf_proc.c @@ -100,6 +100,8 @@ s_conf_entry bforce_config[BFORCE_NUMBER_OF_KEYWORDS+1] = { CONF_KEY(freq_srif_command, CT_STRING), CONF_KEY(incnet_flag, CT_STRING), CONF_KEY(incarc_flag, CT_STRING), + CONF_KEY(inctic_flag, CT_STRING), + CONF_KEY(incfile_flag, CT_STRING), CONF_KEY(hide_our_aka, CT_ADDRESS), CONF_KEY(history_file, CT_STRING), CONF_KEY(hydra_options, CT_OPTIONS), diff --git a/source/bforce/daemon.c b/source/bforce/daemon.c index 2a2fcb1..dfd706e 100644 --- a/source/bforce/daemon.c +++ b/source/bforce/daemon.c @@ -1050,13 +1050,13 @@ int daemon_run(const char *confname, const char *incname, bool quit) if( max_tcpip > 0 ) { - DEB((D_INFO,"daemon: daemon_tcpip_queue")); + DEB((D_DAEMON,"daemon: daemon_tcpip_queue")); daemon_queue_do(&daemon_queues[TCPIP_QUEUE]); } if( max_modem > 0 ) { - DEB((D_INFO,"daemon: daemon_modem_queue")); + DEB((D_DAEMON,"daemon: daemon_modem_queue")); daemon_queue_do(&daemon_queues[MODEM_QUEUE]); } diff --git a/source/bforce/outb_fsqueue.c b/source/bforce/outb_fsqueue.c index ddf0e9f..7e8a9fb 100644 --- a/source/bforce/outb_fsqueue.c +++ b/source/bforce/outb_fsqueue.c @@ -31,6 +31,7 @@ int out_filetype(const char *fname) else p_nam = fname; + DEB((D_EVENT, "outb_fsqueue: getting type of file %s", p_nam)); /* * Get file name extension */ @@ -39,12 +40,19 @@ int out_filetype(const char *fname) for( i = 0; outtab[i].ext; i++ ) if( strcasemask(p_ext, outtab[i].ext) == 0 ) + { + DEB((D_EVENT, "outb_fsqueue: got type %d from outtab ext %s", outtab[i].type, p_ext )); return outtab[i].type; + } for( i = 0; exttab[i].ext; i++ ) if( strcasemask(p_ext, exttab[i].ext) == 0 ) + { + DEB((D_EVENT, "outb_fsqueue: got type %d from exttab ext %s", exttab[i].type, p_ext )); return exttab[i].type; + } + DEB((D_EVENT, "outb_fsqueue: got type UNKNOWN", exttab[i].type, p_ext )); return TYPE_UNKNOWN; } diff --git a/source/bforce/prot_binkp.c b/source/bforce/prot_binkp.c index 3604b69..53731db 100644 --- a/source/bforce/prot_binkp.c +++ b/source/bforce/prot_binkp.c @@ -1052,7 +1052,7 @@ case BINKP_BLK_DATA: if( n < 0 ) { log("error writing local file"); - if( n == -2 ) { + if( n == (long int)-2 ) { bstate->extracmd[0] = BPMSG_GOT; sprintf(bstate->extracmd+1, "%s %ld %ld", bstate->pi->recv->net_name, (long)bstate->pi->recv->bytes_total, (long)bstate->pi->recv->mod_time); @@ -1081,28 +1081,33 @@ case BINKP_BLK_DATA: p_rx_fclose(bstate->pi); PROTO_ERROR("extra data for file") } - else if( bstate->pi->recv->bytes_received == bstate->pi->recv->bytes_total ) { - DEB((D_24554, "receive completed")); - bstate->frs = frs_nothing; - bstate->pi->recv->status = FSTAT_SUCCESS; - if( !p_rx_fclose(bstate->pi) ) { - bstate->extracmd[0] = BPMSG_GOT; - sprintf(bstate->extracmd+1, "%s %ld %ld", - bstate->pi->recv->net_name, (long)bstate->pi->recv->bytes_total, - (long)bstate->pi->recv->mod_time); - bstate->extraislast = false; - return 1; - } - else { - DEB((D_24554, "some error committing file")); - bstate->extracmd[0] = BPMSG_SKIP; - sprintf(bstate->extracmd+1, "%s %ld %ld", - bstate->pi->recv->net_name, (long)bstate->pi->recv->bytes_total, - (long)bstate->pi->recv->mod_time); - bstate->extraislast = false; - return 1; - } - } else { + else if( bstate->pi->recv->bytes_received == bstate->pi->recv->bytes_total ) + { + DEB((D_24554, "receive completed")); + bstate->frs = frs_nothing; + bstate->pi->recv->status = FSTAT_SUCCESS; + if( !p_rx_fclose(bstate->pi) ) + { + bstate->extracmd[0] = BPMSG_GOT; + sprintf(bstate->extracmd+1, "%s %ld %ld", + bstate->pi->recv->net_name, (long)bstate->pi->recv->bytes_total, + (long)bstate->pi->recv->mod_time); + bstate->extraislast = false; + return 1; + } + else + { + DEB((D_24554, "some error committing file")); + bstate->extracmd[0] = BPMSG_SKIP; + sprintf(bstate->extracmd+1, "%s %ld %ld", + bstate->pi->recv->net_name, (long)bstate->pi->recv->bytes_total, + (long)bstate->pi->recv->mod_time); + bstate->extraislast = false; + return 1; + } + } + else + { DEB((D_24554, "data block accepted")); return 1; } diff --git a/source/bforce/prot_common.c b/source/bforce/prot_common.c index 4fd536f..afd6e9d 100644 --- a/source/bforce/prot_common.c +++ b/source/bforce/prot_common.c @@ -415,6 +415,7 @@ int p_tx_rewind(s_protinfo *pi, size_t pos) void prot_traffic_update(s_traffic *traf, size_t size, int xtime, int type) { + DEB((D_EVENT, "prot_common: Adding type %d with size %ld to stats", type, size)); if( type & TYPE_REQANSW ) { traf->freqed_size += size; @@ -433,6 +434,10 @@ void prot_traffic_update(s_traffic *traf, size_t size, int xtime, int type) traf->arcmail_time += xtime; traf->arcmail_num++; } + else if( type & TYPE_TICFILE ) + { + traf->ticfile_num++; + } else { traf->files_size += size; diff --git a/source/bforce/sess_call.c b/source/bforce/sess_call.c index a895cc1..dea5fa5 100644 --- a/source/bforce/sess_call.c +++ b/source/bforce/sess_call.c @@ -656,7 +656,7 @@ int call_system(s_faddr addr, const s_bforce_opts *opts) { log("bad phone, excluding modem"); call_mayuse &= ~CALL_MODEM; - if( !(call_mustuse & CALL_MODEM) ) + if( !(call_mayuse) ) { errmsg = "don't know phone number"; gotoexit(BFERR_PHONE_UNKNOWN); @@ -690,7 +690,7 @@ int call_system(s_faddr addr, const s_bforce_opts *opts) { call_mayuse &= ~CALL_MODEM; log("bad worktime, excluding modem"); - if( !(call_mustuse & CALL_MODEM) ) + if( !(call_mayuse) ) { errmsg = "not works now, try later"; gotoexit(BFERR_NOTWORKING); @@ -783,7 +783,7 @@ int call_system(s_faddr addr, const s_bforce_opts *opts) DEB((D_EVENT, "bad host or proto -> exclude IP, mayuse=%d", call_mayuse)); // If we had ONLY tcpip command - go out with error - if( !(call_mustuse & CALL_TCPIP_ANY) ) + if( !(call_mayuse) ) { errmsg = "Aborting, don't know host name"; gotoexit(BFERR_PHONE_UNKNOWN); diff --git a/source/bforce/sess_main.c b/source/bforce/sess_main.c index 99c28d0..7329dec 100644 --- a/source/bforce/sess_main.c +++ b/source/bforce/sess_main.c @@ -895,13 +895,22 @@ int session(void) * Write total amount of received/sent bytes, files, etc. */ p_log_txrxstat(&pi); - - + + + // Protocol info - real info from protocol + DEB((D_EVENT,"sess_main: Pi stats> Net: %d, Arc: %d, Fil: %d, Tic: %d", + pi.traffic_rcvd.netmail_num, pi.traffic_rcvd.arcmail_num, + pi.traffic_rcvd.files_num, pi.traffic_rcvd.ticfile_num)); + + // Session info - HANDSHAKE info for traffic + DEB((D_EVENT,"sess_main: Sess stats> Net: %d, Arc: %d, Fil: %d, Tic: %d", + state.traff_recv.netmail_num, state.traff_recv.arcmail_num, + state.traff_recv.files_num, state.traff_recv.ticfile_num)); /* * Raise flags if session incoming traffic was not empty */ if ( (p = conf_string(cf_incnet_flag)) ) - if (state.traff_recv.netmail_size > 0) { + if (pi.traffic_rcvd.netmail_size > 0) { DEB((D_EVENT, "Incoming netmail > 0, raising flag")); log("Raising flag for netmail in %s", p); fd = open(p, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP ); @@ -915,7 +924,7 @@ int session(void) } if ( (p = conf_string(cf_incarc_flag)) ) - if (state.traff_recv.arcmail_size > 0) { + if (pi.traffic_rcvd.arcmail_size > 0) { DEB((D_EVENT, "Incoming arcmail > 0, raising flag")); log("Raising flag for arcmail in %s", p); fd = open(p, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); @@ -928,6 +937,33 @@ int session(void) } } + if ( (p = conf_string(cf_inctic_flag)) ) + if (pi.traffic_rcvd.ticfile_num > 0) { + DEB((D_EVENT, "Incoming TIC files > 0, raising flag")); + log("Raising flag for TIC in %s", p); + fd = open(p, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); + if (fd == -1) { + DEB((D_EVENT, "Error raising ticfiles flag")); + log("Error creating flag for ticfiles in %s", p); + } else { + /* all ok - closing file */ + close(fd); + } + } + if ( (p = conf_string(cf_incfile_flag)) ) + if (pi.traffic_rcvd.files_size > 0) { + DEB((D_EVENT, "Incoming FILES > 0, raising flag")); + log("Raising flag for files in %s", p); + fd = open(p, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); + if (fd == -1) { + DEB((D_EVENT, "Error raising files flag")); + log("Error creating flag for files in %s", p); + } else { + /* all ok - closing file */ + close(fd); + } + } + /* * Save session traffic before deiniting */ diff --git a/source/include/confread.h b/source/include/confread.h index 17d35a6..48457af 100644 --- a/source/include/confread.h +++ b/source/include/confread.h @@ -195,6 +195,8 @@ typedef enum { cf_freq_srif_command, cf_incnet_flag, cf_incarc_flag, + cf_inctic_flag, + cf_incfile_flag, cf_hide_our_aka, cf_history_file, cf_hydra_options, diff --git a/source/include/prot_common.h b/source/include/prot_common.h index d5967fc..734879e 100644 --- a/source/include/prot_common.h +++ b/source/include/prot_common.h @@ -44,6 +44,7 @@ typedef struct traffic { int freqed_num; int freqed_time; size_t freqed_size; + int ticfile_num; } s_traffic; /*