From c06322da38b4cb76b2036af1a5448083adb8ff20 Mon Sep 17 00:00:00 2001 From: Darkelarious Date: Tue, 22 Aug 2017 11:00:13 +0200 Subject: new server checking mechanism, complete recode of major functions --- lib/MasterServer/Core/Util.pm | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'lib/MasterServer/Core/Util.pm') diff --git a/lib/MasterServer/Core/Util.pm b/lib/MasterServer/Core/Util.pm index 682335c..5af8264 100755 --- a/lib/MasterServer/Core/Util.pm +++ b/lib/MasterServer/Core/Util.pm @@ -2,12 +2,28 @@ package MasterServer::Core::Util; use strict; use warnings; -use IP::Country::Fast; use Socket; +use Encode; +use IP::Country::Fast; use POSIX qw/strftime/; use Exporter 'import'; +our @EXPORT = qw| data2hashref + ip2country + host2ip + valid_address + db_all + sqlprint |; -our @EXPORT = qw| ip2country host2ip valid_address db_all sqlprint |; +################################################################################ +## process udp/tcp data strings from \key\value to hash +################################################################################ +sub data2hashref { + my ($self, $str) = @_; + my @a = split /\\/, encode('UTF-8', $str||""); + shift @a; + my %h = (@a, (scalar @a % 2 == 1) ? "dummy" : () ); + return \%h; +} ################################################################################ ## return the abbreviated country name based on IP -- cgit v1.2.3