From 279bede6c4bbcf0690a9e403b8a8b4729040abf9 Mon Sep 17 00:00:00 2001 From: RushFan Date: Sat, 18 Mar 2017 08:38:52 -0700 Subject: [PATCH] handle main_type_sub_list --- network2/network2.cpp | 22 +++++++++++++++++++--- networkb/packets.cpp | 10 ++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/network2/network2.cpp b/network2/network2.cpp index 4ba8215b6..0912790d9 100644 --- a/network2/network2.cpp +++ b/network2/network2.cpp @@ -126,8 +126,7 @@ static bool handle_ssm(Context& context, Packet& p) { return true; } -static bool handle_net_info_file(const net_networks_rec& net, Packet& p) { - auto info = GetNetInfoFileInfo(p); +static bool write_net_received_file(const net_networks_rec& net, Packet& p, NetInfoFileInfo info) { if (!info.valid) { LOG(ERROR) << "NetInfoFileInfo is not valid"; return write_wwivnet_packet(DEAD_NET, net, p); @@ -154,6 +153,21 @@ static bool handle_net_info_file(const net_networks_rec& net, Packet& p) { return true; } +static bool handle_net_info_file(const net_networks_rec& net, Packet& p) { + auto info = GetNetInfoFileInfo(p); + return write_net_received_file(net, p, info); +} + +static bool handle_sub_list(const net_networks_rec& net, Packet& p) { + // Handle legacy type 9 main_type_sub_list (SUBS.LST) + NetInfoFileInfo info{}; + info.filename = SUBS_LST; + info.data = p.text; + info.valid = true; + info.overwrite = true; + return write_net_received_file(net, p, info); +} + static bool handle_packet( Context& context, Packet& p) { LOG(INFO) << "Processing message with type: " << main_type_name(p.nh.main_type) @@ -222,6 +236,9 @@ static bool handle_packet( return handle_sub_list_info_response(context, p); } + case main_type_sub_list: + return handle_sub_list(context.net, p); + // Legacy numeric only post types. case main_type_post: case main_type_pre_post: @@ -234,7 +251,6 @@ static bool handle_packet( case main_type_net_edit: // *.### support - case main_type_sub_list: case main_type_group_bbslist: case main_type_group_connect: case main_type_group_info: diff --git a/networkb/packets.cpp b/networkb/packets.cpp index 82ee370e7..fbfa47105 100644 --- a/networkb/packets.cpp +++ b/networkb/packets.cpp @@ -23,6 +23,7 @@ #include "core/file.h" #include "core/log.h" #include "core/strings.h" +#include "networkb/net_util.h" #include "sdk/datetime.h" #include "sdk/filenames.h" @@ -170,7 +171,16 @@ static string NetInfoFileName(uint16_t type) { NetInfoFileInfo GetNetInfoFileInfo(Packet& p) { NetInfoFileInfo info{}; + if (p.nh.main_type != main_type_net_info) { + // Everything else here should be a main_type_net_info + LOG(ERROR) << "GetNetInfoFileInfo can't handle type: " + << main_type_name(p.nh.main_type) << " (" << p.nh.main_type << ")"; + info.valid = false; + return info; + } + if (p.nh.minor_type != net_info_file) { + // Handle the file types we know about using minor_type info.filename = NetInfoFileName(p.nh.minor_type); info.data = p.text; info.valid = true;