Network hub pinger redirect Manager convert to new api
 

News:

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

Network hub pinger redirect Manager convert to new api

Started by DarkElf, 13 November, 2007, 11:28:28

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

DarkElf

hi to all, can someone convert this script to the new API (ptokax 0.3.6.0i)??
--	   >>>>>>>>>>>>>>>> NOTE from [NL]Daddy-Bear?     For this one, I used a script see below   <<<<<<<<<<<<<<<
--	======================  Network hub pinger redirect Manager 2.1 ===============================
--	============= Credits 1ste By ¨?s??t°?s???Hawk????s°??t?s¨ 25-05-04 ===================
--		============= applied to the new PXWSA by bastya_elvtars ===================

-- 	==================== Get PXWSA lib at http://thewildplace.dk/lua/wsa ================
-- 	=============  Create a folder named libs inside your scripts folder and put pxwsa_l51.dll into there =============

--	==================== +rdon = enable / +rdoff = disable =========================================

--	NEW

--		******************************************************************************
--		================= Switching redirect address setter v1.0 lua 5.1  ====================
--		******************************************************************************

-- _________________________________________________________________________________________________________

--      The Switching redirect address setter for Ptokax by [NL]Daddy-Bear? (good-evening-hub.no-ip.org:411)  22-11-2006

-- _________________________________________________________________________________________________________


-- 	=====================  Editable settings  ================================

Bot = frmHub:GetHubBotName()				--// Bot name
oflinePingmin = 2							--// Ping tyd between the hubs in minutes which are ofline
OnlinePingmin = 15							--// Ping tyd between the hubs in minutes which are online
DefaultHub = "xxx.no-ip.xxx:2000"	--// Third and laaste hub if the others go ofline  !  Address:Port

-- =====================  HUBS ESTABLISH OF THE REDICT  ================================

-- >>>>>>>>>>>>>>>>>>>>>>>..... HUB 1 .....<<<<<<<<<<<<<<<<<<<<<

hub1 = "bla bla bla"		--// Address of the first hub where redicts go.
port1 = 489				--// Port of the first hub where redicts go.

-- >>>>>>>>>>>>>>>>>>>>>>>..... HUB 2 .....<<<<<<<<<<<<<<<<<<<<<

hub2 = "bla bla bla"		--// Address of the second hub where redicts go.
port2 = 666				--// Port of the second hub where redicts go.

-- >>>>>>>>>>>>>>>>>>>>>>>..... HUB 3 .....<<<<<<<<<<<<<<<<<<<<<

hub3 = "p?p?r?p?"		--// Address of the second hub where redicts go.
port3 = 1968				--// Port of the second hub where redicts go.

-- >>>>>>>>>>>>>>>>>>>>>>>..... HUB 4 .....<<<<<<<<<<<<<<<<<<<<<

hub4 = "gne gne gne"		--// Address of the second hub where redicts go.
port4 = 4328				--// Port of the second hub where redicts go.
--		 	=================  Change nothing below !!!!!! ===================
RedirectsEnabled = true						--// Do not change
ba = 0										--// Do not change
br = 0										--// Do not change
bx = 0										--// Do not change
mins = 10									--// Do not change
Hub_Adress = {
{hub1,port1},
{hub2,port2},
{hub3,port3},
{hub4,port4},

 }
status=0
libinit = package.loadlib(frmHub:GetPtokaXLocation().."/scripts/libs/pxwsa_l51.dll", "_libinit")
assert(libinit,"Cannot load the WSA library!")
libinit()
_M=0
_A=false
Onlinehubs = {}
HubCounter = 1 	
cnt = 1
function Main() 
  WSA.Init()
  SetTimer(1000 * 60 * mins)  
  if RedirectsEnabled == true then
    StartTimer()
  end
end
function ChatArrival(user, data)
  if user.bOperator then
    local data=string.sub(data,1,string.len(data)-1)
    local _,_,cmd = string.find(data,"%b<>%s+(%S+)")
    if cmd=="+rdon" then
      SendPmToOps(frmHub:GetHubBotName()," Redirects enabled ")
      StartTimer()
      RedirectsEnabled = true
			return 1
    elseif cmd=="+rdoff" then
      SendPmToOps(frmHub:GetHubBotName()," redirects disabled ")
      StopTimer()
      RedirectsEnabled = false
			return 1
    end
    end
end

function OnTimer()
	if _A then ConnectToHost(Hub_Adress[cnt][1],Hub_Adress[cnt][2]) end
	_M=_M+1
	if _M== 1 * mins then
		_M=0
		if cnt > table.maxn(Hub_Adress) then
			cnt=1
		end
		displayhub()
	end
