Spaces:
Sleeping
Sleeping
Commit
·
a655661
1
Parent(s):
d7d7109
refactor: Update app.py for CNAME generation and verification
Browse files- app.py +21 -10
- verify_cname.py +48 -0
app.py
CHANGED
@@ -2,17 +2,22 @@ import os
|
|
2 |
import sys
|
3 |
import gradio as gr
|
4 |
from main import main
|
5 |
-
from tools import write_file
|
6 |
from gen_client_cnames import gen_client_cnames
|
|
|
7 |
|
8 |
def gen_cname(i_domains):
|
9 |
cf_domain = "sileruagartha.eu.org"
|
10 |
cname_recs, cname_values = gen_client_cnames(i_domains, cf_domain)
|
11 |
table_data = []
|
12 |
-
for
|
13 |
-
table_data.append([
|
14 |
return table_data
|
15 |
|
|
|
|
|
|
|
|
|
16 |
def gen_ssl(i_domains, wildcard, email, ca_server, key_type, key_size=None, key_curve=None):
|
17 |
if key_type == "rsa":
|
18 |
key_curve = None
|
@@ -43,14 +48,21 @@ def update_ca_server(wildcard: bool):
|
|
43 |
return gr.update(choices=["Let's Encrypt (Testing)","Let's Encrypt", "ZeroSSL", "Google (Testing)","Google", "SSL.com"], value="Let's Encrypt")
|
44 |
|
45 |
def app():
|
46 |
-
with gr.Blocks() as webui:
|
47 |
with gr.Tab("STEP 1: Generate CNAME Records"):
|
48 |
with gr.Row():
|
49 |
-
|
50 |
-
|
51 |
with gr.Row():
|
52 |
records = gr.Dataframe(label="CNAME Records", headers=["CNAME", "CNAME VALUE"], row_count=(1), col_count=(2))
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
with gr.Tab("STEP 3: Generate SSL"):
|
55 |
with gr.Row():
|
56 |
with gr.Column():
|
@@ -65,7 +77,7 @@ def app():
|
|
65 |
|
66 |
key_type.change(fn=update_key_options, inputs=key_type, outputs=[key_size_dropdown, key_curve_dropdown])
|
67 |
wildcard.change(fn=update_ca_server, inputs=wildcard, outputs=ca_server)
|
68 |
-
|
69 |
|
70 |
with gr.Row():
|
71 |
with gr.Column():
|
@@ -77,8 +89,7 @@ def app():
|
|
77 |
with gr.Column():
|
78 |
crt = gr.Textbox(label="Your SSL Certificate", placeholder="Your SSL Certificate will appear here, after successful SSL generation", type="text", interactive=False, show_copy_button=True, lines=10, max_lines=10)
|
79 |
crtfile = gr.File(label="Download your SSL Certificate")
|
80 |
-
|
81 |
-
btn.click(gen_ssl, inputs=[domains_input, wildcard, email_input, ca_server, key_type, key_size_dropdown, key_curve_dropdown], outputs=[pvt, pvtfile, csr, csrfile, crt, crtfile])
|
82 |
try:
|
83 |
webui.queue(default_concurrency_limit=15).launch()
|
84 |
except Exception as e:
|
|
|
2 |
import sys
|
3 |
import gradio as gr
|
4 |
from main import main
|
5 |
+
from tools import write_file, get_domains
|
6 |
from gen_client_cnames import gen_client_cnames
|
7 |
+
from verify_cname import verify_cname
|
8 |
|
9 |
def gen_cname(i_domains):
|
10 |
cf_domain = "sileruagartha.eu.org"
|
11 |
cname_recs, cname_values = gen_client_cnames(i_domains, cf_domain)
|
12 |
table_data = []
|
13 |
+
for rec, value in zip(cname_recs, cname_values):
|
14 |
+
table_data.append([rec, value])
|
15 |
return table_data
|
16 |
|
17 |
+
def check_cname(domains):
|
18 |
+
data = verify_cname(domains)
|
19 |
+
return data
|
20 |
+
|
21 |
def gen_ssl(i_domains, wildcard, email, ca_server, key_type, key_size=None, key_curve=None):
|
22 |
if key_type == "rsa":
|
23 |
key_curve = None
|
|
|
48 |
return gr.update(choices=["Let's Encrypt (Testing)","Let's Encrypt", "ZeroSSL", "Google (Testing)","Google", "SSL.com"], value="Let's Encrypt")
|
49 |
|
50 |
def app():
|
51 |
+
with gr.Blocks(title="Project Gatekeeper - Get free SSL Certificates") as webui:
|
52 |
with gr.Tab("STEP 1: Generate CNAME Records"):
|
53 |
with gr.Row():
|
54 |
+
cname_domains = gr.Textbox(value="thenayankasturi.eu.org, dash.thenayankasturi.eu.org, www.thenayankasturi.eu.org", label="Enter Domains", placeholder="thenayankasturi.eu.org, dash.thenayankasturi.eu.org, www.thenayankasturi.eu.org", type="text", interactive=True)
|
55 |
+
btn1 = gr.Button(value="Generate CNAME Records & Values")
|
56 |
with gr.Row():
|
57 |
records = gr.Dataframe(label="CNAME Records", headers=["CNAME", "CNAME VALUE"], row_count=(1), col_count=(2))
|
58 |
+
btn1.click(gen_cname, inputs=cname_domains, outputs=records)
|
59 |
+
with gr.Tab("STEP 2: Check CNAME Propagation"):
|
60 |
+
with gr.Row():
|
61 |
+
check_domains = gr.Textbox(label="Enter CNAME", placeholder="thenayankasturi.eu.org, dash.thenayankasturi.eu.org, www.thenayankasturi.eu.org", type="text", interactive=True)
|
62 |
+
btn2 = gr.Button(value="Check CNAME Propagation")
|
63 |
+
with gr.Row():
|
64 |
+
data = gr.Dataframe(label="CNAME Records", headers=["CNAME", "Expected CNAME Value", "Found CNAME Value", "CNAME Status"], row_count=(1), col_count=(4))
|
65 |
+
btn2.click(verify_cname, inputs=check_domains, outputs=data)
|
66 |
with gr.Tab("STEP 3: Generate SSL"):
|
67 |
with gr.Row():
|
68 |
with gr.Column():
|
|
|
77 |
|
78 |
key_type.change(fn=update_key_options, inputs=key_type, outputs=[key_size_dropdown, key_curve_dropdown])
|
79 |
wildcard.change(fn=update_ca_server, inputs=wildcard, outputs=ca_server)
|
80 |
+
btn3 = gr.Button(value="Generate SSL Certificate")
|
81 |
|
82 |
with gr.Row():
|
83 |
with gr.Column():
|
|
|
89 |
with gr.Column():
|
90 |
crt = gr.Textbox(label="Your SSL Certificate", placeholder="Your SSL Certificate will appear here, after successful SSL generation", type="text", interactive=False, show_copy_button=True, lines=10, max_lines=10)
|
91 |
crtfile = gr.File(label="Download your SSL Certificate")
|
92 |
+
btn3.click(gen_ssl, inputs=[domains_input, wildcard, email_input, ca_server, key_type, key_size_dropdown, key_curve_dropdown], outputs=[pvt, pvtfile, csr, csrfile, crt, crtfile])
|
|
|
93 |
try:
|
94 |
webui.queue(default_concurrency_limit=15).launch()
|
95 |
except Exception as e:
|
verify_cname.py
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from dns import resolver
|
2 |
+
from gen_client_cnames import gen_client_cnames
|
3 |
+
|
4 |
+
def verify_cname(i_domains):
|
5 |
+
cname_rec = []
|
6 |
+
cname_value_expected = []
|
7 |
+
cname_value_found = []
|
8 |
+
cname_status = []
|
9 |
+
cf_domain = "silerudaagartha.eu.org"
|
10 |
+
cname_recs, cname_values = gen_client_cnames(i_domains, cf_domain)
|
11 |
+
|
12 |
+
for rec, value in zip(cname_recs, cname_values):
|
13 |
+
redirect_domain = None
|
14 |
+
cname_record = None
|
15 |
+
status = None
|
16 |
+
|
17 |
+
try:
|
18 |
+
cname_answers = resolver.resolve(rec, 'CNAME')
|
19 |
+
for answer in cname_answers:
|
20 |
+
cname_record = answer.to_text().rstrip(".")
|
21 |
+
if cname_record.startswith('_acme-challenge'):
|
22 |
+
redirect_domain = cname_record.split('.')[-1]
|
23 |
+
else:
|
24 |
+
redirect_domain = cname_record
|
25 |
+
except Exception as e:
|
26 |
+
print(f"An error occurred while resolving {rec}: {e}")
|
27 |
+
redirect_domain = None
|
28 |
+
cname_record = None
|
29 |
+
|
30 |
+
if redirect_domain in cname_values:
|
31 |
+
status = "Verified"
|
32 |
+
elif cname_record in cname_values:
|
33 |
+
status = "Verified"
|
34 |
+
else:
|
35 |
+
status = "Not Verified"
|
36 |
+
|
37 |
+
cname_rec.append(rec)
|
38 |
+
cname_value_expected.append(value)
|
39 |
+
cname_value_found.append(redirect_domain or cname_record)
|
40 |
+
cname_status.append(status)
|
41 |
+
|
42 |
+
table_data = []
|
43 |
+
for record, expvalue, foundval, stat in zip(cname_rec, cname_value_expected, cname_value_found, cname_status):
|
44 |
+
table_data.append([record, expvalue, foundval, stat])
|
45 |
+
|
46 |
+
return table_data
|
47 |
+
|
48 |
+
table_data = verify_cname("thenayankasturi.eu.org, dash.thenayankasturi.eu.org, www.thenayankasturi.eu.org")
|