|
@@ -3,11 +3,17 @@ gi.require_version('Gtk', '3.0')
|
|
|
from gi.repository import GLib, Gtk, GObject
|
|
from gi.repository import GLib, Gtk, GObject
|
|
|
import json
|
|
import json
|
|
|
from nginxparser import loads
|
|
from nginxparser import loads
|
|
|
|
|
+import os
|
|
|
import re
|
|
import re
|
|
|
import spur
|
|
import spur
|
|
|
import threading
|
|
import threading
|
|
|
import time
|
|
import time
|
|
|
|
|
|
|
|
|
|
+DIR_PATH = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
|
+VHOSTS_PATH = DIR_PATH + '/nginx-vhosts'
|
|
|
|
|
+
|
|
|
|
|
+if not os.path.isdir(VHOSTS_PATH):
|
|
|
|
|
+ os.mkdir(VHOSTS_PATH)
|
|
|
|
|
|
|
|
fp = open('creds.json', 'r')
|
|
fp = open('creds.json', 'r')
|
|
|
creds = json.load(fp)
|
|
creds = json.load(fp)
|
|
@@ -99,7 +105,6 @@ class EntryWindow(Gtk.Window):
|
|
|
self.scrollable_treelist.add(self.treeview)
|
|
self.scrollable_treelist.add(self.treeview)
|
|
|
|
|
|
|
|
def filter_func(self, model, iter, data):
|
|
def filter_func(self, model, iter, data):
|
|
|
- print(model, iter, data)
|
|
|
|
|
return True
|
|
return True
|
|
|
|
|
|
|
|
def update_progess(self, domain):
|
|
def update_progess(self, domain):
|
|
@@ -149,8 +154,19 @@ class EntryWindow(Gtk.Window):
|
|
|
|
|
|
|
|
def get_nginx_vhost(self, vhost):
|
|
def get_nginx_vhost(self, vhost):
|
|
|
print(vhost)
|
|
print(vhost)
|
|
|
- vhost_file = ssh_command("cat /etc/nginx/sites-enabled/" + vhost)
|
|
|
|
|
- parsed = loads(vhost_file)
|
|
|
|
|
|
|
+ vhost_file = VHOSTS_PATH + '/' + vhost
|
|
|
|
|
+ if not os.path.isfile(vhost_file):
|
|
|
|
|
+ print("not found locally: " + vhost_file)
|
|
|
|
|
+ vhost_content = ssh_command("cat /etc/nginx/sites-enabled/" + vhost)
|
|
|
|
|
+ vhost_fp = open(vhost_file, "w")
|
|
|
|
|
+ vhost_fp.write(vhost_content)
|
|
|
|
|
+ vhost_fp.close()
|
|
|
|
|
+ else:
|
|
|
|
|
+ print("found locally: " + vhost_file)
|
|
|
|
|
+ vhost_fp = open(vhost_file, "r")
|
|
|
|
|
+ vhost_content = vhost_fp.read()
|
|
|
|
|
+ vhost_fp.close()
|
|
|
|
|
+ parsed = loads(vhost_content)
|
|
|
port_subdmomains = {}
|
|
port_subdmomains = {}
|
|
|
for server in parsed:
|
|
for server in parsed:
|
|
|
server_inner = server[1]
|
|
server_inner = server[1]
|
|
@@ -159,26 +175,26 @@ class EntryWindow(Gtk.Window):
|
|
|
for directive in server_inner:
|
|
for directive in server_inner:
|
|
|
if not port and "listen" in directive:
|
|
if not port and "listen" in directive:
|
|
|
p = re.compile('(\d+)')
|
|
p = re.compile('(\d+)')
|
|
|
- print('listen')
|
|
|
|
|
|
|
+ # print('listen')
|
|
|
ports = p.findall(directive[1])
|
|
ports = p.findall(directive[1])
|
|
|
port = int(ports[0])
|
|
port = int(ports[0])
|
|
|
if "server_name" in directive:
|
|
if "server_name" in directive:
|
|
|
- print('server_name')
|
|
|
|
|
- print(directive)
|
|
|
|
|
|
|
+ # print('server_name')
|
|
|
|
|
+ # print(directive)
|
|
|
subd_trimmed = directive[1].strip()
|
|
subd_trimmed = directive[1].strip()
|
|
|
subdomains = subd_trimmed.split(' ')
|
|
subdomains = subd_trimmed.split(' ')
|
|
|
port_subdmomains[port] = subdomains
|
|
port_subdmomains[port] = subdomains
|
|
|
for subd in subdomains:
|
|
for subd in subdomains:
|
|
|
self.vhost_treestore.append([port, vhost, subd])
|
|
self.vhost_treestore.append([port, vhost, subd])
|
|
|
|
|
|
|
|
- print(port_subdmomains)
|
|
|
|
|
|
|
+ # print(port_subdmomains)
|
|
|
self.vhosts_done += 1
|
|
self.vhosts_done += 1
|
|
|
percent_done = self.vhosts_done * 1.0 / self.num_vhosts
|
|
percent_done = self.vhosts_done * 1.0 / self.num_vhosts
|
|
|
self.progressbar.set_fraction(percent_done)
|
|
self.progressbar.set_fraction(percent_done)
|
|
|
return False
|
|
return False
|
|
|
|
|
|
|
|
def get_https_subdomains_for_domain(self, domain):
|
|
def get_https_subdomains_for_domain(self, domain):
|
|
|
- print(domain)
|
|
|
|
|
|
|
+ # print(domain)
|
|
|
p = re.compile('DNS:([0-9a-z-.]+)')
|
|
p = re.compile('DNS:([0-9a-z-.]+)')
|
|
|
cert_data = ssh_command("sudo openssl x509 -text -in /etc/letsencrypt/live/" + domain + "/fullchain.pem", True)
|
|
cert_data = ssh_command("sudo openssl x509 -text -in /etc/letsencrypt/live/" + domain + "/fullchain.pem", True)
|
|
|
self.domains_done += 1
|
|
self.domains_done += 1
|