From d3cf78002617e7f16b837a5221be2d687cc78698 Mon Sep 17 00:00:00 2001 From: Alexey Khromov Date: Sat, 12 Oct 2024 21:19:24 +0300 Subject: [PATCH] Added binkp_waitaka option Initial daemon mode nodelist change detection and restart --- CHANGES | 7 +- source/.version | 2 +- source/ChangeLog | 138 ------------------------------------- source/bforce/conf_proc.c | 1 + source/bforce/daemon.c | 32 ++++++++- source/bforce/nodelist.c | 2 +- source/bforce/prot_binkp.c | 70 ++++++++++++++----- source/include/confread.h | 1 + 8 files changed, 92 insertions(+), 161 deletions(-) delete mode 100644 source/ChangeLog diff --git a/CHANGES b/CHANGES index fc46fa0..6d0366b 100644 --- a/CHANGES +++ b/CHANGES @@ -268,5 +268,10 @@ Alexey Khromov (zx@zxalexis.ru) + Added systemd and xinetd service files to contrib folder + Fixed flag files creation + Added flags for TIC files (inctic_flag) and files (incfile_flag) - + Fixed nodelist index creation + + Fixed nodelist index creation for root nodes + Added support for TCP port description in IBN/IFC/ITN flags + +0.26 + + Added option binkp_waitaka - wait on caller AKA on incoming sessions + and switch self AKA with the hideAKA config + + Initial nodelist change detection for daemon mode diff --git a/source/.version b/source/.version index 3d9dcb1..9922215 100644 --- a/source/.version +++ b/source/.version @@ -1 +1 @@ -0.25.3 +0.26 diff --git a/source/ChangeLog b/source/ChangeLog deleted file mode 100644 index 975134a..0000000 --- a/source/ChangeLog +++ /dev/null @@ -1,138 +0,0 @@ -2006-10-27 Evgeniy Kozhuhovskiy - - * bforce/nodelist.c (nodelist_open): some fixes - -2006-02-05 Evgeniy Kozhuhovskiy - - * bforce/logger.c: trying to fix broken syslog. - -2006-01-04 Evgeniy Kozhuhovskiy - - * bforce/daemon_call.c (daemon_call_branch): if phone == - 00-00-000000, we call via ip - -2005-10-24 Evgeniy Kozhuhovskiy - - * bforce/sess_call.c (call_system): added possibility to run - external script for each line in override - -2005-09-03 Andrey Slusar - - * bforce/prot_emsi_misc.c (emsi_parsedat): correct time_t arg - size. - - * bforce/prot_zmrecv.c (zmodem_proc_ZFILE): correct time_t arg - size. - -2005-09-03 Evgeniy Kozhuhovskiy - - * bforce/prot_hydra.c: added patch to fix problems while sending - files from ?lo on hydra, by anray - -2005-06-23 Evgeniy Kozhuhovskiy - - * bforce/prot_emsi.c (sm_rx_waitseq): reviewed code for buggy-emsi option - - * configure.in: added --disable-buggy-emsi option for stupid mailers - -2005-06-05 Evgeniy Kozhuhovskiy - - * configure.in: added logdir and spooldir to ./configure - (thnx to max boyarov) - -2005-06-03 Evgeniy Kozhuhovskiy - - * configure.in: fixed warnings under *bsd (removed sys/mount.h - from the list of checking headers) - * configure.in: syslog disabled by default - -2005-05-08 Evgeniy Kozhuhovskiy - - * bfutil/nlookup.c (print_nodeinfo): added "Type" entry to the - nlookup output - -2005-05-08 Evgeniy Kozhuhovskiy - - * configure.in: Some changes - * configure.in: Now default prefix is /usr/local/fido (as in fidogate) - -2005-03-26 Evgeniy Kozhuhovskiy - - * bforce/nodelist.c (nodelist_open): fixed compilation with gcc-2.95 - -2005-03-22 Evgeniy Kozhuhovskiy - - * INSTALL.ru: added some information - -2005-02-21 Evgeniy Kozhuhovskiy - - * bforce/sess_answ.c (answ_system): fixed deiniting of tcpip port - -2005-02-20 Evgeniy Kozhuhovskiy - - * bforce/sess_answ.c (answ_system): fixed bug with loggin inbound - tcpip sessions - - * bforce/logger.c (log_getfilename): fixed possible bug - -2005-02-17 Evgeniy Kozhuhovskiy - - * configure.in: fixed --with-owner and --with-group - -2005-02-16 Evgeniy Kozhuhovskiy - - * bforce/prot_emsi.c (sm_rx_waitseq): fixed unexpected emsi - sequence - -2005-02-13 Evgeniy Kozhuhovskiy - - * bforce/sess_call.c (call_system_quiet): added run_before_session - -2005-02-12 Evgeniy Kozhuhovskiy - - * outman: added bso support - -2005-02-10 Evgeniy Kozhuhovskiy - - * bforce.conf: added nodelist mask examples - -2005-02-09 Evgeniy Kozhuhovskiy - - * bforce/nodelist.c (nodelist_open): fixed stupid memory leak. - -2005-01-16 Evgeniy Kozhuhovskiy - - * bforce/nodelist.c (nodelist_open): fixed mask detection - * bforce/nodelist.c (nodelist_open): added tmpseekdir, contains - full path to currently seeked nodelist - -2005-01-12 Andrey Slusar - - * Makefile.in (installdirs): fix compiling when use a bsd - chown. - - * Makefile.in (bforce/expression.c): fix compiling when use - a bsd make. - -2005-01-12 Evgeniy Kozhuhovskiy - - * bforce/nodelist.c (nodelist_open): rewritten logic - - * bforce/logger.c (log): fixed working with --enable-syslog - - * include/logger.h: fixed some warnings - -2005-01-11 Evgeniy Kozhuhovskiy - - * bforce/nodelist.c (nodelist_open): fixed warnings - -2005-01-11 Andrey Slusar - - * Makefile.in (CFLAGS): added -fno-builtin. - - * bforce/nodelist.c (nodelist_checkheader): small fixes. - -2005-01-10 Evgeniy Kozhuhovskiy - - * bforce/nodelist.c (nodelist_open): added mask detection. - diff --git a/source/bforce/conf_proc.c b/source/bforce/conf_proc.c index fc85dbf..fd190dd 100644 --- a/source/bforce/conf_proc.c +++ b/source/bforce/conf_proc.c @@ -67,6 +67,7 @@ s_conf_entry bforce_config[BFORCE_NUMBER_OF_KEYWORDS+1] = { CONF_KEY(address, CT_ADDRESS), CONF_KEY(amiga_outbound_directory, CT_PATH), CONF_KEY(binkp_timeout, CT_NUMBER), + CONF_KEY(binkp_waitaka, CT_BOOLEAN), CONF_KEY(daemon_circle, CT_NUMBER), CONF_KEY(daemon_circle_crash, CT_NUMBER), CONF_KEY(daemon_circle_direct, CT_NUMBER), diff --git a/source/bforce/daemon.c b/source/bforce/daemon.c index dfd706e..ab6c785 100644 --- a/source/bforce/daemon.c +++ b/source/bforce/daemon.c @@ -112,6 +112,7 @@ static RETSIGTYPE daemon_sighandler(int signum) static int daemon_sysentry_init(s_sysentry *sysent) { + int res = -1; s_override *p; char msg[64] = ""; char abuf[BF_MAXADDRSTR+1]; @@ -120,8 +121,13 @@ static int daemon_sysentry_init(s_sysentry *sysent) (void)session_stat_get(&sysent->stat, &sysent->node.addr); /* Lookup node in nodelist */ - (void)nodelist_lookup(&sysent->node, sysent->node.addr); - + res = nodelist_lookup(&sysent->node, sysent->node.addr); + + if (res == -1) { + log("QUEUE: nodelist error for %s", ftn_addrstr(abuf, sysent->node.addr)); + log("QUEUE: try to re-read config!"); + } + /* Set overrides */ if( (p = conf_override(cf_override, sysent->node.addr)) ) { @@ -1034,6 +1040,28 @@ int daemon_run(const char *confname, const char *incname, bool quit) */ if( !timer_running(timer_rescan) || timer_expired(timer_rescan) ) { + //Check the presence of nodelist index. + s_faddr locaddr; + char * wcard; + s_node * mynode; + wcard = xstrcpy('\0'); + DEB((D_DAEMON,"daemon: chk nodelist")); + if (!ftn_addrparse(&locaddr, conf_string(cf_address), wcard) ) + { + //Check the presence of nodelist index. + if (!nodelist_lookup(mynode, locaddr)) { + // All OK + DEB((D_DAEMON,"daemon: chk nodelist OK")); + } else { + // All NOT OK + DEB((D_DAEMON,"daemon: chk nodelist FAILED")); + dmstate = DM_Restart; + break; + } + } + + + // End checkpresense (void)daemon_rescan_sysqueue(&daemon_sys_queue, daemon_queues); timer_set(&timer_rescan, circle_rescan); diff --git a/source/bforce/nodelist.c b/source/bforce/nodelist.c index e686a1c..57286c0 100644 --- a/source/bforce/nodelist.c +++ b/source/bforce/nodelist.c @@ -572,7 +572,7 @@ int nodelist_close(s_nodelist *nlp) logerr("cannot close nodelist index \"%s\"", nlp->name_index); rc = 1; } - + memset(nlp,'\0',sizeof(s_nodelist)); free(nlp); return rc; diff --git a/source/bforce/prot_binkp.c b/source/bforce/prot_binkp.c index 53731db..c54d833 100644 --- a/source/bforce/prot_binkp.c +++ b/source/bforce/prot_binkp.c @@ -339,6 +339,8 @@ int binkp_transfer(s_binkp_sysinfo *local_data, s_binkp_sysinfo *remote_data, s_ int binkp_getforsend(s_binkp_state *bstate, char *buf, int *block_type, unsigned short *block_length) { int my_sf, wr_pos; + s_faddr *bestaddr; + int n; // read file if (bstate->extracmd[0]!=(char)-1) { DEB((D_24554, "Send cmd to remote %d %s", bstate->extracmd[0], bstate->extracmd+1)); @@ -434,31 +436,62 @@ case 7: // p case 2: - DEB((D_24554, "send address")); + if ( (bstate->mode==bmode_incoming_handshake) && (conf_boolean(cf_binkp_waitaka)) && (!(bstate->address_established)) ) + { + DEB((D_24554, "send address paused - waitaka option present")); + return 0; + } + else + { + + DEB((D_24554, "Send address")); bstate->phase += 1; buf[0] = BPMSG_ADR; wr_pos = 1; - int i; - for( i = 0; i < state.n_localaddr; i++ ) - { - if (i) wr_pos += sprintf(buf+wr_pos, " "); - if (state.localaddrs[i].addr.point) { - wr_pos += sprintf(buf+wr_pos, "%d:%d/%d.%d@%s", - state.localaddrs[i].addr.zone, state.localaddrs[i].addr.net, - state.localaddrs[i].addr.node, state.localaddrs[i].addr.point, - state.localaddrs[i].addr.domain); - } - else { - wr_pos += sprintf(buf+wr_pos, "%d:%d/%d@%s", + if (conf_boolean(cf_binkp_waitaka)) + { + // Sending bestAKA: + DEB((D_24554, "Binkp - getting best aka - waitaka option present")); + bestaddr = session_get_bestaka(state.remoteaddrs[0].addr); + if (bestaddr->point) { + wr_pos += sprintf(buf+wr_pos, "%d:%d/%d.%d@%s", + bestaddr->zone, bestaddr->net, + bestaddr->node, bestaddr->point, + bestaddr->domain); + } + else { + wr_pos += sprintf(buf+wr_pos, "%d:%d/%d@%s", + bestaddr->zone, bestaddr->net, + bestaddr->node, + bestaddr->domain); + } + } + else + { + // Sending all adresses: + int i; + for( i = 0; i < state.n_localaddr; i++ ) + { + if (i) wr_pos += sprintf(buf+wr_pos, " "); + if (state.localaddrs[i].addr.point) { + wr_pos += sprintf(buf+wr_pos, "%d:%d/%d.%d@%s", + state.localaddrs[i].addr.zone, state.localaddrs[i].addr.net, + state.localaddrs[i].addr.node, state.localaddrs[i].addr.point, + state.localaddrs[i].addr.domain); + } + else { + wr_pos += sprintf(buf+wr_pos, "%d:%d/%d@%s", state.localaddrs[i].addr.zone, state.localaddrs[i].addr.net, state.localaddrs[i].addr.node, state.localaddrs[i].addr.domain); - } + } + } + } + *block_type = BINKP_BLK_CMD; + *block_length = wr_pos; + DEB((D_24554, "send address: %s", buf+1)); + return 1; } - *block_type = BINKP_BLK_CMD; - *block_length = wr_pos; - DEB((D_24554, "send address: %s", buf+1)); - return 1; 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 @@ -517,6 +550,7 @@ case 3: // send password on outgoing or pw confirmation on incoming case 4: if (bstate->mode==bmode_incoming_handshake) { + int i = 0; DEB((D_24554, "incoming handshake is complete")); bstate->complete = true; char *p; diff --git a/source/include/confread.h b/source/include/confread.h index 48457af..2ca195a 100644 --- a/source/include/confread.h +++ b/source/include/confread.h @@ -162,6 +162,7 @@ typedef enum { cf_address, cf_amiga_outbound_directory, cf_binkp_timeout, + cf_binkp_waitaka, cf_daemon_circle, cf_daemon_circle_crash, cf_daemon_circle_direct,