intelligent redirect script
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

intelligent redirect script

Started by [KATZ]ice, 23 March, 2005, 23:01:42

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

[KATZ]ice

ok, i know, a couple of topics earlier someone asked for the same, but i mean something different. well i already got one for pinging hubs, but it works just fine, now we want to change the network, every hub has a signifacant min hub share (ie 5 gb min 10 gb min 20 gb min 50 gb min, ETC.) so now we want a redirect array that lets a user of 30 gb not join join the 50 GB + hub but automatically one of the lower ones.

So a script that can redirect someone by it's share

(i can't care if it's lua4 or 5)

Cheers ICE

I already got this:

(lua5)
function NewUserConnected(User)
  --//sharesize return is in bytes
  user_sharesize = User.iShareSize

  --//0B-30GiB exclusively
  if (user_sharesize > 0) and (user_sharesize < 30720000000) then 
      User:Redirect(Address, Reason)
 --//greater than OR equal to 30GiB
  elseif (user_sharesize >= 30720000000) then
      User:Redirect(Address, Reason)
  end
end

--[[
 = ShareToRed by Herodes =
 - Redirects users acorrding to share...
 - you may set custom redirect messages.
--]]

tUnit = "gb" -- lower-case the unit in which the sharesize limits are counted... ( maybe i'll work on more that later .. )

tHubs = { -- ["number_of_units_required"] = { "hub.address.com", "excuse for redirecting.." },           --- be sure that you keep this format.. mind the last comma..
	["5"] = { "hub1.no.way", "Our 5GB MinShare Hub", },
	["10"] = { "hub2.no.way", "Our 10GB MinShare Hub", },
	["20"] = { "hub3.no.way", "Our 20GB MinShare Hub", },
	["50"] = { "hub4.no.way", "Our 50GB MinShare Hub", },
	["100"] = { "hub5.no.way", "Our 100GB MinShare Hub", },
}

function LookForRed( share )
	local tUnits, hub = { ["kb"] = 1, ["mb"] = 2, ["gb"] = 3, ["pb"] = 4 }, nil
	for s,h in tHubs do
		if (share < tonumber(s)*1024*tUnits[tUnit]) then hub = h
		else break;
		end
	end
	return hub
end

function NewUserConnected(user)
	local where = LookForRed(user.iShareSize)
	if where then 
		user:Redirect(where[1], where[2])
	end
end

function whichServer(SomeNum)
  servernum = math.random(SomeNum)
  if (servernum < 1) then
     return hub1.ip.org
  elseif (servernum >= 1) and (servernum < 2) then
     return hub2.ip.org
  elseif (servernum >= 2) and (servernum < 3)  then
     return hub3.ip.org
  end
  
  --//in case of some error just send to hub1
  return hub1.no-ip.org
end

function NewUserConnected(User)
  --//sharesize return is in bytes
  user_sharesize = User.iShareSize

  --//0B-20GiB exclusively
  if (user_sharesize > 0) and (user_sharesize < 20480000000) then 
      User:Redirect(whichServer(2), Reason)
 --//greater than OR equal to 20GiB
  elseif (user_sharesize >= 20480000000) then
      User:Redirect(whichServer(3), Reason)
  end
end
-- multiple return values example ...
function give_me_five()
return 1,2,3,4,5
end

one, two, three, four, five = give_me_five()
-- those variables will now have the following values
--[[
one == 1 
two == 2
...
five == 5
--]]

-- multiple return types example ...
function give_smth()
 return { "good", [1] = 23, ["now"] = "good time to learn smth new" }, true, "great", 4
end

table, bool, string, number = give_smth()
-- those variables will now have the following values..
--[[
table == { "good", [1] = 23, ["now"] = "good time to learn smth new" }
bool == true
string == "great"
number == 4
--]]


Thx to Jemte & Herodes

But how to continue from this?

i get this:

[01:19] *** Connecting to XXXXXXX.redirectme.net:XXX...
[01:19] *** Connected
[01:19] You are being redirected to
[01:19] *** Disconnected

Cheers ICE

[KATZ]ice

really no-one, becuz i been trying like hell, and i can't get it working :(

Cheers ICE

SMF spam blocked by CleanTalk