From ca70df573618bdba168bc19250066a7f30e6b89c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andy=20Teijelo=20P=C3=A9rez?= Date: Fri, 6 Nov 2015 11:58:05 -0500 Subject: [PATCH] Working on the IP assignation page --- dhcp-hosts.dpto2 | 372 ++++++++++++++++++++++++++-------------- main.py | 82 +++++++-- static/css/dpto2.css | 9 +- static/img/unusable.png | Bin 200 -> 182 bytes templates/ip.html | 103 ++++++++++- templates/ips.html | 15 +- users.dpto2 | 2 + 7 files changed, 422 insertions(+), 161 deletions(-) diff --git a/dhcp-hosts.dpto2 b/dhcp-hosts.dpto2 index 504ab12..eea81d5 100644 --- a/dhcp-hosts.dpto2 +++ b/dhcp-hosts.dpto2 @@ -1,132 +1,242 @@ -# { "reserved-by": "Andy", "locked": true } -5c:f9:ff:ff:ff:ff,00:23:ff:ff:ff:ff,10.6.122.35,set:client5cf9ffffffff - -# lara -00:e0:ff:ff:ff:ff,4c:72:ff:ff:ff:ff,10.0.0.1 +ff:ff:ff:ff:ff:fe,10.6.122.1 +ff:ff:ff:ff:ff:fe,10.6.122.2 +ff:ff:ff:ff:ff:fe,10.6.122.3 +ff:ff:ff:ff:ff:fe,10.6.122.4 +ff:ff:ff:ff:ff:fe,10.6.122.5 +ff:ff:ff:ff:ff:fe,10.6.122.6 +ff:ff:ff:ff:ff:fe,10.6.122.7 +ff:ff:ff:ff:ff:fe,10.6.122.8 +ff:ff:ff:ff:ff:fe,10.6.122.9 +ff:ff:ff:ff:ff:fe,10.6.122.10 +ff:ff:ff:ff:ff:fe,10.6.122.11 +ff:ff:ff:ff:ff:fe,10.6.122.12 +ff:ff:ff:ff:ff:fe,10.6.122.13 +# { "reserved-by": "WiFi dpto2", "locked": true } +ff:ff:ff:ff:ff:fe,10.6.122.14 +ff:ff:ff:ff:ff:fe,10.6.122.15 +ff:ff:ff:ff:ff:fe,10.6.122.16 +ff:ff:ff:ff:ff:fe,10.6.122.17 +ff:ff:ff:ff:ff:fe,10.6.122.18 +ff:ff:ff:ff:ff:fe,10.6.122.19 +ff:ff:ff:ff:ff:fe,10.6.122.20 +ff:ff:ff:ff:ff:fe,10.6.122.21 +ff:ff:ff:ff:ff:fe,10.6.122.22 +ff:ff:ff:ff:ff:fe,10.6.122.23 +ff:ff:ff:ff:ff:fe,10.6.122.24 +ff:ff:ff:ff:ff:fe,10.6.122.25 +ff:ff:ff:ff:ff:fe,10.6.122.26 +ff:ff:ff:ff:ff:fe,10.6.122.27 +ff:ff:ff:ff:ff:fe,10.6.122.28 +ff:ff:ff:ff:ff:fe,10.6.122.29 +ff:ff:ff:ff:ff:fe,10.6.122.30 +ff:ff:ff:ff:ff:fe,10.6.122.31 +ff:ff:ff:ff:ff:fe,10.6.122.32 +ff:ff:ff:ff:ff:fe,10.6.122.33 +ff:ff:ff:ff:ff:fe,10.6.122.34 +ff:ff:ff:ff:ff:fe,10.6.122.35 +ff:ff:ff:ff:ff:fe,10.6.122.36 +ff:ff:ff:ff:ff:fe,10.6.122.37 +ff:ff:ff:ff:ff:fe,10.6.122.38 +ff:ff:ff:ff:ff:fe,10.6.122.39 +ff:ff:ff:ff:ff:fe,10.6.122.40 +ff:ff:ff:ff:ff:fe,10.6.122.41 +ff:ff:ff:ff:ff:fe,10.6.122.42 +ff:ff:ff:ff:ff:fe,10.6.122.43 +ff:ff:ff:ff:ff:fe,10.6.122.44 +ff:ff:ff:ff:ff:fe,10.6.122.45 +ff:ff:ff:ff:ff:fe,10.6.122.46 +ff:ff:ff:ff:ff:fe,10.6.122.47 +ff:ff:ff:ff:ff:fe,10.6.122.48 +ff:ff:ff:ff:ff:fe,10.6.122.49 +ff:ff:ff:ff:ff:fe,10.6.122.50 +ff:ff:ff:ff:ff:fe,10.6.122.51 +ff:ff:ff:ff:ff:fe,10.6.122.52 +ff:ff:ff:ff:ff:fe,10.6.122.53 +ff:ff:ff:ff:ff:fe,10.6.122.54 +ff:ff:ff:ff:ff:fe,10.6.122.55 +ff:ff:ff:ff:ff:fe,10.6.122.56 +ff:ff:ff:ff:ff:fe,10.6.122.57 +ff:ff:ff:ff:ff:fe,10.6.122.58 +ff:ff:ff:ff:ff:fe,10.6.122.59 +ff:ff:ff:ff:ff:fe,10.6.122.60 +ff:ff:ff:ff:ff:fe,10.6.122.61 +ff:ff:ff:ff:ff:fe,10.6.122.62 +ff:ff:ff:ff:ff:fe,10.6.122.63 +ff:ff:ff:ff:ff:fe,10.6.122.64 +ff:ff:ff:ff:ff:fe,10.6.122.65 +ff:ff:ff:ff:ff:fe,10.6.122.66 +ff:ff:ff:ff:ff:fe,10.6.122.67 +ff:ff:ff:ff:ff:fe,10.6.122.68 +ff:ff:ff:ff:ff:fe,10.6.122.69 +ff:ff:ff:ff:ff:fe,10.6.122.70 +ff:ff:ff:ff:ff:fe,10.6.122.71 +ff:ff:ff:ff:ff:fe,10.6.122.72 +ff:ff:ff:ff:ff:fe,10.6.122.73 +ff:ff:ff:ff:ff:fe,10.6.122.74 +ff:ff:ff:ff:ff:fe,10.6.122.75 +ff:ff:ff:ff:ff:fe,10.6.122.76 +ff:ff:ff:ff:ff:fe,10.6.122.77 +ff:ff:ff:ff:ff:fe,10.6.122.78 +ff:ff:ff:ff:ff:fe,10.6.122.79 +ff:ff:ff:ff:ff:fe,10.6.122.80 +ff:ff:ff:ff:ff:fe,10.6.122.81 +ff:ff:ff:ff:ff:fe,10.6.122.82 +ff:ff:ff:ff:ff:fe,10.6.122.83 +ff:ff:ff:ff:ff:fe,10.6.122.84 +ff:ff:ff:ff:ff:fe,10.6.122.85 +ff:ff:ff:ff:ff:fe,10.6.122.86 +ff:ff:ff:ff:ff:fe,10.6.122.87 +ff:ff:ff:ff:ff:fe,10.6.122.88 +ff:ff:ff:ff:ff:fe,10.6.122.89 +ff:ff:ff:ff:ff:fe,10.6.122.90 +ff:ff:ff:ff:ff:fe,10.6.122.91 +ff:ff:ff:ff:ff:fe,10.6.122.92 +ff:ff:ff:ff:ff:fe,10.6.122.93 +ff:ff:ff:ff:ff:fe,10.6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ff:ff:ff:ff:fe,10.0.0.117 -ff:ff:ff:ff:ff:fe,10.0.0.118 -ff:ff:ff:ff:ff:fe,10.0.0.119 -ff:ff:ff:ff:ff:fe,10.0.0.120 -ff:ff:ff:ff:ff:fe,10.0.0.121 -ff:ff:ff:ff:ff:fe,10.0.0.122 -ff:ff:ff:ff:ff:fe,10.0.0.123 -ff:ff:ff:ff:ff:fe,10.0.0.124 -ff:ff:ff:ff:ff:fe,10.0.0.125 -ff:ff:ff:ff:ff:fe,10.0.0.126 -ff:ff:ff:ff:ff:fe,10.0.0.127 - +00:23:54:8c:65:13,10.6.122.96 +ff:ff:ff:ff:ff:fe,10.6.122.97 +ff:ff:ff:ff:ff:fe,10.6.122.98 +ff:ff:ff:ff:ff:fe,10.6.122.99 +ff:ff:ff:ff:ff:fe,10.6.122.100 +ff:ff:ff:ff:ff:fe,10.6.122.101 +ff:ff:ff:ff:ff:fe,10.6.122.102 +ff:ff:ff:ff:ff:fe,10.6.122.103 +ff:ff:ff:ff:ff:fe,10.6.122.104 +ff:ff:ff:ff:ff:fe,10.6.122.105 +ff:ff:ff:ff:ff:fe,10.6.122.106 +ff:ff:ff:ff:ff:fe,10.6.122.107 +ff:ff:ff:ff:ff:fe,10.6.122.108 +ff:ff:ff:ff:ff:fe,10.6.122.109 +ff:ff:ff:ff:ff:fe,10.6.122.110 +ff:ff:ff:ff:ff:fe,10.6.122.111 +ff:ff:ff:ff:ff:fe,10.6.122.112 +ff:ff:ff:ff:ff:fe,10.6.122.113 +ff:ff:ff:ff:ff:fe,10.6.122.114 +ff:ff:ff:ff:ff:fe,10.6.122.115 +ff:ff:ff:ff:ff:fe,10.6.122.116 +ff:ff:ff:ff:ff:fe,10.6.122.117 +ff:ff:ff:ff:ff:fe,10.6.122.118 +ff:ff:ff:ff:ff:fe,10.6.122.119 +ff:ff:ff:ff:ff:fe,10.6.122.120 +ff:ff:ff:ff:ff:fe,10.6.122.121 +ff:ff:ff:ff:ff:fe,10.6.122.122 +ff:ff:ff:ff:ff:fe,10.6.122.123 +ff:ff:ff:ff:ff:fe,10.6.122.124 +ff:ff:ff:ff:ff:fe,10.6.122.125 +ff:ff:ff:ff:ff:fe,10.6.122.126 +ff:ff:ff:ff:ff:fe,10.6.122.127 +ff:ff:ff:ff:ff:fe,10.6.122.128 +ff:ff:ff:ff:ff:fe,10.6.122.129 +ff:ff:ff:ff:ff:fe,10.6.122.130 +ff:ff:ff:ff:ff:fe,10.6.122.131 +ff:ff:ff:ff:ff:fe,10.6.122.132 +ff:ff:ff:ff:ff:fe,10.6.122.133 +ff:ff:ff:ff:ff:fe,10.6.122.134 +ff:ff:ff:ff:ff:fe,10.6.122.135 +ff:ff:ff:ff:ff:fe,10.6.122.136 +ff:ff:ff:ff:ff:fe,10.6.122.137 +ff:ff:ff:ff:ff:fe,10.6.122.138 +ff:ff:ff:ff:ff:fe,10.6.122.139 +ff:ff:ff:ff:ff:fe,10.6.122.140 +ff:ff:ff:ff:ff:fe,10.6.122.141 +ff:ff:ff:ff:ff:fe,10.6.122.142 +ff:ff:ff:ff:ff:fe,10.6.122.143 +ff:ff:ff:ff:ff:fe,10.6.122.144 +ff:ff:ff:ff:ff:fe,10.6.122.145 +ff:ff:ff:ff:ff:fe,10.6.122.146 +ff:ff:ff:ff:ff:fe,10.6.122.147 +ff:ff:ff:ff:ff:fe,10.6.122.148 +ff:ff:ff:ff:ff:fe,10.6.122.149 +ff:ff:ff:ff:ff:fe,10.6.122.150 +ff:ff:ff:ff:ff:fe,10.6.122.151 +ff:ff:ff:ff:ff:fe,10.6.122.152 +ff:ff:ff:ff:ff:fe,10.6.122.153 +ff:ff:ff:ff:ff:fe,10.6.122.154 +ff:ff:ff:ff:ff:fe,10.6.122.155 +ff:ff:ff:ff:ff:fe,10.6.122.156 +ff:ff:ff:ff:ff:fe,10.6.122.157 +ff:ff:ff:ff:ff:fe,10.6.122.158 +ff:ff:ff:ff:ff:fe,10.6.122.159 +ff:ff:ff:ff:ff:fe,10.6.122.160 +ff:ff:ff:ff:ff:fe,10.6.122.161 +ff:ff:ff:ff:ff:fe,10.6.122.162 +ff:ff:ff:ff:ff:fe,10.6.122.163 +ff:ff:ff:ff:ff:fe,10.6.122.164 +ff:ff:ff:ff:ff:fe,10.6.122.165 +ff:ff:ff:ff:ff:fe,10.6.122.166 +ff:ff:ff:ff:ff:fe,10.6.122.167 +ff:ff:ff:ff:ff:fe,10.6.122.168 +ff:ff:ff:ff:ff:fe,10.6.122.169 +ff:ff:ff:ff:ff:fe,10.6.122.170 +ff:ff:ff:ff:ff:fe,10.6.122.171 +ff:ff:ff:ff:ff:fe,10.6.122.172 +ff:ff:ff:ff:ff:fe,10.6.122.173 +ff:ff:ff:ff:ff:fe,10.6.122.174 +ff:ff:ff:ff:ff:fe,10.6.122.175 +ff:ff:ff:ff:ff:fe,10.6.122.176 +ff:ff:ff:ff:ff:fe,10.6.122.177 +ff:ff:ff:ff:ff:fe,10.6.122.178 +ff:ff:ff:ff:ff:fe,10.6.122.179 +ff:ff:ff:ff:ff:fe,10.6.122.180 +ff:ff:ff:ff:ff:fe,10.6.122.181 +ff:ff:ff:ff:ff:fe,10.6.122.182 +ff:ff:ff:ff:ff:fe,10.6.122.183 +ff:ff:ff:ff:ff:fe,10.6.122.184 +ff:ff:ff:ff:ff:fe,10.6.122.185 +ff:ff:ff:ff:ff:fe,10.6.122.186 +ff:ff:ff:ff:ff:fe,10.6.122.187 +ff:ff:ff:ff:ff:fe,10.6.122.188 +ff:ff:ff:ff:ff:fe,10.6.122.189 +ff:ff:ff:ff:ff:fe,10.6.122.190 +ff:ff:ff:ff:ff:fe,10.6.122.191 +ff:ff:ff:ff:ff:fe,10.6.122.192 +ff:ff:ff:ff:ff:fe,10.6.122.193 +ff:ff:ff:ff:ff:fe,10.6.122.194 +ff:ff:ff:ff:ff:fe,10.6.122.195 +ff:ff:ff:ff:ff:fe,10.6.122.196 +ff:ff:ff:ff:ff:fe,10.6.122.197 +ff:ff:ff:ff:ff:fe,10.6.122.198 +ff:ff:ff:ff:ff:fe,10.6.122.199 +ff:ff:ff:ff:ff:fe,10.6.122.200 +ff:ff:ff:ff:ff:fe,10.6.122.201 +ff:ff:ff:ff:ff:fe,10.6.122.202 +ff:ff:ff:ff:ff:fe,10.6.122.203 +ff:ff:ff:ff:ff:fe,10.6.122.204 +ff:ff:ff:ff:ff:fe,10.6.122.205 +ff:ff:ff:ff:ff:fe,10.6.122.206 +ff:ff:ff:ff:ff:fe,10.6.122.207 +ff:ff:ff:ff:ff:fe,10.6.122.208 +ff:ff:ff:ff:ff:fe,10.6.122.209 +ff:ff:ff:ff:ff:fe,10.6.122.210 +ff:ff:ff:ff:ff:fe,10.6.122.211 +ff:ff:ff:ff:ff:fe,10.6.122.212 +ff:ff:ff:ff:ff:fe,10.6.122.213 +ff:ff:ff:ff:ff:fe,10.6.122.214 +ff:ff:ff:ff:ff:fe,10.6.122.215 +ff:ff:ff:ff:ff:fe,10.6.122.231 +ff:ff:ff:ff:ff:fe,10.6.122.232 +ff:ff:ff:ff:ff:fe,10.6.122.233 +ff:ff:ff:ff:ff:fe,10.6.122.234 +ff:ff:ff:ff:ff:fe,10.6.122.235 +ff:ff:ff:ff:ff:fe,10.6.122.236 +ff:ff:ff:ff:ff:fe,10.6.122.237 +ff:ff:ff:ff:ff:fe,10.6.122.238 +ff:ff:ff:ff:ff:fe,10.6.122.239 +ff:ff:ff:ff:ff:fe,10.6.122.240 +ff:ff:ff:ff:ff:fe,10.6.122.241 +ff:ff:ff:ff:ff:fe,10.6.122.242 +ff:ff:ff:ff:ff:fe,10.6.122.243 +ff:ff:ff:ff:ff:fe,10.6.122.244 +ff:ff:ff:ff:ff:fe,10.6.122.245 +ff:ff:ff:ff:ff:fe,10.6.122.246 +ff:ff:ff:ff:ff:fe,10.6.122.247 +ff:ff:ff:ff:ff:fe,10.6.122.248 +ff:ff:ff:ff:ff:fe,10.6.122.249 +ff:ff:ff:ff:ff:fe,10.6.122.250 +ff:ff:ff:ff:ff:fe,10.6.122.251 +ff:ff:ff:ff:ff:fe,10.6.122.252 +ff:ff:ff:ff:ff:fe,10.6.122.253 +ff:ff:ff:ff:ff:fe,10.6.122.254 +ff:ff:ff:ff:ff:fe,10.6.122.255 diff --git a/main.py b/main.py index c9fc27f..10c6fd1 100755 --- a/main.py +++ b/main.py @@ -4,6 +4,9 @@ from flask import Flask, request, abort, make_response, \ render_template, redirect, url_for, \ json, jsonify, session, flash from collections import namedtuple +from subprocess import check_call, call +from fcntl import flock, LOCK_EX, LOCK_SH, LOCK_UN + import hashlib import random import shutil @@ -12,7 +15,6 @@ import sys import re import os -from subprocess import check_call, call #app = Flask("ISABEL-2 Verifier") # That app name breaks Ubuntu 14.04 :-o app = Flask("main") @@ -22,6 +24,27 @@ users_file = "/etc/freeradius/users.dpto2" dhcp_hosts_file = "/etc/dnsmasq.d/dpto2/dhcp-hosts" dhcp_opts_file = "/etc/dnsmasq.d/dpto2/dhcp-opts" +class Lock: + def __init__(self, lockfile): + self.lockfile = lockfile + + def __enter__(self): + flock(self.lockfile, LOCK_EX) + + def __exit__(self, exc_type, exc_val, exc_tb): + flock(self.lockfile, LOCK_UN) + +class SharedLock(Lock): + def __init__(self, lockfile): + super().__init__(lockfile) + + def __enter__(self, exc_type, exc_val, exc_tb): + flock(self.lockfile, LOCK_SH) + +lock_file = open("/run/lock/dpto2.lock","w") +exclusive_lock = Lock(lock_file) +shared_lock = SharedLock(lock_file) + def reload_freeradius(): call("./reload_freeradius") @@ -29,21 +52,25 @@ def delete_user(deluser): f = open(users_file) lines = f.readlines() f.close() - f = open(users_file,"w") + timestamp = time.time() + tempfile = "{}.{}".format(users_file, timestamp) + f = open(tempfile,"w") for line in lines: if line.startswith(deluser): continue f.write(line) f.close() + shutil.move(tempfile, users_file) reload_freeradius() def nthash(password): return hashlib.new('md4',password.encode('utf-16le')).hexdigest().upper() def create_user(username, password, creator): - f = open(users_file,"a") - f.write('{} NT-Password := "{}" # created by {} \n'.format(username, nthash(password), creator)) - f.close() + with exclusive_lock: + f = open(users_file,"a") + f.write('{} NT-Password := "{}" # created by {} \n'.format(username, nthash(password), creator)) + f.close() reload_freeradius() @app.route("/") @@ -165,30 +192,35 @@ def list_users(): mac_re = re.compile("(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}") ip_re = re.compile("\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}") -DhcpHostLine = namedtuple("DhcpHostLine","macs ip") +DhcpHostLine = namedtuple("DhcpHostLine","macs ip tag") def parse_dchp_host(line): macs = [] ip = "" + tag = "" parts = line.split(",") for p in parts: p = p.strip() m = mac_re.match(p) if m: macs.append(m.group(0)) + continue m = ip_re.match(p) if m: ip = m.group(0) - return DhcpHostLine(macs, ip) + continue + if p.startswith("set:"): + tag = p[4:] + return DhcpHostLine(macs, ip, tag) -Ip = namedtuple("Ip","reserved_by dhcp") +Ip = namedtuple("Ip","reserved_by dhcp locked") -@app.route("/ips") -def ips(): +def load_ips(): ipmap = {} for i in range(1,255): - ipmap[i] = Ip("",True) - ipmap[0] = ipmap[255] = Ip("", False) + ipmap[i] = Ip("",True,False) + ipmap[0] = ipmap[255] = Ip("", False, False) + prefix = None with open(dhcp_hosts_file) as f: meta = {} for line in f: @@ -205,13 +237,31 @@ def ips(): if re.match("^[0-9a-fA-F]{2}:",line): r = parse_dchp_host(line) ip = int(r.ip.split(".")[-1]) - ipmap[ip] = Ip(meta.get("reserved-by",""), False) + if prefix is None: + prefix = ".".join(r.ip.split(".")[:-1]) + ipmap[ip] = Ip( + reserved_by=meta.get("reserved-by",""), + dhcp=False, + locked=meta.get("locked",False) + ) meta = {} + ipmap["prefix"] = prefix + return ipmap + +@app.route("/ips") +def ips(): + ipmap = load_ips() return render_template("ips.html", ipmap=ipmap) -@app.route("/ip/") -def ip(addr): - return render_template("ip.html", ip=addr) +@app.route("/ip/") +def ip(last_byte): + ipmap = load_ips() + addr = "{}.{}".format(ipmap["prefix"], last_byte) + return render_template( + "ip.html", + addr=addr, + meta=ipmap[last_byte], + ) @app.route("/logout") def logout(): diff --git a/static/css/dpto2.css b/static/css/dpto2.css index b218329..472dca3 100644 --- a/static/css/dpto2.css +++ b/static/css/dpto2.css @@ -14,8 +14,10 @@ div.main-container { div.ips-row { margin-bottom: 0px; display: flex; + align-items: stretch; flex-direction: row; justify-content: center; + max-height: 54px; /*line-height: 0;*/ } div.ips-cell { @@ -23,8 +25,8 @@ div.ips-cell { flex-direction: column; justify-content: center; background-color: #faf4fa; - width: 60px; - height: 60px; + width: 54px; + height: 54px; margin: 0px; border-bottom: 1px solid lightgray; border-right: 1px solid lightgray; @@ -47,7 +49,8 @@ div.ips-cell.ips-bottom,div.ips-hor-half { } div.name { - max-height: 70px; +/* max-height: 52px; */ + font-size: small; } span.ip { position: absolute; diff --git a/static/img/unusable.png b/static/img/unusable.png index 86c05aa3b7db961b55d75a259336684d6deb9c6c..38a3af2d0b8123a85b791c0074dae46969a48962 100644 GIT binary patch delta 133 zcmX@XxQ%gw3O`$tx4R3&e-K=-clqRrh7#HAC7!;n?Dx6Zc!d@8<7UibU|?|eba4!k zxLkXFBkutP5$A)=ZyGmoZmt$SqU0&8DSH3z<zRc)V5x5baI)^|2m>%S7Fc^7CLgQu&X%Q~loCIB6XGlc*E delta 172 zcmdnSc!F_)N=&TIAWfr64Ht`Q}{`DrEP ziAAXl<>lpinR(g8$%zH2dih1^v)|cB0TsD=x;TbNOsze8kheiWg!uxy#o77CPkubc zmiN%LSK(Ihzopr08lJFd;kCd diff --git a/templates/ip.html b/templates/ip.html index 69ccad5..9fd84ff 100644 --- a/templates/ip.html +++ b/templates/ip.html @@ -2,19 +2,112 @@ {% block title %}Subir Circuito{% endblock %} {% block head %} - {{ super() }} + {{ super() }} {% endblock %} {% block content %}
-

