Added common name to network, fix issue #1

This commit is contained in:
Julia Pfitzer 2019-01-03 18:29:49 +01:00
parent 120933aa33
commit aa75cfc0f7
3 changed files with 15 additions and 12 deletions

View file

@ -13,12 +13,13 @@ class Organization(models.Model):
return self.name
class Network(models.Model):
commonname = models.CharField("Common Name", max_length=64, default="Network")
extip = models.CharField("External/Public IP", max_length=15)
intip = models.CharField("Internal/Private IP", max_length=15)
organizations = models.ManyToManyField(Organization)
def __str__(self):
return "%s (%s)" % (self.intip, self.extip)
return "%s (%s)" % (self.intip, self.commonname)
class Model(models.Model):
name = models.CharField("Model Name", max_length=100, unique=True)

View file

@ -49,18 +49,20 @@ if /usr/bin/wget -O/tmp/wireless.in https://admin360.kumi.host/wireless --post-d
then
while read p
do
if [[ $p == "# VPN360 WiFi Configuration" ]]
echo $p >/tmp/wireless.line
if /bin/grep wifi-iface /tmp/wireless.line && ! /bin/grep radio /tmp/wireless.line;
then
break
fi
echo $p >>/tmp/wireless.og
done </etc/config/wireless
/bin/cat /tmp/wireless.in >>/tmp/wireless.og
/bin/mv /tmp/wireless.og /etc/config/wireless
/bin/cp /tmp/wireless.og /etc/config/wireless
/sbin/uci commit /etc/config/wireless
/bin/rm /tmp/wireless.*
fi
"""
device.lastbeat = timezone.now()
elif device.reboot:
code = "/sbin/reboot"
@ -77,18 +79,18 @@ fi
return HttpResponse(code)
def makewificonfig(device):
output = "\n# VPN360 WiFi Configuration\n"
output = ""
i = 1
for wifi in device.wifi.all():
output += """
config wifi-iface
option network 'wwan'
output += """config wifi-iface
option network 'wwan%i'
option ssid '%s'
option encryption 'psk2'
option device 'radio1'
option mode 'sta'
option key '%s'
""" % (wifi.ssid, wifi.key)
""" % (i, wifi.ssid, wifi.key)
i += 1
return output
@ -236,7 +238,7 @@ def ping(request, device_id):
ajax += ',\n "network": {'
ajax += '\n "intip": "%s"' % device[0].network.intip
ajax += ',\n "extip": "%s"' % device[0].network.extip
ajax += ',\n "commonname": "%s"' % device[0].network.commonname
ajax += '\n }'
except:
@ -430,7 +432,7 @@ def makewifi(request):
serial = wifi_serial,
ssid = wifi_ssid,
key = wifi_key,
organization = wifi_organization
organization = Organization.objects.filter(id=wifi_organization)[0]
)
return redirect("/")

View file

@ -29,7 +29,7 @@ function styleStatus(msg, device) {
};
if (msg.hasOwnProperty("network")) {
device_network.text(msg.network.intip + " (" + msg.network.extip + ")");
device_network.text(msg.network.intip + " (" + msg.network.commonname + ")");
};
if (msg.hasOwnProperty("reboot")) {