Added callout hiddenline rotation and multiply INA
All checks were successful
Altlinux build / build-alt (push) Successful in 2m36s
Archlinux build / build-arch (push) Successful in 3m49s
Archlinux build / make-test (push) Successful in 2m5s
Debian build / build-ubuntu (push) Successful in 3m53s

This commit is contained in:
Alexey Khromov 2025-04-26 21:23:31 +03:00
parent 72f46f357d
commit 0999c65b1a
17 changed files with 339 additions and 95 deletions

16
CHANGES
View File

@ -286,3 +286,19 @@ Alexey Khromov (zx@zxalexis.ru)
+ Fixed RPM spec-file to make builds for AltLinux + Fixed RPM spec-file to make builds for AltLinux
+ Added fail2ban filter to contrib + Added fail2ban filter to contrib
+ Fixed node/point-lists indexing and parsing for points listed + Fixed node/point-lists indexing and parsing for points listed
0.27
+ Fixed warnings from PVS-Studio analyser
+ Fixed getaddrinfo switching through available ip-addresses
+ Reduced SYN-SENT timeout to 3 secs to avoid blocking on hosts with services down
+ nlookup - new option -o to show configured overrides and hidden lines
+ nlookup - new option -t to show calltable
+ Added support for multiply INA: addresses of a node
+ Added automatic rolling of all available adresses on callout
+ Added automatic rolling of all available hidden phone numbers on callout
+ Full rework of overrides in config:
* override (not hidden) changes phone,ipaddr and flags (old behaviour - add flags)
* hidden flags temporary rolls instead of original
* INA in hidden flags sets remote address, protoflags change protocols
* ipaddr in hidden flags overwrites original and has max priority
* phone in hidden lines do not affect ip callout in case without flags

14
debian/changelog vendored
View File

@ -1,3 +1,17 @@
bforce (0.27) UNRELEASED; urgency=medium
* Fixed warnings from PVS-Studio analyser
* Fixed getaddrinfo switching through available ip-addresses
* Reduced SYN-SENT timeout to 3 secs to avoid blocking on hosts with services down
* nlookup - new option -o to show configured overrides and hidden lines
* nlookup - new option -t to show calltable
* Added support for multiply INA: addresses of a node
* Added automatic rolling of all available adresses on callout
* Added automatic rolling of all available hidden phone numbers on callout
* Full rework of overrides in config
-- Alexey Khromov <zx@zxalexis.ru> Sat, 26 Apr 2025 21:19:54 +0300
bforce (0.26.2) UNRELEASED; urgency=medium bforce (0.26.2) UNRELEASED; urgency=medium
* Added tests to CI actions * Added tests to CI actions

View File

@ -2,7 +2,7 @@
.SH NAME .SH NAME
Bnlookup \- Nodelist search tool for bforce Bnlookup \- Nodelist search tool for bforce
.SH SYNOPSYS .SH SYNOPSYS
\fBnlookup [-rh] [-C\fIconfig\fB]\fR \fBnlookup [-otrh] [-C\fIconfig\fB]\fR
.SH DESCRIPTION .SH DESCRIPTION
\fBnlookup\fP is a nodelist search tool for BinkleyForce FTN mailer. \fBnlookup\fP is a nodelist search tool for BinkleyForce FTN mailer.
@ -13,6 +13,12 @@ show nodelist string
\fB\-m\fR \fB\-m\fR
show sysops e-mail (see FSP-1004.001 - p2) show sysops e-mail (see FSP-1004.001 - p2)
.P .P
\fB\-t\fR
show calltable
.P
\fB\-o\fR
show overrides
.P
\fB-h\fR \fB-h\fR
show help message show help message
.SH SEE ALSO .SH SEE ALSO

View File

@ -1,7 +1,7 @@
Summary: Bforce, Fidonet mailer Summary: Bforce, Fidonet mailer
Name: bforce Name: bforce
Version: 0.26.2 Version: 0.27
Release: %{_vendor}.1 Release: %{_vendor}1
Copyright: GPL Copyright: GPL
Group: Fidonet/mailer Group: Fidonet/mailer
Source0: bforce-%{version}.tar.gz Source0: bforce-%{version}.tar.gz

View File

@ -1 +1 @@
0.26.2 0.27

View File

@ -137,7 +137,7 @@ elemexp : INCOMING
} }
| FLAG flagstring | FLAG flagstring
{ {
$$ = $2; $$ = $2; //-V1037
} }
| CONNSPEED AROP NUMBER | CONNSPEED AROP NUMBER
{ {
@ -163,7 +163,7 @@ elemexp : INCOMING
} }
| TIME timestring | TIME timestring
{ {
$$ = $2; $$ = $2; //-V1037
} }
| EXEC TEXT | EXEC TEXT
{ {
@ -194,7 +194,7 @@ flagstring : TEXT
} }
| TEXT COMMA flagstring | TEXT COMMA flagstring
{ {
$$ = expr_check_logic($1, OR, $3); $$ = expr_check_logic($1, OR, $3); //-V1037
} }
; ;
timestring : TEXT timestring : TEXT
@ -205,7 +205,7 @@ timestring : TEXT
} }
| TEXT COMMA timestring | TEXT COMMA timestring
{ {
$$ = expr_check_logic($1, OR, $3); $$ = expr_check_logic($1, OR, $3); //-V1037
} }
; ;
%% %%

