変更は許可されていません
\n')
end
if post then
tcp=not not mg.get_var(post,'tcp')
itemList=GetItemList(tcp)
if mg.get_var(post,'add') then
ip=(mg.get_var(post,'specip') or ''):match('^.+$') or mg.get_var(post,'ip')
port=GetVarInt(post,'port',0)
--IPアドレスっぽくないものを弾く
if ip and port and ip:find('^[0-9A-Za-z%%.:]+$') and ip:find('[^%%.:]') and ip:find('[.:]') then
if ip=='0.0.0.1' then
--SrvPipeのPortは常に0
port=0
elseif ip=='0.0.0.2' and port>=100 then
--PipeのPortは基本的に0
port=0
end
broadcast=not tcp and GetVarInt(post,'broadcast')==1
for i,v in ipairs(itemList) do
if v.ip==ip and v.port%65536==port%65536 and v.broadcast==broadcast then
--既にある
ip=nil
break
end
end
if ip then
itemList[#itemList+1]={ip=ip,port=port,broadcast=broadcast}
ct:Append('追加しました
\n')
end
end
elseif mg.get_var(post,'del') then
index=GetVarInt(post,'index',1)
if index and index<=#itemList then
table.remove(itemList,index)
ct:Append('削除しました
\n')
end
end
for i,v in ipairs(itemList) do
ipA,ipB,ipC,ipD=v.ip:match('^([0-2]?[0-9]?[0-9])%.([0-2]?[0-9]?[0-9])%.([0-2]?[0-9]?[0-9])%.([0-2]?[0-9]?[0-9])$')
if ipA then
--IPv4。非負の整数に変換
ip=(tonumber(ipA) or 0)*256*256*256+(tonumber(ipB) or 0)*256*256+(tonumber(ipC) or 0)*256+(tonumber(ipD) or 0)
ip=math.floor(ip<0x100000000 and (ip>=0x80000000 and ip-0x100000000 or ip>0 and ip) or 0)
else
ip='['..v.ip..']'
end
edcb.WritePrivateProfile(tcp and 'SET_TCP' or 'SET_UDP','IP'..(i-1),ip,appIni)
edcb.WritePrivateProfile(tcp and 'SET_TCP' or 'SET_UDP','Port'..(i-1),v.port,appIni)
if not tcp then
edcb.WritePrivateProfile('SET_UDP','BroadCast'..(i-1),v.broadcast,appIni)
end
end
edcb.WritePrivateProfile(tcp and 'SET_TCP' or 'SET_UDP','Count',#itemList,appIni)
for i=#itemList+1,999 do
--掃除
if edcb.GetPrivateProfile(tcp and 'SET_TCP' or 'SET_UDP','IP'..(i-1),'',appIni)=='' then break end
edcb.WritePrivateProfile(tcp and 'SET_TCP' or 'SET_UDP','IP'..(i-1),nil,appIni)
edcb.WritePrivateProfile(tcp and 'SET_TCP' or 'SET_UDP','Port'..(i-1),nil,appIni)
if not tcp then
edcb.WritePrivateProfile('SET_UDP','BroadCast'..(i-1),nil,appIni)
end
end
end
edcb.htmlEscape=15
ct:Append([=[
UDP送信先
]=])
for i,v in ipairs(GetItemList(false)) do
ct:Append([=[
]=])
end
ct:Append([=[
※複数の起動があった場合、自動的にPortが+1されます。
※ブロードキャストとして送信する場合は、ブロードキャストアドレスを指定してください。
※仕様によりドロップすることがあるので、とくに理由がなければTCP送信の利用をお勧めします。
TCP送信先
※ブロードキャストとして送信する場合は、ブロードキャストアドレスを指定してください。
※仕様によりドロップすることがあるので、とくに理由がなければTCP送信の利用をお勧めします。
]=])
for i,v in ipairs(GetItemList(true)) do
ct:Append([=[
]=])
end
ct:Append([=[
※複数の起動があった場合、自動的にPortが+1されます。