PtokaX forum

Stuff => Offtopic => Topic started by: [NL]Pur on 04 May, 2004, 16:18:44

Title: GetNetInfo
Post by: [NL]Pur on 04 May, 2004, 16:18:44
I was expermenting with $GetNetInfo|

but when i send this to a NMDC 2 client it's gets disconnected.

anyone noticed this ?

oh, and the client sends before it's gets disconnected a NetInfo.


Is this a client bug, or ptokax that doens't like weird protocol?


Or did i forget something?
Title:
Post by: NotRabidWombat on 04 May, 2004, 16:49:30
PtokaX will disconnect users that send unauthorized commands such as BCDC++'s $UserIP. You must return 1 if you want PtokaX to keep the client connected.

Here is an example of NetInfo.
function DataArrival(curUser, sData)
if(strsub(sData, 1, 7) == "$MyINFO") then
if(curUser.iVersion == nil) then
curUser:SendPM("test", "Your client is stupid");
curUser:Disconnect();
return;
end

if(strfind(curUser.iVersion, "^1.0091$") and curUser.bOperator == nil) then
-- the . is a magic char on purpose
curUser:SendData("$GetNetInfo|");
end
end

if(strsub(sData, 1, 8) == "$NetInfo") then
local info = strsub(sData, 9, -1);
local s, e, slots, hubs, mode, cap = strfind(sData, "^%$NetInfo (%d+)%$(%d+)%$(%w)%$*(%d*)%|$");

if(s == nil)
then curUser:Disconnect();-- the search failed, incorrect NetInfo
elseif(cap == "") then
curUser:SendData("Hub-Security", "Please download the latest Neo Modus Client");
curUser:Disconnect();
else
slots = tonumber(slots) or 0;
hubs = tonumber(hubs) or -1; -- second value is for invalid number
cap = tonumber(cap) or -1; -- second value is for invalid number

-- do what you want with the rest of the stuff above
-- slots: duh
-- hubs: all open hubs (even if OP and even if the user isn't connected :-\ )
-- mode: A or P
-- cap: kB/sec upload cap

end

return 1;
end

return 0;
end

-NotRabidWombat
Title:
Post by: [NL]Pur on 04 May, 2004, 17:28:47
QuotePtokaX will disconnect users that send unauthorized commands such as BCDC++'s $UserIP. You must return 1 if you want PtokaX to keep the client connected.


ah yes, now it works

i did forget the return 1