Nп/п : 50 из 66
От : Javier Sturman 4:900/733 22 апр 26 17:03:38
К : All 22 апр 26 23:19:01
Тема : awk script for nodelists
----------------------------------------------------------------------------------
@MSGID: 4:900/733 69e92bae
@CHRS: LATIN-1 2
@TZUTC: -0300
Hello everybody!
Based on ndl2binkd I (99% Gemini) created an awk script to generate
the same output. It takes a nodelist as argument and it produces binkd
expected node values. For sure it can be pefected.
it assumes there are domains in binkd.conf named, fidonet, nixnet,
fsxnet. Tested on FreeBSD.
---ndl.awk---
#!/usr/bin/awk -f
BEGIN {
# 1. Argument Validation
if (ARGC < 2) {
print "Error: No input file provided." > "/dev/stderr"
print "Usage: ./ndl.awk " > "/dev/stderr"
print "Example: ./ndl.awk nodelist.360" > "/dev/stderr"
exit 1
}
FS = ","
current_zone = 1
current_net = 0
# Set DEBUG=1 via command line to see the parsing process:
# awk -v DEBUG=1 -f ndl.awk
if (DEBUG == "") DEBUG = 0
}
# 2. Dynamic Domain Detection (based on filename)
FNR == 1 {
fname = toupper(FILENAME);
if (fname ~ /NODELIST\\./) dom = "fidonet";
else if (fname ~ /NIXLIST\\./) dom = "nixnet";
else if (fname ~ /FSXNET\\./) dom = "fsxnet";
else dom = "fidonet";
if (DEBUG) print "--- Debug: Processing file " FILENAME " as
domain @" dom " ---" > "/dev/stderr"
}
# Skip comments and empty lines
/^;/ || !NF { next }
{
gsub(/
/, "", $0);
# Normalize keyword to lowercase for robust matching
keyword = tolower($1);
number = $2;
sysname = $3;
sysop = $5;
# 3. Filter DOWN and HOLD states
if (keyword == "down" || keyword == "hold") {
if (DEBUG) printf "--- Debug: Skipping node %d:%d/%d (Status: %s) ---
", current_zone, current_net, number, keyword > "/dev/stderr"
next;
}
# 4. Hierarchy Logic (Pascal Style)
if (keyword == "zone") {
current_zone = number; current_net = number; node_num = 0;
}
else if (keyword == "host" || keyword == "region") {
current_net = number; node_num = 0;
}
else {
node_num = number;
}
host_ip = "";
port = "";
# Priority tracking: 0=none, 1=ITN (Telnet), 2=IBN/INA (BinkP/Mail)
p_priority = 0;
# 5. Technical Flag Scanning (Case-Insensitive)
for (i = 7; i <= NF; i++) {
field_data = tolower($i);
if (field_data ~ /^(ina|ibn|ifc|itn):/) {
# Use original field $i for splitting to preserve Host casing
n_sub = split($i, parts, ":");
tag = tolower(parts[1]);
# Capture Hostname (INA/IBN have preference)
if (n_sub >= 2 && parts[2] ~ /[A-Za-z\\.]/ && host_ip == "") {
host_ip = parts[2];
}
# Port Priority Logic
# According to FTSC, IBN is the primary BinkP mail port.
# ITN (Telnet) should not overwrite it.
current_tag_priority = (tag == "itn") ? 1 : 2;
# Check for port in sub-part 2 (e.g., IBN:24555 or ITN:60177)
if (n_sub >= 2 && parts[2] ~ /^[0-9]+$/) {
if (current_tag_priority >= p_priority) {
port = parts[2];
p_priority = current_tag_priority;
if (DEBUG) printf " [Debug] Port %s set by %s (Priority %d)
", port, tag, p_priority > "/dev/stderr"
}
}
# Check for port in sub-part 3 (e.g., IBN:host:24555)
if (n_sub >= 3 && parts[3] ~ /^[0-9]+$/) {
if (current_tag_priority >= p_priority) {
port = parts[3];
p_priority = current_tag_priority;
if (DEBUG) printf " [Debug] Port %s set by %s (Priority %d)
", port, tag, p_priority > "/dev/stderr"
}
}
}
}
# 6. Final Output Generation
if (host_ip != "") {
gsub(/_/, " ", sysop);
gsub(/_/, " ", sysname);
full_dest = (port != "") ? host_ip ":" port : host_ip;
gsub(/[[:space:]]+$/, "", full_dest);
printf "# %s | %s
", sysop, sysname;
printf "node %d:%d/%d@%s -nd %s
", current_zone, current_net, node_num, dom, full_dest;
}
}
Javier
--- GoldED+/BSD 1.1.5-b20170303-b20170303 + HPT 1.9.0 + Binkd 1.1a-115
* Origin: FIDONODO DE JAS | ┬п\\_(O,O)_/┬п (4:900/733)
SEEN-BY: 4/0 19/10 50/109 88/0 90/0 93/1 103/705
104/117 124/5016 153/757
SEEN-BY: 154/10 30 201/0 203/0 218/840 221/0 1 6
242 360 229/426 230/0
SEEN-BY: 240/1120 5832 263/1 280/464 1043 5003
5006 5555 292/854 8125 301/1
SEEN-BY: 310/31 320/219 335/364 341/66 234 396/45
423/81 120 452/166 460/58
SEEN-BY: 463/68 633/280 712/848 770/1 900/0 102
106 733 902/0 19 26 904/0 13
SEEN-BY: 905/0 5000/111 5015/46 5020/329 400 715
828 830 846 848 1042 4441
SEEN-BY: 5020/12000 5022/128 5030/49 1081 5053/51
5060/900 5061/133 5083/444
@PATH: 900/733 902/26 280/464 221/1 6 5020/1042
4441