Modul pro Conky zobrazující běžné síťové zařízení, jeho provoz a nastavení.

Skript modulu stačí vložit na konec již uveřejněného základního nastavení LUA skriptu a do tabulky ‚modul‘ zadat název modulu. Název modulu naleznete za nápovědou v proměnné:
local name = "network"
Skript modulu:
function modul_network()
------------------------------------------------------------
-- VLKODLAK
-- 2015 ver 0.1
------------------------------------------------------------
-- informace o síťovém zařízení a jeho provozu
--
--##########################################################
--
-- pro svou činnost potřebuje: funkce
--[[
kurzor()
pozadi(poz,vyska)
--]]
--
-- pro svou činnost potřebuje: globální tabulky (před hlavní funkcí - conky_main())
--[[
update = {
["network"] = nil,
}
interval = {
["network"] = 4,
}
klik_menu = {
["network"] = 0,
}
--]]
--
-- pro svou činnost potřebuje: globální proměnné (před hlavní funkcí - conky_main())
--[[
pozadi_menu --nastavuje pozadí pro menu
pozadi_panel --nastavuje pozadí pro panel
pozadi_barva --nastavuje barvu pozadí
rozmer_panelu_x --rozměr panelu v pixelech, musí se shodovat s nastavením
--hodnoty 'minimum_size' v conky.rc
--]]
--
-- pro svou činnost potřebuje: nainstalované aplikace
--[[
ip --informace o síťovém zařízení
iwconfig --informace o WiFi
--]]
------------------------------------------------------------
--proměnná pro identifikaci modulu
local name = "network"
----------------------------------------
--podmínky pro interval dat modulu
----------------------------------------
if tonumber(update[tostring(name)]) == nil then--první průchod skriptem
--nastavení intervalu
update[tostring(name)] = updates + tonumber(interval[tostring(name)])
----------------------------------------
--tabulka pro nastavení modulu
net_tab = {
["tl"] = {},--podtabulka pro tlačítka
["reload"] = 1,--stav načtení dat
["soused"] = 0,
["pozice_y"] = nil,--pozice 'y' pro modul
}
--smyčka pro nastavení pozice modulu
for a = 1,#modul.name do
local text = tostring(modul.name[a])
if string.match(text, "(%S*)") == tostring(name) then
net_tab.pozice_y = a
break
end--if string.match(text, "(%S)") == tostring(name) then
end--for a = 1,#modul.name do
----------------------------------------
--definování tabulky pro data
net = {} --hlavní tabulka o zařízení
----------------------------------------
--seznam zařízení
seznam_network = {"eth","wlan","mon"}
local hw = 1
local data = io.open("/proc/net/dev", "r")
while true do
local line = data:read("*l")
if line == nil then break end
z,k,vyber = string.find(line,"([%w]*%d+)%p%s+%d") --eth0, wlan0
if vyber ~= nil then
for a = 1,#seznam_network do
if string.match(vyber,"(%w*)%d+") == tostring(seznam_network[tonumber(a)]) then
net[tonumber(hw)] = {}
net[tonumber(hw)].dev = vyber
hw = hw + 1
end--if string.match(vyber,"(%w*)%d+") == tostring(seznam_network[tonumber(a)]) then
end--for a = 1,#seznam_network do
end--if vyber ~= nil then
end--while true do
data:close()
----------------------------------------
--podtabulka pro tlačítka zařízení
for n = 1, #net do
net_tab.tl[tonumber(n)] = 0
end--for n = 1, #net do
----------------------------------------
--seznam pro odstranění z názvu zařízení
nahradit_vyrobce = {
["Semiconductor"] = "",
["Communications"] = "",
["Corporation"] = "",
["Co."] = "",
["Ltd."] = "",
["Inc."] = "",
}
----------------------------------------
--model a výrobce zařízení
for n = 1,#net do
local dev = net[tonumber(n)].dev
local data = io.open("/sys/class/net/"..dev.."/device/modalias", "r")
local line = data:read("*l")
z,k,bus = string.find(line,"([%w]*)%p")
data:close()
if bus == "pci" then
z,k,vendor = string.find(line,"pci%pv%w%w%w%w(%w%w%w%w)d")
z,k,device = string.find(line,"pci%pv%w*d%w%w%w%w(%w%w%w%w)sv")
elseif bus == "usb" then
z,k,vendor = string.find(line,"usb%pv(%w%w%w%w)p")
z,k,device = string.find(line,"usb%pv%w*p(%w%w%w%w)d")
end
local data = io.popen("ls"..bus.." -d "..vendor..":"..device)
local line = data:read("*l")
if bus == "pci" then
z,k,model = string.find(line, "%p%s([%S%s]*)")
elseif bus == "usb" then
z,k,model = string.find(line, device.."%s([%S%s]*)")
end
data:close()
--nahrazení nepotřebných údajů z názvu zařízení
model = string.gsub (model, ",", " ")
model = string.gsub (model, "PCI Express", "PCI-E")
model = string.gsub (model, "Controller", " ")
model = string.gsub (model, "%S+", nahradit_vyrobce)
model = string.gsub (model, "%s%s+", " ")
net[tonumber(n)].model = model
end--for n = 1,#net do
--další průchod skriptem
elseif tonumber(update[tostring(name)]) <= updates or net_tab.reload == 1 then
--nastavení intervalu
update[tostring(name)] = updates + tonumber(interval[tostring(name)])
----------------------------------------
--kontrola seznamu zařízení a uložení přijato/odesláno
local new_net = 0
local data = io.open("/proc/net/dev", "r")
while true do
local line = data:read("*l")
if line == nil then break end
z,k,vyber = string.find(line,"([%w]*%d+)%p%s*%d") --eth0, wlan0
if vyber ~= nil then
for a = 1,#seznam_network do
if string.match(vyber,"(%w*)%d+") == tostring(seznam_network[tonumber(a)]) then
new_net = tonumber(new_net) + 1
end--if string.match(vyber,"(%w*)%d+") == tostring(seznam_network[tonumber(a)]) then
end--for a = 1,#seznam_network do
end--if vyber ~= nil then
end--while true do
data:close()
if tonumber(new_net) ~= tonumber(#net) then
update[tostring(name)] = nil
else
net_tab.reload = 0
----------------------------------------
--brána a hostname
net_info = {}
local data = io.popen("ip route")
while true do
local line = data:read("*l")
if line == nil then break end
z,k,vyber = string.find(line,"default%svia%s(%S+)%s") --ip adresa
if vyber ~= nil then net_info[1] = vyber end
z,k,vyber = string.find(line,"default%svia%s%S+%sdev%s(%S+)") --zařízení
if vyber ~= nil then
net_info[2] = vyber
break
end--if vyber ~= nil then
end--while true do
data:close()
local data = io.open("/etc/hostname","r")
net_info[3] = data:read("*l") --hostname
data:close()
----------------------------------------
--zařízení - stav, mac, ip4, ip6 (společné pro eth/wlan)
for n = 1, #net do
--reset hodnot
net[tonumber(n)].ip4 = nil
net[tonumber(n)].ip6 = nil
local data = io.popen("ip addr show "..net[tonumber(n)].dev)
while true do
local line = data:read("*l")
if line == nil then break end
z,k,vyber = string.find(line, "state%s(%w*)%s") --stav
if vyber ~= nil then net[tonumber(n)].stav = vyber end
z,k,vyber = string.find(line,"link/%S*%s([%w%p]*)%s") --mac
if vyber ~= nil then net[tonumber(n)].mac = string.upper(vyber) end
z,k,vyber = string.find(line, "inet%s([%d%p]*)/%d+%s") --ip4
if vyber ~= nil then net[tonumber(n)].ip4 = vyber end
z,k,vyber = string.find(line, "inet6%s(%S*)/%d+%s") --ip6
if vyber ~= nil then net[tonumber(n)].ip6 = vyber end
end--while true do
data:close()
end--for n = 1, #net do
----------------------------------------
--ostatní informace
for n = 1, #net do
--reset hodnot
net[tonumber(n)].essid = nil
net[tonumber(n)].mac_ap = nil
local dev = net[tonumber(n)].dev
--nastavení wifi
if string.match(dev,"(%w*)%d") == "wlan" or string.match(dev,"(%w*)%d") == "mon" then
local data = io.popen("iwconfig "..dev)
while true do
local line = data:read("*l")
if line == nil then break end
z,k,vyber = string.find(line, "(IEEE%s%S*)%s") --standard b/g/n
if vyber ~= nil then net[tonumber(n)].wifi = vyber end
z,k,vyber = string.find(line,"ESSID%p(%S+)") --essid
if vyber ~= nil then net[tonumber(n)].essid = vyber end
z,k,vyber = string.find(line, "Mode%p(%S+)%s") --mód
if vyber ~= nil then net[tonumber(n)].mod = vyber end
z,k,vyber = string.find(line, "Access%sPoint%p%s(%S*)%s") --mac ap
if vyber ~= nil then net[tonumber(n)].pripojeno_mac = vyber end
end--while true do
data:close()
local mac_ap = net[tonumber(n)].pripojeno_mac
if mac_ap ~= nil or mac_ap ~= "Not-Associated" and net[tonumber(n)].mod ~= "Monitor" then
for line in io.lines("/proc/net/arp") do
z,k,ip4_ap = string.find(line,"([%w%p]*)%s*%S*%s*%S*%s*"..string.lower(mac_ap))
if ip4_ap ~= nil then
net[tonumber(n)].pripojeno_ip = ip4_ap
break
end--if ip4_ap ~= nil then
end--for line in io.lines("/proc/net/arp") do
end--if mac_ap ~= nil or mac_ap ~= "Not-Associated" then
end--if string.match(dev,"(%w*)%d") == "wlan" or string.match(dev,"(%w*)%d") == "mon" then
--nastavení síťové karty
if string.match(dev,"(%w*)%d") == "eth" and net[tonumber(n)].ip4 ~= nil then
for line in io.lines("/proc/net/arp") do
z,k,vyber = string.find(line,"(%S+)%s+%S+%s+%S+%s+%S+%s+%S+%s+"..dev)
if vyber ~= nil then
net[tonumber(n)].pripojeno_ip = vyber
z,k,pripojeno_mac = string.find(line, "%S+%s+%S+%s+%S+%s+(%S+)")
net[tonumber(n)].pripojeno_mac = pripojeno_mac
break
end--if vyber ~= nil then
end--for line in io.lines("/proc/net/arp") do
end--if string.match(dev,"(%w*)%d") == "eth" and net[tonumber(n)].ip4 ~= nil then
end--for n = 1, #net do
----------------------------------------
--sousedé na síti
net_soused = {}
for line in io.lines("/proc/net/arp") do
z,k,vyber = string.find(line,"(%S+)")
if tostring(vyber) ~= "IP" and vyber ~= nil then table.insert(net_soused, line) end
end--for line in io.lines("/proc/net/arp") do
for n = 1,#net do
local ip = net[tonumber(n)].pripojeno_ip
if ip ~= nil then
local a = 0
repeat
a = a + 1
if string.match(tostring(net_soused[tonumber(a)]),"(%S+)") == tostring(ip) then
table.remove(net_soused, tonumber(a))
table.sort(net_soused)
a = a - 1
end
until net_soused[tonumber(a)] == nil
end--if ip ~= nil then
end--for n = 1,#net do
end--if tonumber(new_net) ~= tonumber(#net) then
end--if tonumber(update[tostring(name)]) == nil then
----------------------------------------
--vypis dat modulu
----------------------------------------
local x = 0
local y = modul.pozice[tonumber(net_tab.pozice_y)]
--nastavení fontu
cairo_select_font_face (cr, "Mono", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
----------------------------------------
--vykreslení pozadí pro menu
if pozadi_menu == 1 then pozadi(y - 12,15) end
----------------------------------------
--konstrukce pro klikutí na menu
local menu = "NETWORK"
local delka = tonumber(string.len(menu)*7)
--linie - první část
cairo_select_font_face (cr, "Mono", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 12.0);
cairo_set_source_rgba (cr, 1,0.7,0,1);
local linie1 = (rozmer_panelu_x - delka)/2 - 5
cairo_rectangle (cr, x,y-5,linie1,1);cairo_fill (cr);
--pozice kurzoru/kliknutí
if mx>=x+linie1+5 and mx<=x+linie1+5+delka+3 and my<=y and my>=y-12 then
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
if mx == kx and my == ky and klik_menu[tostring(name)] == 0 then
klik_menu[tostring(name)] = 1
elseif mx == kx and my == ky and klik_menu[tostring(name)] == 1 then
klik_menu[tostring(name)] = 0
end--kliknutí
else
cairo_set_source_rgba (cr, 1,0.7,0,1);
end--pozice kurzoru
cairo_move_to (cr, x+linie1+5, y);cairo_show_text (cr, menu);--text menu
--linie - druhá část
cairo_set_source_rgba (cr, 1,0.7,0,1);
local linie2 = rozmer_panelu_x - (linie1+5+delka+7)
cairo_rectangle (cr, x+linie1+5+delka+7,y-5,linie2,1);cairo_fill (cr);
----------------------------------------
--otevřený panel
y = y + 3
if klik_menu[tostring(name)] == 1 then
cairo_select_font_face (cr, "Mono", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
----------------------------------------
--brána a hostname - pouze pokud bude spojení
local brana = net_info[1]
if brana ~= nil then
local delka = tonumber(string.len(brana)*6)
--pozadí pro bránu,hostname,upload,download
if pozadi_panel == 1 then pozadi(y + 2,34) end
y = y + 15
cairo_set_font_size (cr, 10.0);
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
cairo_move_to (cr, x+10,y-1);cairo_show_text (cr, "Brána: ");
--podmínka pro možnost kliknout na ip adresu brány
local klik = nil
for n = 1,#net do
if tostring(net[tonumber(n)].dev) == tostring(net_info[2]) then klik = 1 end
end--for n = 1,#net do
if klik == 1 then
if mx>=x+55 and mx<=x+55+delka and my<=y and my>=y-10 then
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
if mx == kx and my == ky then os.execute("sensible-browser "..brana.." &") end
else
cairo_set_source_rgba (cr, 0.9,0.9,0.9,1);
end--pozice kurzoru
cairo_move_to (cr, x+55,y-1);cairo_show_text (cr, brana);
elseif klik == nil then
cairo_set_source_rgba (cr, 0.9,0.9,0.9,1);
cairo_move_to (cr, x+55,y-1);cairo_show_text (cr, brana);
end--if klik == 1 then
--připojeno zařízením
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);cairo_show_text (cr, " "..net_info[2]);
--název počítače v síti
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
cairo_move_to (cr, x+205,y-1);cairo_show_text (cr, "Název pc: ");
cairo_set_source_rgba (cr, 0.9,0.9,0.9,1);cairo_show_text (cr, net_info[3]);
--staženo/odesláno
y = y + 15
--odesláno
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
cairo_move_to (cr, x+25,y-1);cairo_show_text (cr, "Odesláno: ");
local text = string.match(conky_parse("${upspeed "..net_info[2].."}"),"([%d%p]*%w)")
cairo_set_source_rgba (cr, 0.9,0.9,0.9,1);cairo_show_text (cr, text);
--celkem
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
cairo_move_to (cr, x+125,y-1);
local text = string.match(conky_parse("${totalup "..net_info[2].."}"),"([%d%p]*%w)")
cairo_show_text (cr, "- "..text);
--přijato
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
cairo_move_to (cr, x+200,y-1);cairo_show_text (cr, "Přijato: ");
local text = string.match(conky_parse("${downspeed "..net_info[2].."}"),"([%d%p]*%w)")
cairo_set_source_rgba (cr, 0.9,0.9,0.9,1);cairo_show_text (cr, text);
--celkem
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
cairo_move_to (cr, x+295,y-1);
local text = string.match(conky_parse("${totaldown "..net_info[2].."}"),"([%d%p]*%w)")
cairo_show_text (cr, "- "..text);
--oddělující čára
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
cairo_rectangle (cr, x+10,y+4,rozmer_panelu_x-20,0.5);cairo_fill (cr);
y = y + 4
end--if brana ~= nil then
----------------------------------------
--seznam zařízení
for n = 1,#net do
--pozadí pro název zařízení
if pozadi_panel == 1 then pozadi(y + 2,15) end
--eth0/wlan0 atd.
if net[tonumber(n)].ip4 ~= nil then --změna barvy u zapnutého zařízení
cairo_set_source_rgba (cr, 1,1,1,1);
else
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
end--if net[tonumber(n)].ip4 ~= nil then
y = y + 15
cairo_set_font_size (cr, 10.0);
cairo_move_to (cr, x+5,y-1);cairo_show_text (cr, net[tonumber(n)].dev);
--model zařízení - kliknutelný text
local text = string.match(net[tonumber(n)].model,"(%S+%s%S+%s%S+)")
local delka = tonumber(string.len(text)*6.75)
cairo_set_font_size (cr, 11.0);
cairo_set_source_rgba (cr, 1,0.7,0,1);
--kurzor (změna barvy textu / kliknutí = informace)
if mx>=x+45 and mx<=x+45+delka and my<=y and my>=y-10 then
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
if mx == kx and my == ky and net_tab.tl[tonumber(n)] == 0 then
net_tab.tl[tonumber(n)] = 1
elseif mx == kx and my == ky and net_tab.tl[tonumber(n)] == 1 then
net_tab.tl[tonumber(n)] = 0
end--kliknuti
else
cairo_set_source_rgba (cr, 1,0.7,0,1);
end--pozice kurzoru
cairo_move_to (cr, x+45,y-1);cairo_show_text (cr, text);
----------------------------------------
--infornace o zařízení po kliknutí na název
if net_tab.tl[tonumber(n)] == 1 then
--výpis informací podle druhu zařízení
local dev = string.match(net[tonumber(n)].dev,"(%w*)%d+")
if tostring(dev) == "eth" then
--pozadí
if pozadi_panel == 1 then pozadi(y + 2,61) end
--stav
y = y + 15
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
cairo_move_to (cr, x+30,y-1);cairo_show_text (cr, "Stav: ");
cairo_set_source_rgba (cr, 0.9,0.9,0.9,1);
local stav = net[tonumber(n)].stav
if stav == "DOWN" then
cairo_show_text (cr, "kabel odpojen");
elseif stav == "UP" and net[tonumber(n)].ip4 == nil then
cairo_show_text (cr, "kabel zapojen");
elseif stav == "UP" and net[tonumber(n)].ip4 ~= nil then
cairo_show_text (cr, "připojeno");
end
--připojeno (ip)
if net[tonumber(n)].ip4 ~= nil then
local text = net[tonumber(n)].pripojeno_ip
if text ~= nil then
local delka = tonumber(string.len(text)*6.75)
if mx>=x+205 and mx<=x+205+delka and my<=y and my>=y-10 then
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
if mx == kx and my == ky then os.execute("sensible-browser "..text.." &") end
else
cairo_set_source_rgba (cr, 0.9,0.9,0.9,1);
end--kliknutí na ip
cairo_move_to (cr, x+205,y-1);cairo_show_text (cr, text);
end--if text ~= nil then
end--if net[tonumber(n)].ip4 ~= nil then
--mac
y = y + 15
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
cairo_move_to (cr, x+30,y-1);cairo_show_text (cr, "mac: ");
cairo_show_text (cr, net[tonumber(n)].mac);
--mac brány
if net[tonumber(n)].ip4 ~= nil then
cairo_move_to (cr, x+205,y-1);
cairo_show_text (cr, string.upper(net[tonumber(n)].pripojeno_mac));
end--if net[tonumber(n)].ip4 ~= nil then
--ip4 a ip6
y = y + 15
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
cairo_move_to (cr, x+30,y-1);cairo_show_text (cr, "ip4: ");
cairo_show_text (cr, net[tonumber(n)].ip4);
y = y + 15
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
cairo_move_to (cr, x+30,y-1);cairo_show_text (cr, "ip6: ");
cairo_show_text (cr, net[tonumber(n)].ip6);
elseif tostring(dev) == "wlan" or tostring(dev) == "mon" then
--pozadí
if pozadi_panel == 1 then pozadi(y + 2,61) end
--stav
y = y + 15
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
cairo_move_to (cr, x+30,y-1);cairo_show_text (cr, "Stav: ");
cairo_set_source_rgba (cr, 0.9,0.9,0.9,1);
local stav = net[tonumber(n)].stav
if stav == "DOWN" then
cairo_show_text (cr, "WiFi vypnuto");
elseif tostring(stav) == "DORMANT" then
cairo_show_text (cr, "WiFi zapnuto");
elseif tostring(stav) == "UP" then
cairo_show_text (cr, "WiFi připojeno");
else
cairo_show_text (cr, "nezjištěn");
end
--připojeno (ap)
if net[tonumber(n)].ip4 ~= nil then
local text = net[tonumber(n)].essid
local web = net[tonumber(n)].pripojeno_ip
if text ~= nil or text ~= "OFF/ANY" then
local delka = tonumber(string.len(text)*6.75)
if mx>=x+205 and mx<=x+205+delka and my<=y and my>=y-10 then
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
if mx == kx and my == ky then os.execute("sensible-browser "..web.." &") end
else
cairo_set_source_rgba (cr, 0.9,0.9,0.9,1);
end--kliknutí na ap
cairo_move_to (cr, x+205,y-1);cairo_show_text (cr, text);
end--if text ~= nil or text ~= "OFF/ANY" then
end--net[tonumber(n)].ip4 ~= nil then
--mac
y = y + 15
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
cairo_move_to (cr, x+30,y-1);cairo_show_text (cr, "mac: ");
cairo_show_text (cr, net[tonumber(n)].mac);
--mac AP
if net[tonumber(n)].pripojeno_mac ~= "Not-Associated" then
cairo_move_to (cr, x+210,y-1);
cairo_show_text (cr, net[tonumber(n)].pripojeno_mac);
end--net[tonumber(n)].pripojeno_mac ~= "Not-Associated" then
--ip a monitování
if net[tonumber(n)].mod == "Monitor" then
y = y + 15
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
cairo_move_to (cr, x+30,y-1);
cairo_show_text (cr, "Zařízení nastaveno na: ");
cairo_set_source_rgba (cr, 0.9,0.9,0.9,1);cairo_show_text (cr, "Monitor");
y = y + 15
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
cairo_move_to (cr, x+65,y-1);
cairo_show_text (cr, "Dostupný pasivní odposlech WiFi.");
else
y = y + 15
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
cairo_move_to (cr, x+30,y-1);cairo_show_text (cr, "ip4: ");
cairo_show_text (cr, net[tonumber(n)].ip4);
y = y + 15
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
cairo_move_to (cr, x+30,y-1);cairo_show_text (cr, "ip6: ");
cairo_show_text (cr, net[tonumber(n)].ip6);
end--if net[tonumber(n)].mod == "Monitor" then
end--if dev == "eth" then
--stav zařízení
y = y + 1
end--if net_tab.tl[tonumber(n)] == 1 then
end--for n = 1,#net do
----------------------------------------
--úprava pozadí pod názvem zařízení (kosmetická úprava)
if pozadi_panel == 1 then pozadi(y + 2,1) end
----------------------------------------
--sousedé v síti
local info = 0
for n = 1,#net do
if net[tonumber(n)].ip4 ~= nil and tonumber(#net_soused) > 0 then
info = 1
break
end
end--for n = 1,#net do
if info == 1 then
--pozadí
if pozadi_panel == 1 then pozadi(y + 3,18) end
--oddělující čára
y = y + 4
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
cairo_rectangle (cr, x+10,y,rozmer_panelu_x-20,0.5);cairo_fill (cr);
y = y + 13
if mx>=x+100 and mx<=x+100+150 and my<=y and my>=y-10 then
cairo_set_source_rgba (cr, 0.9,0.9,0.9,1);
if mx == kx and my == ky and net_tab.soused == 0 then
net_tab.soused = 1
elseif mx == kx and my == ky and net_tab.soused == 1 then
net_tab.soused = 0
end--kliknutí
else
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
end--najetí kurzorem
cairo_move_to (cr, x+125,y-1);cairo_show_text (cr, "sousedé v síti");
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
cairo_rectangle (cr, x+10,y+2,rozmer_panelu_x-20,0.5);cairo_fill (cr);
if net_tab.soused == 1 then
local pocet = tonumber(#net_soused)
--pozadí
if pozadi_panel == 1 then pozadi(y + 4,15*tonumber(pocet)) end
--výpis sousedů
for s = 1,#net_soused do
y = y + 15
local line = tostring(net_soused[tonumber(s)])
z,k,soused_ip = string.find(line,"(%S+)")
z,k,soused_mac = string.find(line,"%S+%s+%S+%s+%S+%s+(%S+)")
z,k,soused_net = string.find(line,"%S+%s+%S+%s+%S+%s+%S+%s+%S+%s+(%S+)")
cairo_set_source_rgba (cr, 0.7,0.7,0.7,1);
cairo_move_to (cr, x+15,y-1);cairo_show_text (cr, soused_ip);
cairo_move_to (cr, x+150,y-1);cairo_show_text (cr, string.upper(soused_mac));
cairo_move_to (cr, x+300,y-1);cairo_show_text (cr, soused_net);
end--for s = 1,#net_soused do
end--if net_tab.soused == 1 then
end--if info == 1 then
end--if klik_menu[tostring(name)] == 1 then
----------------------------------------
--pozice pro další modul
if klik_menu[tostring(name)] == 1 then
next_y = y + 17
else
next_y = y + 14
end--if klik_menu[tostring(name)] == 1 then
modul.pozice[tonumber(net_tab.pozice_y)+1] = next_y
return modul
end--function modul_network()
--############################################################