Compare commits
1 commit
70210142da
...
1d91382733
Author | SHA1 | Date | |
---|---|---|---|
Jannik Beyerstedt | 1d91382733 |
16
node.lua
16
node.lua
|
@ -22,10 +22,8 @@ font = resource.load_font("vera.ttf")
|
||||||
|
|
||||||
local v = {
|
local v = {
|
||||||
network = "<unkown>",
|
network = "<unkown>",
|
||||||
ethipv4 = "<unkown>",
|
ethip = "<unkown>",
|
||||||
ethipv6 = "<unkown>",
|
wlanip = "<unkown>",
|
||||||
wlanipv4 = "<unkown>",
|
|
||||||
wlanipv6 = "<unkown>",
|
|
||||||
gw = "<unkown>"
|
gw = "<unkown>"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,13 +80,9 @@ function node.render()
|
||||||
|
|
||||||
-- right side: IP addresses
|
-- right side: IP addresses
|
||||||
y = y_start
|
y = y_start
|
||||||
font:write(x_right, y, "Eth: " .. v.ethipv4, fontsize, 1,1,1,1)
|
font:write(x_right, y, "Eth: " .. v.ethip, fontsize, 1,1,1,1)
|
||||||
|
|
||||||
y = y + offset
|
y = y + offset
|
||||||
font:write(x_right, y, v.ethipv6, fontsize, 1,1,1,1)
|
font:write(x_right, y, "WiFi: " .. v.wlanip, fontsize, 1,1,1,1)
|
||||||
|
|
||||||
y = y + offset
|
|
||||||
font:write(x_right, y, "WiFi: " .. v.wlanipv4, fontsize, 1,1,1,1)
|
|
||||||
y = y + offset
|
|
||||||
font:write(x_right, y, v.wlanipv6, fontsize, 1,1,1,1)
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
24
service
24
service
|
@ -60,24 +60,6 @@ def get_ipv4(ifname):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_ipv6(ifname):
|
|
||||||
try:
|
|
||||||
s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
|
|
||||||
info = fcntl.ioctl(s.fileno(), 0x8915,
|
|
||||||
struct.pack('256s', ifname[:15]))
|
|
||||||
ip = socket.inet_ntoa(info[20:24])
|
|
||||||
|
|
||||||
mask = struct.unpack('>I', fcntl.ioctl(
|
|
||||||
s.fileno(), 0x891b, struct.pack('256s', ifname))[20:24])[0]
|
|
||||||
# Remember: not everything has to be performance optimal :-)
|
|
||||||
mask = bin(mask)[2:].count('1')
|
|
||||||
return "%s/%d" % (ip, mask)
|
|
||||||
except IOError:
|
|
||||||
return "<no ipv6>"
|
|
||||||
except:
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def check_network():
|
def check_network():
|
||||||
return os.path.exists('/sd/config/network') and "static" or "dhcp"
|
return os.path.exists('/sd/config/network') and "static" or "dhcp"
|
||||||
|
|
||||||
|
@ -98,10 +80,8 @@ def check_internet():
|
||||||
|
|
||||||
|
|
||||||
tests = [
|
tests = [
|
||||||
(1, "ethipv4", partial(get_ipv4, "eth0")),
|
(1, "ethip", partial(get_ipv4, "eth0")),
|
||||||
(1, "ethipv6", partial(get_ipv6, "eth0")),
|
(1, "wlanip", partial(get_ipv4, "wlan0")),
|
||||||
(1, "wlanipv4", partial(get_ipv4, "wlan0")),
|
|
||||||
(1, "wlanipv6", partial(get_ipv6, "wlan0")),
|
|
||||||
(1, "gw", get_default_gateway),
|
(1, "gw", get_default_gateway),
|
||||||
(10, "online", check_internet),
|
(10, "online", check_internet),
|
||||||
(5, "network", check_network),
|
(5, "network", check_network),
|
||||||
|
|
Loading…
Reference in a new issue