end
function ConnectToHost(addy,port)
	local status
	local err1,err2=WSA.Connect(sock,addy,port)
	if err1 then
		if err1~=10035 and err1~=10056 then
			_A=false
			status=1; WSA.Close(sock)
		elseif err1==10056 then
			_A=false
			status=2; WSA.Close(sock)
		elseif err1==10035 then
			_A=true
			return
		end
	else
		_A=false
		status=2; WSA.Close(sock)
	end
	Populate(status)
end
function Populate(status)
   if status == 1 then
    if Active == false then
    elseif Active == true then
      Onlinehubs[Position] = nil
    end
  elseif status==2 then
    if Active == false then
      Onlinehubs[ActiveHubCount] = CurrentChecking
    elseif Active == true then
    end
 end
  cnt = cnt + 1
  if (table.maxn(Onlinehubs) == 0)  then
	if bx == 0  then  mins = 1
end
	bx = bx + 1
	br = 1
	ba = 0
  else
	br = 0
	bx = 0
	mins = 1
    frmHub:SetRedirectAddress(Onlinehubs[HubCounter])
  end
  if HubCounter >= table.maxn(Onlinehubs) then
    HubCounter = 1
  else
    HubCounter = HubCounter + 1
  end
	if ba < 2 and br == 0 then ba = ba + 1
	end
	if ba == 1 then
	names = "\tThe Switching redirect address setter is now started and he is pinging the hubs during 1 minute."
	SendPmToOps(Bot,names)
	end	
	if ba > 1 and br == 0 then mins = OnlinePingmin
	names = "\tThese "..mins.." minutes the redicts are going to\t"..frmHub:GetRedirectAddress().."\tbecause this hub is *online*."
	SendPmToOps(Bot,names)
	end
	if br == 1 and bx > 1 then bx = 6
	mins = oflinePingmin
	names = "\tThe redicts are going to\t"..frmHub:GetRedirectAddress().."\tbecause the other hubs are *ofline*.\r\n\t\t\t\tTher will be a check each "..mins.." minutes to see if the are comming *online*."
	SendPmToOps(Bot,names)
end
CurrentOnlineHubs()
 end
function displayhub()
  _,_,sock=WSA.NewSocket()
  CurrentChecking = Hub_Adress[cnt][1]..":"..Hub_Adress[cnt][2]
  Active = false
  ActiveHubCount = table.maxn(Onlinehubs) + 1
  for index, value in ipairs(Onlinehubs) do
    if value == CurrentChecking then
      Active = true
      Position = index
      break
    end
  end
  ConnectToHost(Hub_Adress[cnt][1],Hub_Adress[cnt][2])
end
function CurrentOnlineHubs()
--  Here you can put a command   eg. hub ..... is online
end	
function OnExit() WSA.Dispose(); end

Many thanks (and sorry 4 my english :-P )
Please sorry my bad english, i'm learning it :-D

\\100Gb ][ MeGaShArE @ I?? - ?u?i?N Owner [/I]
100gb.ifs-fusion.net:666 Only EliTe ShArE min 100gb
-={ I?? - ?u?i?N }=- N??Owner

bastya_elvtars

There is no PXWSA library for that one, so the answer is: No. Maybe with luasockets it could be done.
Everything could have been anything else and it would have just as much meaning.

DarkElf

and it is possible to make a simple timed redirect changer with the new api?
Please sorry my bad english, i'm learning it :-D

\\100Gb ][ MeGaShArE @ I?? - ?u?i?N Owner [/I]
100gb.ifs-fusion.net:666 Only EliTe ShArE min 100gb
-={ I?? - ?u?i?N }=- N??Owner

Toast

Here are some ideas me and Flip Flop talked about for an array based on a similar Script

Array Ideas

Min ADC Version Checker
if a adc client is detected in array then it can be redirected to an adc hub (this eliminates redirection for non adc clients to adc hubs)

Non wanted prefixes and nick names checker
If a non wanted nickname is detected then it redirects it to 127.0.0.1

Known Fake Share Detector
if a know fake share or client is detected then its redirected to 127.0.0.1

Hubsettings Detector
it checks how much the hub handles and if hub is at full it skips the hub and fills the next one

DarkElf

i need only a redirect script that ping a hub from the list, if is online it change the redirect to the addy, or a simple timed redir address changer, it's for a network
Please sorry my bad english, i'm learning it :-D

\\100Gb ][ MeGaShArE @ I?? - ?u?i?N Owner [/I]
100gb.ifs-fusion.net:666 Only EliTe ShArE min 100gb
-={ I?? - ?u?i?N }=- N??Owner

SMF spam blocked by CleanTalk