View File

@ -16,6 +16,7 @@
#include "logger.h" #include "logger.h"
#include "util.h" #include "util.h"
#include "io.h" #include "io.h"
#include <netinet/tcp.h>
#define DEFAULT_PORT 60179 /* Birthday .. mother fucker :) */ #define DEFAULT_PORT 60179 /* Birthday .. mother fucker :) */
@ -39,10 +40,13 @@ static RETSIGTYPE tcpip_brokenpipe(int sig)
static int tcpip_connect2(struct addrinfo *ai) static int tcpip_connect2(struct addrinfo *ai)
{ {
int fd = -1; int fd = -1;
bool connected = FALSE;
char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
int synRetries = 2; // Send a total of 3 SYN packets => Timeout ~7s
int usertimeout = 3000;
struct addrinfo *rai; struct addrinfo *rai;
for (rai = ai; rai != NULL; rai = rai->ai_next) for (rai = ai; rai != NULL; rai = rai->ai_next)
{ {
if (getnameinfo(rai->ai_addr, rai->ai_addrlen, hbuf, sizeof(hbuf), sbuf, if (getnameinfo(rai->ai_addr, rai->ai_addrlen, hbuf, sizeof(hbuf), sbuf,
@ -57,23 +61,32 @@ static int tcpip_connect2(struct addrinfo *ai)
} }
else else
{ {
DEB((D_INFO, "tcpip_connect2: socket opened - breaking")); DEB((D_INFO, "tcpip_connect2: socket opened - try to connect"));
setsockopt(fd, IPPROTO_TCP, TCP_SYNCNT, &synRetries, sizeof(synRetries));
setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &usertimeout, sizeof(usertimeout));
if( connect(fd, rai->ai_addr, rai->ai_addrlen) == -1 ) if( connect(fd, rai->ai_addr, rai->ai_addrlen) == -1 )
{ {
DEB((D_INFO, "tcpip_connect2: can't connect %s", hbuf)); DEB((D_INFO, "tcpip_connect2: can't connect %s", hbuf));
logerr("can't connect to %s", hbuf); logerr("can't connect to %s", hbuf);
close(fd); close(fd);
} else fd = -1;
} else {
DEB((D_INFO, "tcpip_connect2: connect"));
connected = TRUE;
break; break;
}
} }
DEB((D_INFO, "tcpip_connect2: socket not opened - returning"));
hbuf[0]='\0'; hbuf[0]='\0';
sbuf[0]='\0'; sbuf[0]='\0';
if (!connected) {
DEB((D_INFO, "tcpip_connect2: socket not opened - returning"));
}
} }
DEB((D_INFO, "tcpip_connect2: socket success: %d", fd)); DEB((D_INFO, "tcpip_connect2: socket: %d", fd));
if (fd < 0 ) if ((fd < 0) || !connected)
{ {
DEB((D_INFO, "tcpip_connect2: can't create socket")); DEB((D_INFO, "tcpip_connect2: can't create socket and connect"));
logerr("can't create socket"); logerr("can't create socket");
return(1); return(1);
} }

View File

@ -76,7 +76,7 @@ int nodelist_checkflag(const char *nodeflags, const char *flag)
} }
} }
return 1; return -1;
} }
/***************************************************************************** /*****************************************************************************
@ -387,7 +387,7 @@ int nodelist_parsehiddenina(s_node *node,s_override *ov) {
if( *(p+flaglen) == 0 || *(p+flaglen) == ',' ) if( *(p+flaglen) == 0 || *(p+flaglen) == ',' )
{ {
// empty flag // empty flag
strncpy(tmp, p,'\0'); memset(tmp, '\0', 1);
} }
else else
{ {
@ -397,9 +397,10 @@ int nodelist_parsehiddenina(s_node *node,s_override *ov) {
q = strchrnul(p, ','); // end of data: comma or EOS q = strchrnul(p, ','); // end of data: comma or EOS
strncpy(tmp, p, q-p); strncpy(tmp, p, q-p);
tmp[q-p]='\0'; tmp[q-p]='\0';
DEB((D_NODELIST, "nodelist: host INA is %s", node->host));
if (!strcmp(tmp, node->host)) { if (!strcmp(tmp, node->host)) {
DEB((D_NODELIST, "nodelist: found host INA %s", tmp)); DEB((D_NODELIST, "nodelist: found host INA %s", tmp));
} else { } else {
DEB((D_NODELIST, "nodelist: found hidden INA %s", tmp)); DEB((D_NODELIST, "nodelist: found hidden INA %s", tmp));

View File

@ -360,12 +360,12 @@ static int noxrd7(void)
if( (c = GETCHAR(Z_Rxwait)) < 0 ) if( (c = GETCHAR(Z_Rxwait)) < 0 )
return(c); return(c);
switch( c &= 0177 ) { switch( c &= 0x7F ) { // was octal 0177
case XON: case XON:
case XOFF: case XOFF:
continue; continue;
default: default:
if( Z_Ctlesc && !(c & 0140) ) if( Z_Ctlesc && !(c & 0x60) ) //was octal 0140 b01100000 hex 0x60
continue; continue;
case '\r': case '\r':
case '\n': case '\n':
@ -1056,8 +1056,8 @@ static int zrhhdr(char *hdr)
/* There is some characters available.. */ /* There is some characters available.. */
switch( (c = GETCHAR(1)) ) { switch( (c = GETCHAR(1)) ) {
case 0215: case 0x8D: //was octal 0215 dec 141 b 10001101 hex 0x8D ZCRC
case 015: case 0x0D: //was octal 015 dec 13 b 00001101 hex 0x0D ZCRC
/* Throw away possible cr/lf */ /* Throw away possible cr/lf */
if( (c = GETCHAR(1)) < 0 && c != ZTIMER ) if( (c = GETCHAR(1)) < 0 && c != ZTIMER )
return(c); return(c);

View File

@ -248,8 +248,8 @@ int rx_zmodem(s_protinfo *pi, bool caller)
break; break;
} /* end of switch(rxstate) */ } /* end of switch(rxstate) */
// && rxstate != ZRX_GOTFILE - always true, :131 changes it
if( rxstate != ZRX_INIT && rxstate != ZRX_GOTFILE if( rxstate != ZRX_INIT
&& rxstate != ZRX_SENDRPOS && rxstate != ZRX_WAITDATA && rxstate != ZRX_SENDRPOS && rxstate != ZRX_WAITDATA
&& rxstate != ZRX_SKIP && rxstate != ZRX_REFUSE ) && rxstate != ZRX_SKIP && rxstate != ZRX_REFUSE )
{ {

View File

@ -133,6 +133,7 @@ int tx_zmodem(s_protinfo *pi, bool caller)
int dtype, n; int dtype, n;
int ftype; int ftype;
char c, *p; char c, *p;
int ichar = 0;
long unsigned crc32; long unsigned crc32;
enum ztxstates txstate; enum ztxstates txstate;
time_t deadtimer; time_t deadtimer;
@ -389,8 +390,9 @@ int tx_zmodem(s_protinfo *pi, bool caller)
/* Ignore them all */ /* Ignore them all */
break; break;
} /* end of switch(txstate) */ } /* end of switch(txstate) */
if( txstate != ZTX_START && txstate != ZTX_RQINIT // txstate != ZTX_START always true
if( txstate != ZTX_RQINIT
&& txstate != ZTX_FINFO && txstate != ZTX_DATA && txstate != ZTX_FINFO && txstate != ZTX_DATA
&& txstate != ZTX_EOF && txstate != ZTX_FIN ) && txstate != ZTX_EOF && txstate != ZTX_FIN )
{ {
@ -648,8 +650,8 @@ int tx_zmodem(s_protinfo *pi, bool caller)
log(" Send file's CRC-32 "); log(" Send file's CRC-32 ");
crc32 = 0xFFFFFFFFL; crc32 = 0xFFFFFFFFL;
while( ((c = getc(pi->send->fp)) != EOF) && --Z_Rxpos ) while( ((ichar = getc(pi->send->fp)) != EOF) && --Z_Rxpos )
crc32 = updcrc32(c, crc32); crc32 = updcrc32(ichar, crc32);
crc32 = ~crc32; crc32 = ~crc32;

View File

@ -591,7 +591,7 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
log(s); log(s);
DEB((D_EVENT, s)); DEB((D_EVENT, s));
// find suitable way of connection and try to make session // find suitable way of connection and try to make session
s_override *tmpovr;
int rc = 0; int rc = 0;
int runrc = 0; int runrc = 0;
char abuf[BF_MAXADDRSTR+1]; char abuf[BF_MAXADDRSTR+1];
@ -599,7 +599,9 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
char *errmsg = NULL; char *errmsg = NULL;
int call_mustuse = 0; int call_mustuse = 0;
int call_mayuse = 0; int call_mayuse = 0;
char origphone[BNI_MAXPHONE+1];
char origflags[BNI_MAXFLAGS+1];
char orighost[BNI_MAXHOST+1];
init_state(&state); init_state(&state);
state.caller = TRUE; state.caller = TRUE;
@ -611,12 +613,38 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
{ {
errmsg = "incorrect hidden line number"; errmsg = "incorrect hidden line number";
gotoexit(BFERR_PHONE_UNKNOWN); gotoexit(BFERR_PHONE_UNKNOWN);
}
// We can do it even if no nodelist string for node
// we got overrides, so apply ALL configs, except tuned by options
// BEFORE we decide how to call
if (state.override.sFlags) {
(void)strnxcpy(state.node.flags, state.override.sFlags, strlen(state.override.sFlags)+1);
state.node.do_binkp = (nodelist_checkflag(state.node.flags, "IBN") == 0);
state.node.do_ifcico = (nodelist_checkflag(state.node.flags, "IFC") == 0);
state.node.do_telnet = (nodelist_checkflag(state.node.flags, "ITN") == 0);
memset(state.node.host,'\0',sizeof(state.node.host));
nodelist_flagvalue(state.node.flags, "INA",state.node.host);
DEB((D_EVENT, "sess_call: applied override flags=%s", state.node.flags));
} }
if (state.override.sPhone && !(opts->phone)) {
(void)strnxcpy(state.node.phone, state.override.sPhone, strlen(state.override.sPhone)+1);
DEB((D_EVENT, "sess_call: applied override phone=%s", state.node.phone));
}
if (state.override.sIpaddr && !(opts->iphost)) {
(void)strnxcpy(state.node.host, state.override.sIpaddr, strlen(state.override.sIpaddr)+1);
DEB((D_EVENT, "sess_call: applied override ipaddr=%s", state.node.host));
}
if (nodelist_parsehiddenina(&state.node, &state.override) > 0) {
DEB((D_EVENT, "sess_call: got hidden INAs"));
}
state.listed = state.node.listed; state.listed = state.node.listed;
//DEB((D_EVENT, "Calling init, listed=%d", state.listed)); //DEB((D_EVENT, "Calling init, listed=%d", state.listed));
state.node.addr.domain[0] = '\0'; /* Discard domain for node address */ state.node.addr.domain[0] = '\0'; /* Discard domain for node address */
// 1. If call method specified in cmdline, do use it // 1. If call method specified in cmdline, do use it
// 2. If not, use nodelist data and overrides and call all available methods // 2. If not, use nodelist data and overrides and call all available methods
// If override contains Phone or IP flags, ignore nodelist connect methods (but save INA if not overrided) // If override contains Phone or IP flags, ignore nodelist connect methods (but save INA if not overrided)
@ -640,7 +668,7 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
} }
else if( opts->runmode == MODE_CALL_IP ) else if( opts->runmode == MODE_CALL_IP )
{ {
DEB((D_EVENT, "Calling init, MODE_CALL_IP")); DEB((D_EVENT, "sess_call: MODE_CALL_IP - from cli"));
if( !(opts->ipproto) ) // determine from nodelist/override if( !(opts->ipproto) ) // determine from nodelist/override
{ {
DEB((D_EVENT, "ipproto not set")); DEB((D_EVENT, "ipproto not set"));
@ -676,9 +704,9 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
call_mayuse |= call_mustuse; // it simplifies logics: all required is allowed call_mayuse |= call_mustuse; // it simplifies logics: all required is allowed
//char s[300]; //char s[300];
//snprintf(s, 299, "initial: may use %d must use %d", call_mayuse, call_mustuse); snprintf(s, 299, "initial: may use %d must use %d", call_mayuse, call_mustuse);
//log(s); //log(s);
//DEB((D_EVENT, s)); DEB((D_EVENT, s));
if( (call_mayuse & CALL_MODEM) ) if( (call_mayuse & CALL_MODEM) )
@ -691,16 +719,17 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
{ {
(void)strnxcpy(state.node.phone, opts->phone, sizeof(state.node.phone)); (void)strnxcpy(state.node.phone, opts->phone, sizeof(state.node.phone));
//log("phone from options"); //log("phone from options");
} } // Moved to top
else if( state.override.sPhone ) //else if( state.override.sPhone )
{ //{
(void)strnxcpy(state.node.phone, state.override.sPhone, sizeof(state.node.phone)); // (void)strnxcpy(state.node.phone, state.override.sPhone, sizeof(state.node.phone));
//log("phone from override"); // //log("phone from override");
} //}
if( !modem_isgood_phone(state.node.phone) ) if( !modem_isgood_phone(state.node.phone) )
{ {
log("bad phone, excluding modem"); log("bad phone, excluding modem");
DEB((D_EVENT, "sess_call: bad phone, excluding modem" ));
call_mayuse &= ~CALL_MODEM; call_mayuse &= ~CALL_MODEM;
if( !(call_mayuse) ) if( !(call_mayuse) )
{ {
@ -749,14 +778,14 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
//log(s); //log(s);
//DEB((D_EVENT, s)); //DEB((D_EVENT, s));
/* /*
* Apply overrides to the node information * Apply overrides to the node information - 2025 moved to start
*/ */
if( state.override.sFlags ) //if( state.override.sFlags )
{ //{
strnxcat(state.node.flags, ",", sizeof(state.node.flags)); // strnxcat(state.node.flags, ",", sizeof(state.node.flags));
strnxcat(state.node.flags, state.override.sFlags, sizeof(state.node.flags)); // strnxcat(state.node.flags, state.override.sFlags, sizeof(state.node.flags));
} //}
// state.node nodelist // state.node nodelist
// state.override config // state.override config
@ -764,44 +793,50 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
// filter unavailable protos if not obligated to use it // filter unavailable protos if not obligated to use it
if( !(call_mustuse & CALL_TCPIP_BINKP) && (call_mayuse & CALL_TCPIP_BINKP) ) // Decide protos on calling by flags with override
if( (call_mustuse & CALL_TCPIP_BINKP) && (call_mayuse & CALL_TCPIP_BINKP) )
{ {
//if( nodelist_checkflag(state.node.flags, "BINKP") != 0 && nodelist_checkflag(state.node.flags, "IBN") != 0 ) //if( nodelist_checkflag(state.node.flags, "IBN") != 0 )
if( state.node.do_binkp == 0 ) if( state.node.do_binkp == 0 )
{ {
call_mayuse &= ~CALL_TCPIP_BINKP; call_mayuse &= ~CALL_TCPIP_BINKP;
} }
} }
if( !(call_mustuse & CALL_TCPIP_IFCICO) && (call_mayuse & CALL_TCPIP_IFCICO) ) if( (call_mustuse & CALL_TCPIP_IFCICO) && (call_mayuse & CALL_TCPIP_IFCICO) )
{ {
//if( nodelist_checkflag(state.node.flags, "IFC") != 0 && nodelist_checkflag(state.node.flags, "IFC") != 0 ) //if( nodelist_checkflag(state.node.flags, "IFC") != 0 )
if( state.node.do_ifcico == 0 ) if( state.node.do_ifcico == 0 )
{ {
call_mayuse &= ~CALL_TCPIP_IFCICO; call_mayuse &= ~CALL_TCPIP_IFCICO;
} }
} }
if( !(call_mustuse & CALL_TCPIP_TELNET) && (call_mayuse & CALL_TCPIP_TELNET) ) if( (call_mustuse & CALL_TCPIP_TELNET) && (call_mayuse & CALL_TCPIP_TELNET) )
{ {
//if( nodelist_checkflag(state.node.flags, "TELN") != 0 && nodelist_checkflag(state.node.flags, "TLN") != 0 ) //if( nodelist_checkflag(state.node.flags, "TLN") != 0 )
if( state.node.do_telnet == 0 ) if( state.node.do_telnet == 0 )
{ {
call_mayuse &= ~CALL_TCPIP_TELNET; call_mayuse &= ~CALL_TCPIP_TELNET;
} }
} }
snprintf(s, 299, "after 1 check: may use %d must use %d", call_mayuse, call_mustuse);
log(s);
DEB((D_EVENT, s));
if( opts->iphost && *opts->iphost ) if( opts->iphost && *opts->iphost )
{ {
memset(state.node.host,'\0',sizeof(state.node.host));
(void)strnxcpy(state.node.host, opts->iphost, sizeof(state.node.host)); (void)strnxcpy(state.node.host, opts->iphost, sizeof(state.node.host));
} }
else if( state.override.sIpaddr ) // Moved to start
{ //else if( state.override.sIpaddr )
(void)strnxcpy(state.node.host, //{
state.override.sIpaddr, sizeof(state.node.host)); // (void)strnxcpy(state.node.host,
} // state.override.sIpaddr, sizeof(state.node.host));
//}
//DEB((D_EVENT, "Calling init, IPHOST", state.node.host)); DEB((D_EVENT, "Calling init, IPHOST %s", state.node.host));
// We have at least one protocol and not valid address - try to // We have at least one protocol and not valid address - try to
// find INA with through Fidonet DNS // find INA with through Fidonet DNS
@ -871,31 +906,129 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
// try allowed methods and break if rc == 0 // try allowed methods and break if rc == 0
rc = -1; rc = -1;
// START CALLING
// ROTATE HIDDEN LINES IF ANY
//snprintf(s, 299, "before call: may use %d must use %d", call_mayuse, call_mustuse);
//log(s);
//DEB((D_EVENT, s));
// Hidden lines - if smth is not in place - use orig overriden hard
memcpy(&origphone, &state.node.phone,sizeof(origphone));
memcpy(&origflags, &state.node.flags,sizeof(origflags));
memcpy(&orighost, &state.node.host,sizeof(orighost));
if( call_mayuse & CALL_STDIO ) if( call_mayuse & CALL_STDIO )
{ {
DEB((D_EVENT,"sess_call: calling stdio")); DEB((D_EVENT,"sess_call: calling stdio, mayuse=%x", call_mayuse));
rc = call_system_quiet(opts->connect, opts->inetd); rc = call_system_quiet(opts->connect, opts->inetd);
} }
if( rc && (call_mayuse & CALL_TCPIP_BINKP) ) if( rc && (call_mayuse & CALL_TCPIP_BINKP) )
{ {
DEB((D_EVENT,"sess_call: calling binkp")); DEB((D_EVENT,"sess_call: calling binkp, mayuse=%x", call_mayuse));
rc = call_system_tcpip(CALL_TCPIP_BINKP); rc = call_system_tcpip(CALL_TCPIP_BINKP);
} }
if( rc && (call_mayuse & CALL_TCPIP_IFCICO) ) if( rc && (call_mayuse & CALL_TCPIP_IFCICO) )
{ {
DEB((D_EVENT,"sess_call: calling ifcico")); DEB((D_EVENT,"sess_call: calling ifcico, mayuse=%x", call_mayuse));
rc = call_system_tcpip(CALL_TCPIP_IFCICO); rc = call_system_tcpip(CALL_TCPIP_IFCICO);
} }
if( rc && (call_mayuse & CALL_TCPIP_TELNET) ) if( rc && (call_mayuse & CALL_TCPIP_TELNET) )
{ {
DEB((D_EVENT,"sess_call: calling telnet")); DEB((D_EVENT,"sess_call: calling telnet, mayuse=%x", call_mayuse));
rc = call_system_tcpip(CALL_TCPIP_TELNET); rc = call_system_tcpip(CALL_TCPIP_TELNET);
} }
tmpovr = &state.override;
while (tmpovr->hidden != NULL && rc) {
DEB((D_EVENT, "sess_call: starting hidden, current is %x", tmpovr->hidden));
tmpovr = tmpovr->hidden;
if (tmpovr->sFlags) {
if (nodelist_checkflag(tmpovr->sFlags, "INA") == 0) {
memset(state.node.host,'\0',sizeof(state.node.host));
nodelist_flagvalue(tmpovr->sFlags, "INA",state.node.host);
}
(void)strnxcpy(state.node.flags, tmpovr->sFlags, strlen(tmpovr->sFlags)+1);
call_mayuse |= call_mustuse;
state.node.do_binkp = nodelist_checkflag(state.node.flags, "IBN") == 0;
state.node.do_ifcico = nodelist_checkflag(state.node.flags, "IFC") == 0;
state.node.do_telnet = nodelist_checkflag(state.node.flags, "ITN") == 0;
DEB((D_EVENT, "sess_call: applied hidden flags=%s", state.node.flags));
} else {
memcpy(&state.node.flags, &origflags, sizeof(origflags));
call_mayuse |= call_mustuse;
state.node.do_binkp = nodelist_checkflag(state.node.flags, "IBN") == 0;
state.node.do_ifcico = nodelist_checkflag(state.node.flags, "IFC") == 0;
state.node.do_telnet = nodelist_checkflag(state.node.flags, "ITN") == 0;
DEB((D_EVENT, "sess_call: applied original flags=%s", state.node.flags));
}
if (tmpovr->sPhone && !(opts->phone)) {
(void)strnxcpy(state.node.phone, tmpovr->sPhone, strlen(tmpovr->sPhone)+1);
DEB((D_EVENT, "sess_call: ?skipping hidden phone=%s", state.node.phone));
if ( !(tmpovr->sFlags) && !(tmpovr->sIpaddr) ) continue; // skip only telephone
} else {
memcpy(&state.node.phone, &origphone, sizeof(origphone));
DEB((D_EVENT, "sess_call: applied original phone=%s", state.node.phone));
}
if (tmpovr->sIpaddr && !(opts->iphost)) {
(void)strnxcpy(state.node.host, tmpovr->sIpaddr, strlen(tmpovr->sIpaddr)+1);
DEB((D_EVENT, "sess_call: applied hidden ipaddr=%s", state.node.host));
}
if( (call_mustuse & CALL_TCPIP_BINKP) && (call_mayuse & CALL_TCPIP_BINKP) )
{
//if( nodelist_checkflag(state.node.flags, "IBN") != 0 )
if( state.node.do_binkp == 0 )
{
call_mayuse &= ~CALL_TCPIP_BINKP;
}
}
if( (call_mustuse & CALL_TCPIP_IFCICO) && (call_mayuse & CALL_TCPIP_IFCICO) )
{
//if( nodelist_checkflag(state.node.flags, "IFC") != 0 )
if( state.node.do_ifcico == 0 )
{
call_mayuse &= ~CALL_TCPIP_IFCICO;
}
}
if( (call_mustuse & CALL_TCPIP_TELNET) && (call_mayuse & CALL_TCPIP_TELNET) )
{
//if( nodelist_checkflag(state.node.flags, "TLN") != 0 )
if( state.node.do_telnet == 0 )
{
call_mayuse &= ~CALL_TCPIP_TELNET;
}
}
if( rc && (call_mayuse & CALL_TCPIP_BINKP) )
{
DEB((D_EVENT,"sess_call: calling binkp"));
rc = call_system_tcpip(CALL_TCPIP_BINKP);
}
if( rc && (call_mayuse & CALL_TCPIP_IFCICO) )
{
DEB((D_EVENT,"sess_call: calling ifcico"));
rc = call_system_tcpip(CALL_TCPIP_IFCICO);
}
if( rc && (call_mayuse & CALL_TCPIP_TELNET) )
{
DEB((D_EVENT,"sess_call: calling telnet"));
rc = call_system_tcpip(CALL_TCPIP_TELNET);
}
DEB((D_EVENT, "sess_call: finished hidden, next is %x", tmpovr->hidden));
}
// DIALING_
if( rc && (call_mayuse & CALL_MODEM) ) if( rc && (call_mayuse & CALL_MODEM) )
{ {
DEB((D_EVENT,"sess_call: calling MODEM")); DEB((D_EVENT,"sess_call: calling MODEM"));
@ -932,7 +1065,54 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
{ {
errmsg = "unable to get modem port"; errmsg = "unable to get modem port";
} }
tmpovr = &state.override;
while (tmpovr->hidden != NULL && rc) {
DEB((D_EVENT, "sess_call: starting hidden, current is %x", tmpovr->hidden));
tmpovr = tmpovr->hidden;
// As for now - no effect in phone calls
if (tmpovr->sFlags) {
(void)strnxcpy(state.node.flags, tmpovr->sFlags, strlen(tmpovr->sFlags)+1);
DEB((D_EVENT, "sess_call: applied hidden flags=%s", state.node.flags));
} else {
memcpy(&state.node.flags, &origflags, sizeof(origflags));
DEB((D_EVENT, "sess_call: applied original flags=%s", state.node.flags));
}
if (tmpovr->sPhone && !(opts->phone)) {
(void)strnxcpy(state.node.phone, tmpovr->sPhone, strlen(tmpovr->sPhone)+1);
DEB((D_EVENT, "sess_call: applied hidden phone=%s", state.node.phone));
} else {
DEB((D_EVENT, "sess_call: no hidden phone - skipping"));
continue;
}
if( state.modemport )
{
if( port_lock(p_lockdir, state.modemport) == 0 ) /* Successfuly locked port */
{
DEB((D_EVENT,"sess_call: hidden call_system_modem running"));
rc = call_system_modem();
port_unlock(p_lockdir, state.modemport);
}
else
{
errmsg = "cannot lock modem port";
}
}
else
{
errmsg = "unable to get modem port";
}
}
// END_DIALING
} }
// END CALLING
if( rc ) if( rc )
{ {

View File

@ -223,7 +223,8 @@ int session_init_outgoing()
} }
else if( c == ENQ ) else if( c == ENQ )
{ {
if( enq_need && ++enqcount >= enq_need && canyoohoo ) if ( ++enqcount >= enq_need && canyoohoo )
//if( enq_need && ++enqcount >= enq_need && canyoohoo )
{ {
DEB((D_HSHAKE, "tx_init: exit with YooHoo")); DEB((D_HSHAKE, "tx_init: exit with YooHoo"));
state.session = SESSION_YOOHOO; state.session = SESSION_YOOHOO;
@ -232,7 +233,8 @@ int session_init_outgoing()
} }
else if( c == TSYNC ) else if( c == TSYNC )
{ {
if( nak_need && ++nakcount > nak_need && canftsc ) if( ++nakcount > nak_need && canftsc )
//if( nak_need && ++nakcount > nak_need && canftsc )
{ {
DEB((D_HSHAKE, "tx_init: exit with FTS-1")); DEB((D_HSHAKE, "tx_init: exit with FTS-1"));
state.session = SESSION_FTSC; state.session = SESSION_FTSC;

View File

@ -60,7 +60,11 @@ char *xstrcpy(const char *src)
return NULL; return NULL;
tmp = xmalloc(strlen(src)+1); tmp = xmalloc(strlen(src)+1);
strcpy(tmp, src); if (!tmp)
return NULL;
else
strcpy(tmp, src);
return tmp; return tmp;
} }
@ -85,15 +89,16 @@ char *xstrcat(char *src, const char *add)
size = (src ? strlen(src) : 0) + strlen(add); size = (src ? strlen(src) : 0) + strlen(add);
tmp = (char*)xmalloc(size+1); tmp = (char*)xmalloc(size+1);
if (tmp) {
if( src ) if( src )
{ {
strcpy(tmp, src); strcpy(tmp, src);
free(src); free(src);
} else } else
*tmp = '\0'; *tmp = '\0';
strcat(tmp, add); strcat(tmp, add);
}
return tmp; return tmp;
} }
@ -676,7 +681,7 @@ char *string_translate(const char *str, const char *find, const char *repl)
size_t sz_find = strlen(find); size_t sz_find = strlen(find);
size_t sz_repl = strlen(repl); size_t sz_repl = strlen(repl);
size_t sz_dest = strlen(str); size_t sz_dest = strlen(str);
char *dest, *p; char *tmp, *dest, *p;
p = dest = xstrcpy(str); p = dest = xstrcpy(str);
@ -689,9 +694,13 @@ char *string_translate(const char *str, const char *find, const char *repl)
size_t offset = p - dest; size_t offset = p - dest;
size_t newsize = sz_dest + (sz_repl - sz_find); size_t newsize = sz_dest + (sz_repl - sz_find);
if( newsize > sz_dest ) if( newsize > sz_dest ) {
dest = xrealloc(dest, newsize+1); tmp = xrealloc(dest, newsize+1);
if (!tmp) {
free(dest);
return NULL;
} else dest = tmp;
}
if( sz_repl > sz_find ) if( sz_repl > sz_find )
memmove(dest + offset + (sz_repl - sz_find), dest + offset, sz_dest - offset + 1); memmove(dest + offset + (sz_repl - sz_find), dest + offset, sz_dest - offset + 1);
else if( sz_repl < sz_find ) else if( sz_repl < sz_find )
@ -842,18 +851,19 @@ char *string_concat(const char *str, ...)
va_end(args); va_end(args);
yield = xmalloc(yield_len + 1); yield = xmalloc(yield_len + 1);
strncpy(yield, str, yield_len); if (yield) {
yield[yield_len] = '\0'; strncpy(yield, str, yield_len);
yield_ptr = yield + strlen(yield); yield[yield_len] = '\0';
yield_ptr = yield + strlen(yield);
va_start(args, str); va_start(args, str);
while( (p = va_arg(args, char *)) ) while( (p = va_arg(args, char *)) )
{ {
strcpy(yield_ptr, p); strcpy(yield_ptr, p);
yield_ptr += strlen(p); yield_ptr += strlen(p);
}
va_end(args);
} }
va_end(args);
return yield; return yield;
} }

View File

@ -70,7 +70,7 @@ void print_nodeinfo(const s_node *node)
printf("Phone : %s\n", node->phone); printf("Phone : %s\n", node->phone);
printf("Sysop : %s\n", node->sysop); printf("Sysop : %s\n", node->sysop);
printf("Location : %s\n", node->location); printf("Location : %s\n", node->location);
printf("Speed : %lu\n", node->speed); printf("Speed : %ld\n", node->speed);
printf("Flags : %s\n", node->flags); printf("Flags : %s\n", node->flags);
if( node->worktime.num ) if( node->worktime.num )
@ -214,7 +214,7 @@ void print_calltable(s_faddr addr){
// Let's print this table // Let's print this table
// begin with HOST itself // begin with HOST itself
ln = 0; ln = 0;
if (nnode.host) { if (nnode.host[0]) {
tmphost = nnode.host; tmphost = nnode.host;
} }
if (!nodelist_checkflag(nnode.flags, "IBN")) { if (!nodelist_checkflag(nnode.flags, "IBN")) {
@ -253,7 +253,7 @@ void print_calltable(s_faddr addr){
} }
// Calltable for pstn // Calltable for pstn
if (nnode.phone && check_phone(nnode.phone) ) { if (nnode.phone[0] && check_phone(nnode.phone) ) {
tmpphone = nnode.phone; tmpphone = nnode.phone;
ln +=1; ln +=1;
printf ("%5d. PSTN %s\n", ln, tmpphone); printf ("%5d. PSTN %s\n", ln, tmpphone);

View File

@ -3,7 +3,7 @@ dnl
dnl $Id$ dnl $Id$
dnl dnl
#AC_INIT(bforce/bforce.c) #AC_INIT(bforce/bforce.c)
AC_INIT([bforce],[0.26.2],[zx@zxalexis.ru]) AC_INIT([bforce],[0.27],[zx@zxalexis.ru])
AC_CONFIG_HEADER(include/config.h) AC_CONFIG_HEADER(include/config.h)
AC_CANONICAL_SYSTEM AC_CANONICAL_SYSTEM
dnl # Minimum Autoconf version required. dnl # Minimum Autoconf version required.

View File

@ -185,6 +185,6 @@ int nodelist_lookup_string(char *buffer, size_t buflen, s_faddr addr);
int nodelist_lookup(s_node *node, s_faddr addr); int nodelist_lookup(s_node *node, s_faddr addr);
void nodelist_initnode(s_node *node, s_faddr addr); void nodelist_initnode(s_node *node, s_faddr addr);
int nodelist_parsehiddenina(s_node *node, s_override *ov); int nodelist_parsehiddenina(s_node *node, s_override *ov);
int nodelist_flagvalue(const char *nodeflags, const char *flag, char *res);
#endif /* _NODELIST_H_ */ #endif /* _NODELIST_H_ */