|
@@ -248,9 +248,15 @@ class BatcaveHttpRequestHandler(BaseHTTPRequestHandler):
|
|
|
self.wfile.write('<!DOCTYPE html>\n')
|
|
|
self.wfile.write('<html><head><title>BATCAVE - VPN LIST</title></head>\n')
|
|
|
self.wfile.write('<body>\n')
|
|
|
+ self.wfile.write('<style type="text/css">\n')
|
|
|
+ self.wfile.write('table { border: 2px solid #999; border-collapse: collapse; }\n')
|
|
|
+ self.wfile.write('th, td { border: 1px solid #CCC; }\n')
|
|
|
+ self.wfile.write('table tbody tr.online { background-color: #CFC; }\n')
|
|
|
+ self.wfile.write('table tbody tr.offline { background-color: #FCC; }\n')
|
|
|
+ self.wfile.write('</style>\n')
|
|
|
self.wfile.write('<table>\n<thead>\n')
|
|
|
- self.wfile.write('<tr><th>key</th><th colspan="' + str(len(gateways)) + '">active</th><th colspan="' + str(len(gateways)) + '">last</th></tr>\n')
|
|
|
- self.wfile.write('<tr><th>name</th><th>' + '</th><th>'.join(gateways) + '</th><th>' + '</th><th>'.join(gateways) + '</th></tr>\n')
|
|
|
+ self.wfile.write('<tr><th rowspan="2">names (key)</th><th colspan="' + str(len(gateways)) + '">active</th><th colspan="' + str(len(gateways)) + '">last</th></tr>\n')
|
|
|
+ self.wfile.write('<tr><th>' + '</th><th>'.join(gateways) + '</th><th>' + '</th><th>'.join(gateways) + '</th></tr>\n')
|
|
|
self.wfile.write('</thead>\n')
|
|
|
|
|
|
if self.DATAKEY_VPN in storage.data:
|
|
@@ -258,13 +264,18 @@ class BatcaveHttpRequestHandler(BaseHTTPRequestHandler):
|
|
|
item = storage.data[self.DATAKEY_VPN][key]
|
|
|
|
|
|
names = set()
|
|
|
+ count = {}
|
|
|
for t in [ 'active', 'last' ]:
|
|
|
+ count[t] = 0
|
|
|
if t in item:
|
|
|
for gw in item[t]:
|
|
|
+ if 'remote' in item[t][gw] and len(item[t][gw]['remote']) > 0:
|
|
|
+ count[t] += 1
|
|
|
if 'peer' in item[t][gw]:
|
|
|
- names.add(item[t][gw])
|
|
|
+ names.add(item[t][gw]['peer'])
|
|
|
|
|
|
- self.wfile.write('<tr><td title="' + str(key) + '">' + ' / '.join(names) + '</td>')
|
|
|
+ self.wfile.write('<tr class="online">' if count['active'] > 0 else '<tr class="offline">')
|
|
|
+ self.wfile.write('<td title="' + str(key) + '">' + (' / '.join(names) if len(names) > 0 else '?') + '</td>')
|
|
|
for t in [ 'active', 'last' ]:
|
|
|
for gw in gateways:
|
|
|
ip = ''
|