Asignación de 10.6.122.{{ ip }}

+

Asignación de {{ addr }}

+
+ +{% if meta.locked %} +
Esta dirección está reservada por Ilúvatar
+{% endif %} + +
+
+ {% if meta.locked %} +
+ {% endif %} +
+
+ + + +
+
+
+ + +
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+ + {% if create_error %} +
+

Error: {{ errormsg }}

+
+ {% endif %} +
+ +
+ {% if meta.locked %} +
+ {% endif %} +
-
- -
+ Regresar
+ + {% endblock %} diff --git a/templates/ips.html b/templates/ips.html index 807cf48..4c512de 100644 --- a/templates/ips.html +++ b/templates/ips.html @@ -25,12 +25,15 @@ {% if unusable %} unusable{% endif %} {%- if ipmap[ip].dhcp %} dhcp-pool{% endif -%} "> -
- {% if ipmap[ip].dhcp %} - DHCP - {% else %} - {{ ipmap[ip].reserved_by }} - {% endif %} +
+
+ {% if ipmap[ip].dhcp %} + DHCP + {% else %} + {{ ipmap[ip].reserved_by }} + {% endif %} +
+
{% if usable %} {% if ipmap[ip].locked %} diff --git a/users.dpto2 b/users.dpto2 index 5f268ba..41d8876 100644 --- a/users.dpto2 +++ b/users.dpto2 @@ -12,3 +12,5 @@ Bolufe NT-Password := "8846F7EAEE8FB117AD06BDD830B7586C" # created by apiad hydn NT-Password := "8846F7EAEE8FB117AD06BDD830B7586C" oscarluis NT-Password := "8846F7EAEE8FB117AD06BDD830B7586C" # created by hydn luilver NT-Password := "8846F7EAEE8FB117AD06BDD830B7586C" # created by pepe +perico NT-Password := "70A3D0B8621E601DCCA59F8E23A11B75" # created by ateijelo +qwer NT-Password := "E5810F3C99AE2ABB2232ED8458A61309" # created by ateijelo