From ea81ac7f6422832e7e456b817a178328d72e2927 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 26 Aug 2010 17:18:47 +0200 Subject: [PATCH] psu_login: Reject clients version < 2.009.2. --- priv/psu_login/error_version.txt | Bin 0 -> 686 bytes src/psu/psu_game.erl | 5 ----- src/psu/psu_login.erl | 25 +++++++++++++++++++++++-- 3 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 priv/psu_login/error_version.txt diff --git a/priv/psu_login/error_version.txt b/priv/psu_login/error_version.txt new file mode 100644 index 0000000000000000000000000000000000000000..fcf63414261d69b226cf3d1dc80826952cc69ae3 GIT binary patch literal 686 zcmZ{iy-veG5QL}pQ}_iiN=Z5jItqk<-ozn^lAI&Q2J-U2H@93OA)zbo_Ge~i$Nv6$ z(Ncqs+Nf7jtvjND_n=Bw|DKBKlh$Bsz5ii2fu6{>aJW8Y_M{c>4evVFM|E_Jbac5l z<$FOcae6A1UeEaG3WXzcgXfqh$NUDC2kpqT%qVkxyWjU4tUFGx5AfDg5&5Y>{eV+L|oS{!Q8_#Q_U)v(n8}!n+u@Sc)q2*W?%AmPHFjs4|Ag?jsIdPNwGNd3$&ty9 H!qrAU4a|C> literal 0 HcmV?d00001 diff --git a/src/psu/psu_game.erl b/src/psu/psu_game.erl index 181f69c..613d864 100644 --- a/src/psu/psu_game.erl +++ b/src/psu/psu_game.erl @@ -117,11 +117,6 @@ process_handle(16#020d, << GID:32/little-unsigned-integer, Auth:32/bits, _/bits end end; -%% @doc Platform information handler. -process_handle(16#080e, << _:64, Version:32/little-unsigned-integer, _/bits >>) -> - file:write_file("versions.txt", io_lib:format("~b~n", [Version]), [append]), - ?MODULE:process(); - %% @doc Unknown command handler. Do nothing. process_handle(Command, _) -> log("(process) dismissed packet ~4.16.0b", [Command]), diff --git a/src/psu/psu_login.erl b/src/psu/psu_login.erl index 33b08c7..5ac5f5f 100644 --- a/src/psu/psu_login.erl +++ b/src/psu/psu_login.erl @@ -124,8 +124,29 @@ handle(Command, CSocket, SessionID, Orig) when Command =:= 16#0226; Command =:= Packet = << 16#0225:16, 0:304, NbPages:8, Page:8, 16#8200:16/unsigned-integer, MOTD/binary, 0:16 >>, psu_proto:packet_send(CSocket, Packet); -%% Silently ignore packets 0227 and 080e. -handle(Command, _, _, _) when Command =:= 16#0227; Command =:= 16#080e -> +%% @doc Platform information handler. Reject versions < 2.0009.2. +handle(16#080e, CSocket, SessionID, << _:352, _:64, Revision:8, Minor:4, _:12, Major:4, _:4, _/bits >>) -> + Version = Major * 1000000 + Minor * 1000 + Revision, + if Version < 2009002 -> + log(SessionID, "reject outdated version ~b.~b.~b", [Major, Minor, Revision]), + Website = << "http://psumods.co.uk/forums/comments.php?DiscussionID=40#Item_1" >>, + Size = byte_size(Website), + WebsiteLen = Size + 1, + PaddingSize = 8 * (512 - Size), + WebsitePacket = << 16#02310300:32, 16#ffff0000:32, 16#00000f00:32, SessionID:32/little, 0:64, 16#00000f00:32, SessionID:32/little, 0:64, + WebsiteLen:32/little, Website/binary, 0:PaddingSize >>, + psu_proto:packet_send(CSocket, WebsitePacket), + {ok, File} = file:read_file("priv/psu_login/error_version.txt"), + ErrorLen = byte_size(File) div 2 + 2, + ErrorPacket = << 16#02230300:32, 0:160, 16#00000f00:32, SessionID:32/little, 0:96, 16#f9dbce73:32, 3:32/little, 0:48, ErrorLen:16/little, File/binary, 0:16 >>, + psu_proto:packet_send(CSocket, ErrorPacket), + closed; + true -> + ignore + end; + +%% Silently ignore command 0227. +handle(16#0227, _, _, _) -> ignore; %% Unknown command handler. Print a log message about it.