Any of these neighbours can then retrieve QWK files using:
- echo get | nncp-exec bbsnode qwikboard
+ echo get USER | nncp-exec bbsnode qwikboard
This will result in the QWK file being assembled sent to the
requesting node using nncp-file, meaning the requesting node will also
-need an incoming directory specified.
+need an incoming directory specified. The "USER" argument specifies
+the handle which will be associated with the requesting node
+when replies are sent. (It is an error to request a packet for
+a username which has already been associated with another node.)
Similarly, REP files can be submitted using:
This will result in the messages contained in replyfile.rep being
incorporated into the message database.
-The nncp_handler command assumes that the name of the sending NNCP
-node is the name of the user. Thus, when registering users to the
-BBS, ensure that you configure their node names appropriately in
-nncp.hjson.
-
License
-------
fs.touch(qb.path .. "/notices/hello")
fs.touch(qb.path .. "/notices/news")
fs.touch(qb.path .. "/notices/goodbye")
+
+ fs.touch(qb.path .. "/nncp_users.lua")
end
-- qwkout: generate QWK file
qwk.import_rep(arg[1], arg[2])
end
+local function restore_nncp_usernames()
+ nncp_usernames = {}
+ dofile(qb.path .. "/nncp_users.lua")
+end
+
+local function store_nncp_usernames()
+ local fh = assert(io.open(qb.path .. "/nncp_users.lua", "w"))
+ for k,v in pairs(nncp_usernames) do
+ fh:write("nncp_usernames[" .. string.format("%q",k) .. "] = " ..
+ string.format("%q", v) .. "\n")
+ end
+end
+
function cmd.nncp_handler()
load_config()
- local user_name = os.getenv("NNCP_SENDER")
+ local node_id = os.getenv("NNCP_SENDER")
- if not user_name then
+ if not node_id then
print [[The nncp_handler command is intended to be called by nncp on
receipt of an exec packet. For instance, the offline BBS could
be made accessible by user (node) NODENAME by adding the following
return false
end
+ restore_nncp_usernames()
+
local input_string = io.stdin:read("*all")
- if string.match(string.lower(input_string), "get.*") then
+ if string.match(input_string, "^get%s%w+%s$") then
+
+ local user_name = string.match(input_string, "^get%s(%w+)%s$")
+
+ nncp_usernames[node_id] = user_name
+ store_nncp_usernames()
+
print("Building QWK packet for user '" .. user_name .. "'")
-- Construct QWK packet
qwk.build_qwk(user_name, out_file_name)
print(qb.nncp_file .. " " .. out_file_name .. " " ..
- user_name .. ":" .. qb.bbsid .. ".QWK")
+ node_id .. ":" .. qb.bbsid .. ".QWK")
os.execute(qb.nncp_file .. " " .. out_file_name .. " " ..
user_name .. ":" .. qb.bbsid .. ".QWK")
fs.rmfile(out_file_name)
else
+ local user_name = nncp_usernames[node_id]
+
+ if not user_name then
+ print("No user name for node " .. node_id .. " found. Aborting.")
+ return false
+ end
+
print("Accepting REP packet from user '" .. user_name .. "'")
-- Accept REP packet