я взял за основу расширение pingProxy.lua мне нужно чтоб внешние прокси автоматом переключались при доступности (например пингует прокси - если он доступен то работает через него, если нет то через второй прокси)
вот что я понаписал
--[[ <HCExtension>
@name WiiProxy WOW III
@author igorek
@version 0.2
@description Ïðîâåðèòü ïðîêñè
@event Init/init
@event Timer1m/timer
@rule ^http://ping\.proxy/
@event RequestHeaderReceived/Request
</HCExtension> ]]
function init()
hc_static['count']=1
end
function timer ()
if not hc.offline_on then
if hc_static['count']<=1 then
hc_static['count']=1 --ïèíãîâàòü êàæäûå x ìèíóò
hc.execute_cmd('LoadURL
http://ping.proxy/')
else hc_static['count']=hc_static['count']-1
end
else hc_static['count']=1
end
end
function GetAnswerCode(s)
_,_,x = string.find(s, 'HTTP/1%.%d +(%d+)')
if x==nil then return -1 else return tonumber(x) end
end
function Request()
local s = s
hc.use_proxy="127.0.0.1:8288" --Âíåøèíé ïðîêñè
hc.request_header="HEAD
http://www.google.de/ HTTP/1.0\13\10\13\10"
hc.monitor_string = hc.monitor_string..'R-Ping '
hc.call_me_for('BeforeAnswerHeaderSend', 'Answer')
end
function Answer()
hc.action='dont_save'
answ_code = GetAnswerCode(hc.answer_header)
if answ_code==200 then
s = 0
else s = 1
end
hc.monitor_string = hc.monitor_string..'A-Ping '
end
function Request()
if s==0 then
hc.use_proxy="127.0.0.1:9202" --SPRINT
hc.monitor_string = hc.monitor_string..'SPRINT '
end
if s==1 then
hc.use_proxy="127.0.0.1:8288" --GLOBAX
hc.monitor_string = hc.monitor_string..'GLOBAX '
end
end
lua только начил изучать , с переменными не как до меня недоходит - почему
они не срабатывают, уже незнаю где рыть. в луатест ошибок нет. как только вписываю последнию функцию в расширение
function Request()
if s==0 then
hc.use_proxy="127.0.0.1:9202" --SPRINT
hc.monitor_string = hc.monitor_string..'SPRINT '
end
if s==1 then
hc.use_proxy="127.0.0.1:8288" --GLOBAX
hc.monitor_string = hc.monitor_string..'GLOBAX '
end
end
все сразу втупляет.
Уважаемый mail62 помогите.