| 1 | /* |
| 2 | * Copyright (C) 2000 Onlyer ([email protected]) |
| 3 | * Copyright (C) 2001 Ross Combs ([email protected]) |
| 4 | * Copyright (C) 2002 Gianluigi Tiesi ([email protected]) |
| 5 | * Copyright (C) 2004 CreepLord ([email protected]) |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License |
| 9 | * as published by the Free Software Foundation; either version 2 |
| 10 | * of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 20 | */ |
| 21 | #include "common/setup_before.h"cxx . . $ `<file>/src/common/setup_before.h`/ |
| 22 | #include "versioncheck.h"cxx . . $ `<file>/src/bnetd/versioncheck.h`/ |
| 23 | |
| 24 | #include <cctype> |
| 25 | #include <cerrno> |
| 26 | #include <chrono> |
| 27 | #include <climits> |
| 28 | #include <cstdint> |
| 29 | #include <cstdio> |
| 30 | #include <cstdlib> |
| 31 | #include <cstring> |
| 32 | #include <ctime> |
| 33 | #include <fstream> |
| 34 | #include <iomanip> |
| 35 | #include <regex> |
| 36 | #include <sstream> |
| 37 | #include <string> |
| 38 | #include <tuple> |
| 39 | #include <unordered_map> |
| 40 | |
| 41 | #include "common/eventlog.h"cxx . . $ `<file>/src/common/eventlog.h`/ |
| 42 | |
| 43 | #include "common/field_sizes.h"cxx . . $ `<file>/src/common/field_sizes.h`/ |
| 44 | #include "common/format.h"cxx . . $ `<file>/src/common/format.h`/ |
| 45 | #include "common/hash_tuple.hpp"cxx . . $ `<file>/src/common/hash_tuple.hpp`/ |
| 46 | #include "common/proginfo.h"cxx . . $ `<file>/src/common/proginfo.h`/ |
| 47 | #include "compat/strcasecmp.h"cxx . . $ `<file>/src/compat/strcasecmp.h`/ |
| 48 | #include "common/token.h"cxx . . $ `<file>/src/common/token.h`/ |
| 49 | #include "common/util.h"cxx . . $ `<file>/src/common/util.h`/ |
| 50 | |
| 51 | |
| 52 | #include "json/json.hpp"cxx . . $ `<file>/src/json/json.hpp`/ |
| 53 | |
| 54 | #include "prefs.h"cxx . . $ `<file>/src/bnetd/prefs.h`/ |
| 55 | #include "common/setup_after.h"cxx . . $ `<file>/src/common/setup_after.h`/ |
| 56 | |
| 57 | |
| 58 | using jsoncxx . . $ json# = nlohmanncxx . . $ nlohmann/::jsoncxx . . $ nlohmann/json#; |
| 59 | |
| 60 | |
| 61 | namespace pvpgncxx . . $ pvpgn/ |
| 62 | { |
| 63 | |
| 64 | namespace bnetdcxx . . $ pvpgn/bnetd/ |
| 65 | { |
| 66 | stdcxx . . $ std/::unordered_mapcxx . . $ std/unordered_map#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<stdcxx . . $ std/::uint32_tcxx . . $ std/uint32_t#, stdcxx . . $ std/::uint32_tcxx . . $ std/uint32_t#, t_tagcxx . . $ pvpgn/t_tag#, t_tagcxx . . $ pvpgn/t_tag#>, VersionCheckcxx . . $ pvpgn/bnetd/VersionCheck#, hash_tuplecxx . . $ pvpgn/hash_tuple/::hashcxx . . $ pvpgn/hash_tuple/hash#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<stdcxx . . $ std/::uint32_tcxx . . $ std/uint32_t#, stdcxx . . $ std/::uint32_tcxx . . $ std/uint32_t#, t_tagcxx . . $ pvpgn/t_tag#, t_tagcxx . . $ pvpgn/t_tag#>>> vc_entriescxx . . $ pvpgn/bnetd/vc_entries.; |
| 67 | stdcxx . . $ std/::unordered_mapcxx . . $ std/unordered_map#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<t_tagcxx . . $ pvpgn/t_tag#, t_tagcxx . . $ pvpgn/t_tag#, stdcxx . . $ std/::uint32_tcxx . . $ std/uint32_t#>, stdcxx . . $ std/::tuplecxx . . $ std/tuple#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::stringcxx . . $ std/string#>, hash_tuplecxx . . $ pvpgn/hash_tuple/::hashcxx . . $ pvpgn/hash_tuple/hash#<stdcxx . . $ std/::tuplecxx . . $ std/tuple#<t_tagcxx . . $ pvpgn/t_tag#, t_tagcxx . . $ pvpgn/t_tag#, stdcxx . . $ std/::uint32_tcxx . . $ std/uint32_t#>>> cr_entriescxx . . $ pvpgn/bnetd/cr_entries.; |
| 68 | |
| 69 | bool versioncheck_conf_is_loadedcxx . . $ pvpgn/bnetd/versioncheck_conf_is_loaded. = false; |
| 70 | |
| 71 | // bool validate_file_metadata_format(const std::string& metadata); |
| 72 | |
| 73 | |
| 74 | bool load_versioncheck_confcxx . . $ pvpgn/bnetd/load_versioncheck_conf(7c222eea44a24d43).(const stdcxx . . $ std/::stringcxx . . $ std/string#& filename) |
| 75 | { |
| 76 | if (versioncheck_conf_is_loadedcxx . . $ pvpgn/bnetd/versioncheck_conf_is_loaded.) |
| 77 | { |
| 78 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "Could not load {}, a versioncheck configuration file is already loaded", filename); |
| 79 | return false; |
| 80 | } |
| 81 | |
| 82 | auto t0 = stdcxx . . $ std/::chronocxx . . $ std/chrono/::steady_clockcxx . . $ std/chrono/_V2/steady_clock#::nowcxx . . $ std/chrono/_V2/steady_clock#now(edffc6b45db65c20).(); |
| 83 | |
| 84 | stdcxx . . $ std/::ifstreamcxx . . $ std/ifstream# file_streamcxx . . $ std/basic_ifstream#basic_ifstream(be6c264dafcf0985).(filename, stdcxx . . $ std/::ioscxx . . $ std/ios#::incxx . . $ std/ios_base#in.); |
| 85 | if (!file_stream.is_opencxx . . $ std/basic_ifstream#is_open(c9857a73d68e59ba).()) |
| 86 | { |
| 87 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "Could not open file \"{}\" for reading", filename); |
| 88 | return false; |
| 89 | } |
| 90 | |
| 91 | jsoncxx . . $ json# jconfcxx . . $ nlohmann/basic_json#basic_json(6d988fd07f070dfc).; |
| 92 | try |
| 93 | { |
| 94 | file_stream >>cxx . . $ nlohmann/`operator>>`(3a8382316c854421). jconf; |
| 95 | } |
| 96 | catch (const stdcxx . . $ std/::exception& e) |
| 97 | { |
| 98 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "Could not parse {}: {}", filename, e.what()); |
| 99 | return false; |
| 100 | } |
| 101 | |
| 102 | vc_entriescxx . . $ pvpgn/bnetd/vc_entries..reservecxx . . $ std/unordered_map#reserve(9d5427c995a631d6).(185); |
| 103 | |
| 104 | for (auto jclient : jconf.itemscxx . . $ nlohmann/basic_json#items(179e49f6bcb2f34f).()) |
| 105 | { |
| 106 | t_tagcxx . . $ pvpgn/t_tag# client = tag_str_to_uintcxx . . $ pvpgn/tag_str_to_uint(c61c63047ce273de).(jclient.keycxx . . $ nlohmann/detail/iteration_proxy#iteration_proxy_internal#key(219584694fe2b248).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 107 | if (!tag_check_clientcxx . . $ pvpgn/tag_check_client(4c679297bf94b9eb).(client)) |
| 108 | { |
| 109 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "Invalid client: {}", jclient.keycxx . . $ nlohmann/detail/iteration_proxy#iteration_proxy_internal#key(219584694fe2b248).()); |
| 110 | continue; |
| 111 | } |
| 112 | |
| 113 | for (auto jarchitecture : jclient.valuecxx . . $ nlohmann/detail/iteration_proxy#iteration_proxy_internal#value(a05c2dc6cd5a22e0).().itemscxx . . $ nlohmann/basic_json#items(179e49f6bcb2f34f).()) |
| 114 | { |
| 115 | t_tagcxx . . $ pvpgn/t_tag# architecture = tag_str_to_uintcxx . . $ pvpgn/tag_str_to_uint(c61c63047ce273de).(jarchitecture.keycxx . . $ nlohmann/detail/iteration_proxy#iteration_proxy_internal#key(219584694fe2b248).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 116 | if (!tag_check_archcxx . . $ pvpgn/tag_check_arch(4c679297bf94b9eb).(architecture)) |
| 117 | { |
| 118 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "Invalid architecture: {}", jarchitecture.keycxx . . $ nlohmann/detail/iteration_proxy#iteration_proxy_internal#key(219584694fe2b248).()); |
| 119 | continue; |
| 120 | } |
| 121 | |
| 122 | for (auto jversion_id : jarchitecture.valuecxx . . $ nlohmann/detail/iteration_proxy#iteration_proxy_internal#value(a05c2dc6cd5a22e0).().itemscxx . . $ nlohmann/basic_json#items(179e49f6bcb2f34f).()) |
| 123 | { |
| 124 | stdcxx . . $ std/::uint32_tcxx . . $ std/uint32_t# version_id; |
| 125 | try |
| 126 | { |
| 127 | version_id = stdcxx . . $ std/::stoulcxx . . $ std/__cxx11/stoul(83a5b6ad71410cff).(jversion_id.keycxx . . $ nlohmann/detail/iteration_proxy#iteration_proxy_internal#key(219584694fe2b248).(), nullptr, 0); |
| 128 | } |
| 129 | catch (const stdcxx . . $ std/::exception& e) |
| 130 | { |
| 131 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "Invalid version id \"{}\": {}", jversion_id.keycxx . . $ nlohmann/detail/iteration_proxy#iteration_proxy_internal#key(219584694fe2b248).(), e.what()); |
| 132 | continue; |
| 133 | } |
| 134 | |
| 135 | // FIXME: do error checking for these |
| 136 | stdcxx . . $ std/::stringcxx . . $ std/string# checkrevision_filename = jversion_id.valuecxx . . $ nlohmann/detail/iteration_proxy#iteration_proxy_internal#value(a05c2dc6cd5a22e0).()[cxx . . $ nlohmann/basic_json#`operator[]`(b7cf55a98983e7f7)."checkRevisionFile"].getcxx . . $ nlohmann/basic_json#get(f3c7994d1bba77c).<stdcxx . . $ std/::stringcxx . . $ std/string#>(); |
| 137 | stdcxx . . $ std/::stringcxx . . $ std/string# checkrevision_equation = jversion_id.valuecxx . . $ nlohmann/detail/iteration_proxy#iteration_proxy_internal#value(a05c2dc6cd5a22e0).()[cxx . . $ nlohmann/basic_json#`operator[]`(b7cf55a98983e7f7)."equation"].getcxx . . $ nlohmann/basic_json#get(f3c7994d1bba77c).<stdcxx . . $ std/::stringcxx . . $ std/string#>(); |
| 138 | |
| 139 | cr_entriescxx . . $ pvpgn/bnetd/cr_entries..emplacecxx . . $ std/unordered_map#emplace(8e800962ae7274b6).( |
| 140 | stdcxx . . $ std/::piecewise_constructcxx . . $ std/piecewise_construct., |
| 141 | stdcxx . . $ std/::forward_as_tuplecxx . . $ std/forward_as_tuple(cd19fb0d9524ec73).(architecture, client, version_id), |
| 142 | stdcxx . . $ std/::forward_as_tuplecxx . . $ std/forward_as_tuple(cd19fb0d9524ec73).(checkrevision_filename, checkrevision_equation) |
| 143 | ); |
| 144 | |
| 145 | for (auto jentry : jversion_id.valuecxx . . $ nlohmann/detail/iteration_proxy#iteration_proxy_internal#value(a05c2dc6cd5a22e0).()[cxx . . $ nlohmann/basic_json#`operator[]`(b7cf55a98983e7f7)."entries"]) |
| 146 | { |
| 147 | try |
| 148 | { |
| 149 | VersionCheckcxx . . $ pvpgn/bnetd/VersionCheck# entrycxx . . $ pvpgn/bnetd/VersionCheck#VersionCheck(17fcd316e6b38176).(jentry[cxx . . $ nlohmann/basic_json#`operator[]`(b7cf55a98983e7f7)."title"].getcxx . . $ nlohmann/basic_json#get(f3c7994d1bba77c).<stdcxx . . $ std/::stringcxx . . $ std/string#>(), |
| 150 | version_id, |
| 151 | jentry[cxx . . $ nlohmann/basic_json#`operator[]`(b7cf55a98983e7f7)."version"].getcxx . . $ nlohmann/basic_json#get(f3c7994d1bba77c).<stdcxx . . $ std/::stringcxx . . $ std/string#>(), |
| 152 | jentry[cxx . . $ nlohmann/basic_json#`operator[]`(b7cf55a98983e7f7)."hash"].getcxx . . $ nlohmann/basic_json#get(f3c7994d1bba77c).<stdcxx . . $ std/::stringcxx . . $ std/string#>(), |
| 153 | architecture, |
| 154 | client, |
| 155 | jentry[cxx . . $ nlohmann/basic_json#`operator[]`(b7cf55a98983e7f7)."versionTag"].getcxx . . $ nlohmann/basic_json#get(f3c7994d1bba77c).<stdcxx . . $ std/::stringcxx . . $ std/string#>() |
| 156 | ); |
| 157 | |
| 158 | vc_entriescxx . . $ pvpgn/bnetd/vc_entries..insertcxx . . $ std/unordered_map#insert(e946fb78224671dd).({cxx . . $ std/pair#pair(14d64bafa7379ebc). stdcxx . . $ std/::make_tuplecxx . . $ std/make_tuple(3964edbfd7e8599f).(entry.m_version_idcxx . . $ pvpgn/bnetd/VersionCheck#m_version_id., entry.m_game_versioncxx . . $ pvpgn/bnetd/VersionCheck#m_game_version., entry.m_architecturecxx . . $ pvpgn/bnetd/VersionCheck#m_architecture., entry.m_clientcxx . . $ pvpgn/bnetd/VersionCheck#m_client.), entry }); |
| 159 | } |
| 160 | catch (const stdcxx . . $ std/::exception& e) |
| 161 | { |
| 162 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "Failed to load versioncheck entry: {}", e.what()); |
| 163 | continue; |
| 164 | } |
| 165 | } |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | auto t1 = stdcxx . . $ std/::chronocxx . . $ std/chrono/::steady_clockcxx . . $ std/chrono/_V2/steady_clock#::nowcxx . . $ std/chrono/_V2/steady_clock#now(edffc6b45db65c20).(); |
| 171 | |
| 172 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info., __FUNCTION__, "Successfully loaded {} versioncheck entries in {} microseconds", vc_entriescxx . . $ pvpgn/bnetd/vc_entries..sizecxx . . $ std/unordered_map#size(fe713de6d184c8a).(), stdcxx . . $ std/::chronocxx . . $ std/chrono/::duration_castcxx . . $ std/chrono/duration_cast(b7f67bf9c2f19806).<stdcxx . . $ std/::chronocxx . . $ std/chrono/::microsecondscxx . . $ std/chrono/microseconds#>(t1 -cxx . . $ std/chrono/operator-(37d29b8d7121dc12). t0).countcxx . . $ std/chrono/duration#count(8f5363d873dd4781).()); |
| 173 | |
| 174 | versioncheck_conf_is_loadedcxx . . $ pvpgn/bnetd/versioncheck_conf_is_loaded. = true; |
| 175 | |
| 176 | return true; |
| 177 | } |
| 178 | |
| 179 | void unload_versioncheck_confcxx . . $ pvpgn/bnetd/unload_versioncheck_conf(49f6e7a06ebc5aa8).() |
| 180 | { |
| 181 | if (versioncheck_conf_is_loadedcxx . . $ pvpgn/bnetd/versioncheck_conf_is_loaded.) |
| 182 | { |
| 183 | vc_entriescxx . . $ pvpgn/bnetd/vc_entries..clearcxx . . $ std/unordered_map#clear(ced63f7c635d850d).(); |
| 184 | |
| 185 | cr_entriescxx . . $ pvpgn/bnetd/cr_entries..clearcxx . . $ std/unordered_map#clear(ced63f7c635d850d).(); |
| 186 | |
| 187 | versioncheck_conf_is_loadedcxx . . $ pvpgn/bnetd/versioncheck_conf_is_loaded. = false; |
| 188 | |
| 189 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_infocxx . . $ pvpgn/eventlog_level_info., __FUNCTION__, "Successfully unloaded all version check entries"); |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | stdcxx . . $ std/::tuplecxx . . $ std/tuple#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::stringcxx . . $ std/string#> select_checkrevisioncxx . . $ pvpgn/bnetd/select_checkrevision(e17816cf095531bf).(t_tagcxx . . $ pvpgn/t_tag# architecture, t_tagcxx . . $ pvpgn/t_tag# client, stdcxx . . $ std/::uint32_tcxx . . $ std/uint32_t# version_id) |
| 194 | { |
| 195 | static const stdcxx . . $ std/::tuplecxx . . $ std/tuple#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::stringcxx . . $ std/string#> default_checkrevisioncxx . . $ std/tuple#tuple(533e79eb6234819d). { "ver-IX86-1.mpq", "A=42 B=42 C=42 4 A=A^S B=B^B C=C^C A=A^S" }; |
| 196 | |
| 197 | auto key = cr_entriescxx . . $ pvpgn/bnetd/cr_entries..findcxx . . $ std/unordered_map#find(f711f2f81556fe93).(stdcxx . . $ std/::make_tuplecxx . . $ std/make_tuple(3964edbfd7e8599f).(architecture, client, version_id)); |
| 198 | if (key !=cxx . . $ std/__detail/`operator!=`(6ab342297d2d0253). cr_entriescxx . . $ pvpgn/bnetd/cr_entries..endcxx . . $ std/unordered_map#end(58ae48d364eea91c).()) |
| 199 | { |
| 200 | return keycxx . . $ std/tuple#tuple(f6149edcf2e66b11).->cxx . . $ std/__detail/_Node_iterator#`operator->`(35610babf8706b50).secondcxx . . $ std/pair#second.; |
| 201 | } |
| 202 | |
| 203 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_debugcxx . . $ pvpgn/eventlog_level_debug., __FUNCTION__, "Could not find corresponding CheckRevision entry, returning default CheckRevision"); |
| 204 | |
| 205 | return default_checkrevisioncxx . . $ std/tuple#tuple(f6149edcf2e66b11).; |
| 206 | } |
| 207 | |
| 208 | // could use C++17 std::optional here |
| 209 | const VersionCheckcxx . . $ pvpgn/bnetd/VersionCheck#* select_versioncheckcxx . . $ pvpgn/bnetd/select_versioncheck(eb22150cf07bbdd6).(t_tagcxx . . $ pvpgn/t_tag# architecture, t_tagcxx . . $ pvpgn/t_tag# client, stdcxx . . $ std/::uint32_tcxx . . $ std/uint32_t# version_id, |
| 210 | stdcxx . . $ std/::uint32_tcxx . . $ std/uint32_t# checkrevision_version, stdcxx . . $ std/::uint32_tcxx . . $ std/uint32_t# checkrevision_checksum) |
| 211 | { |
| 212 | auto it = vc_entriescxx . . $ pvpgn/bnetd/vc_entries..findcxx . . $ std/unordered_map#find(f711f2f81556fe93).(stdcxx . . $ std/::make_tuplecxx . . $ std/make_tuple(3964edbfd7e8599f).(version_id, checkrevision_version, architecture, client)); |
| 213 | if (it ==cxx . . $ std/__detail/`operator==`(6ab342297d2d0253). vc_entriescxx . . $ pvpgn/bnetd/vc_entries..endcxx . . $ std/unordered_map#end(58ae48d364eea91c).()) |
| 214 | { |
| 215 | return nullptr; |
| 216 | } |
| 217 | |
| 218 | if (it->cxx . . $ std/__detail/_Node_iterator#`operator->`(35610babf8706b50).secondcxx . . $ std/pair#second..m_checksumcxx . . $ pvpgn/bnetd/VersionCheck#m_checksum. != checkrevision_checksum |
| 219 | && !prefs_get_allow_bad_versioncxx . . $ pvpgn/bnetd/prefs_get_allow_bad_version(db52760e79bf9054).()) |
| 220 | { |
| 221 | return nullptr; |
| 222 | } |
| 223 | |
| 224 | return &(it->cxx . . $ std/__detail/_Node_iterator#`operator->`(35610babf8706b50).secondcxx . . $ std/pair#second.); |
| 225 | } |
| 226 | |
| 227 | VersionCheckcxx . . $ pvpgn/bnetd/VersionCheck#::VersionCheckcxx . . $ pvpgn/bnetd/VersionCheck#VersionCheck(17fcd316e6b38176).(const stdcxx . . $ std/::stringcxx . . $ std/string#& title, stdcxx . . $ std/::uint32_tcxx . . $ std/uint32_t# version_id, const stdcxx . . $ std/::stringcxx . . $ std/string#& game_version, |
| 228 | const stdcxx . . $ std/::stringcxx . . $ std/string#& checksum, t_tagcxx . . $ pvpgn/t_tag# architecture, t_tagcxx . . $ pvpgn/t_tag# client, const stdcxx . . $ std/::stringcxx . . $ std/string#& version_tag) |
| 229 | : m_version_idcxx . . $ pvpgn/bnetd/VersionCheck#m_version_id.(version_id), m_architecturecxx . . $ pvpgn/bnetd/VersionCheck#m_architecture.(architecture), m_clientcxx . . $ pvpgn/bnetd/VersionCheck#m_client.(client) |
| 230 | { |
| 231 | if (verstr_to_vernumcxx . . $ pvpgn/verstr_to_vernum(adf14cd0d317759d).(game_version.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(), reinterpret_cast<unsigned long *>(&this->m_game_versioncxx . . $ pvpgn/bnetd/VersionCheck#m_game_version.)) < 0) |
| 232 | { |
| 233 | throw stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error#("Invalid version \"" +cxx . . $ std/operator+(42c652dfebe55ad7). game_version +cxx . . $ std/operator+(900ec9581c410ad9). "\" in entry \"" +cxx . . $ std/operator+(db5dc2ea912c6495). title +cxx . . $ std/operator+(900ec9581c410ad9). "\""); |
| 234 | } |
| 235 | |
| 236 | this->m_checksumcxx . . $ pvpgn/bnetd/VersionCheck#m_checksum. = stdcxx . . $ std/::stoulcxx . . $ std/__cxx11/stoul(83a5b6ad71410cff).(checksum, nullptr, 0); |
| 237 | |
| 238 | // FIXME: check for uniqueness |
| 239 | this->m_version_tagcxx . . $ pvpgn/bnetd/VersionCheck#m_version_tag. =cxx . . $ std/__cxx11/basic_string#`operator=`(c0b47be1fddc0e75). version_tag; |
| 240 | } |
| 241 | |
| 242 | stdcxx . . $ std/::stringcxx . . $ std/string# VersionCheckcxx . . $ pvpgn/bnetd/VersionCheck#::get_version_tagcxx . . $ pvpgn/bnetd/VersionCheck#get_version_tag(219584694fe2b248).() const |
| 243 | { |
| 244 | return thiscxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).->m_version_tagcxx . . $ pvpgn/bnetd/VersionCheck#m_version_tag.; |
| 245 | } |
| 246 | |
| 247 | /* |
| 248 | // This function only validates the format of the metadata string |
| 249 | // There is no need to validate the information in the string because validating the checksum and file version is sufficient |
| 250 | bool validate_file_metadata_format(const std::string& metadata) |
| 251 | { |
| 252 | if (metadata.empty()) |
| 253 | { |
| 254 | return false; |
| 255 | } |
| 256 | |
| 257 | try |
| 258 | { |
| 259 | std::smatch tokens; |
| 260 | if (std::regex_match(metadata, tokens, std::regex{ R"(([[:print:]]+\.exe) (\d\d/\d\d/\d\d \d\d:\d\d:\d\d) (\d+))" }) == false) |
| 261 | { |
| 262 | eventlog(eventlog_level_error, __FUNCTION__, "got invalid file metadata \"{}\"", metadata); |
| 263 | return false; |
| 264 | } |
| 265 | } |
| 266 | catch (const std::regex_error& e) |
| 267 | { |
| 268 | eventlog(eventlog_level_error, __FUNCTION__, "{} (code {})", e.what(), e.code()); |
| 269 | return false; |
| 270 | } |
| 271 | |
| 272 | return true; |
| 273 | } |
| 274 | */ |
| 275 | |
| 276 | } |
| 277 | |
| 278 | } |