Skip to content

Commit 245bc48

Browse files
committed
1 parent 8e8fd6a commit 245bc48

File tree

5 files changed

+138
-83
lines changed

5 files changed

+138
-83
lines changed

IncBackups/static/IncBackups/IncBackups.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,6 +1877,7 @@ app.controller('ConfigureV2Backup', function ($scope, $http, $timeout) {
18771877
hostName: $scope.hostName,
18781878
UserName: $scope.UserName,
18791879
Repo_Name: $scope.reponame,
1880+
sshPort: $scope.sshPort
18801881
};
18811882

18821883
var config = {

IncBackups/templates/IncBackups/ConfigureV2Backup.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ <h4 class="modal-title">{% trans "Set up account" %}</h4>
134134
</div>
135135
</div>
136136

137+
<div ng-hide="installationDetailsForm" class="form-group">
138+
<label class="col-sm-3 control-label">{% trans "SSH Port" %}</label>
139+
<div class="col-sm-6">
140+
<input name="sshPort" type="text" class="form-control"
141+
ng-model="sshPort" value="Default SSH Port is 22">
142+
</div>
143+
</div>
144+
137145
</form>
138146

139147
</div>

IncBackups/views.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,7 @@ def ConfigureSftpV2Backup(request):
986986
hostName = data['hostName']
987987
UserName = data['UserName']
988988
Repo_Name = data['Repo_Name']
989+
sshPort = data['sshPort']
989990
currentACL = ACLManager.loadedACL(userID)
990991
admin = Administrator.objects.get(pk=userID)
991992

@@ -1001,6 +1002,11 @@ def ConfigureSftpV2Backup(request):
10011002
req_data['password'] = sfptpasswd
10021003
req_data['Repo_Name'] = Repo_Name
10031004

1005+
try:
1006+
req_data['sshPort'] = sshPort
1007+
except:
1008+
req_data['sshPort'] = '22'
1009+
10041010

10051011
cpbuv2 = CPBackupsV2(
10061012
{'domain': Selectedwebsite, 'BasePath': '/home/backup', 'BackupDatabase': 1, 'BackupData': 1,

plogical/Backupsv2.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ def SetupRcloneBackend(self, type, config):
186186
host = {config["host"]}
187187
user = {config["user"]}
188188
pass = {ObsecurePassword}
189+
port = {config["sshPort"]}
189190
'''
190191

191192
command = f"echo '{content}' >> {self.ConfigFilePath}"

plogical/test.py

Lines changed: 122 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,132 @@
1+
# #
2+
# # import imaplib
3+
# # import getpass
4+
# # from email import message_from_string
5+
# # import socket
6+
# #
7+
# # import dns.resolver as dnspython
8+
# #
9+
# # def get_mx_records(domain):
10+
# # try:
11+
# # # Query MX records for the domain
12+
# # mx_records = dns.resolver.resolve(domain, 'MX')
13+
# # # Extract and return the MX record data
14+
# # return [(mx.exchange.to_text(), mx.preference) for mx in mx_records]
15+
# # except dns.resolver.NoAnswer:
16+
# # print(f"No MX records found for {domain}")
17+
# # return []
18+
# # except dns.resolver.NXDOMAIN:
19+
# # print(f"Domain {domain} not found")
20+
# # return []
21+
# # except Exception as e:
22+
# # print(f"Error: {str(e)}")
23+
# # return []
24+
# #
25+
# #
26+
# # # IMAP server settings
27+
# # imap_server = ''
28+
# # imap_port = 993
29+
# #
30+
# # # User credentials
31+
# # email_address = ''
32+
# # password = ''
33+
# #
34+
# # # Connect to the IMAP server
35+
# # mail = imaplib.IMAP4_SSL(imap_server, imap_port)
36+
# #
37+
# # # Log in to the mailbox
38+
# # mail.login(email_address, password)
39+
# #
40+
# # # Select the INBOX
41+
# # mail.select("inbox")
42+
# #
43+
# # # Search for all emails in the INBOX
44+
# # result, data = mail.search(None, "ALL")
45+
# # email_ids = data[0].split()
46+
# #
47+
# # # Fetch and print header information for each email
48+
# # for email_id in email_ids:
49+
# # result, message_data = mail.fetch(email_id, "(BODY[HEADER.FIELDS (FROM TO SUBJECT DATE)])")
50+
# # raw_email = message_data[0][1].decode('utf-8')
51+
# # msg = message_from_string(raw_email)
52+
# # FromDomain = msg['From'].split('@')[1].rstrip('>')
53+
# # MailServer = get_mx_records(FromDomain)
54+
# # print(f'From Domain {FromDomain}')
55+
# # print(f'MX Records of the domains {MailServer}')
56+
# # print(f'Mail Server From Domain {MailServer}')
57+
# # print(f"Email ID: {email_id}")
58+
# # print(f"From: {msg['From']}")
59+
# # print(f"To: {msg['To']}")
60+
# # print(f"Subject: {msg['Subject']}")
61+
# # print(f"Date: {msg['Date']}")
62+
# # print("-" * 30)
63+
# # print(message_data)
64+
# #
65+
# # # Logout
66+
# # mail.logout()
67+
# # #
68+
# # # # from cryptography import x509
69+
# # # # from cryptography.hazmat.backends import default_backend
70+
# # # #
71+
# # # # def get_domains_covered(cert_path):
72+
# # # # with open(cert_path, 'rb') as cert_file:
73+
# # # # cert_data = cert_file.read()
74+
# # # # cert = x509.load_pem_x509_certificate(cert_data, default_backend())
75+
# # # #
76+
# # # # # Check for the Subject Alternative Name (SAN) extension
77+
# # # # san_extension = cert.extensions.get_extension_for_class(x509.SubjectAlternativeName)
78+
# # # #
79+
# # # # if san_extension:
80+
# # # # # Extract and print the domains from SAN
81+
# # # # san_domains = san_extension.value.get_values_for_type(x509.DNSName)
82+
# # # # return san_domains
83+
# # # # else:
84+
# # # # # If SAN is not present, return the Common Name as a fallback
85+
# # # # return [cert.subject.get_attributes_for_oid(x509.NameOID.COMMON_NAME)[0].value]
86+
# # # #
87+
# # # # # Example usage
88+
# # # # cert_path = '/etc/letsencrypt/live/cyberplanner.io/fullchain.pem'
89+
# # # # domains_covered = get_domains_covered(cert_path)
90+
# # # #
91+
# # # # print("Domains covered by the certificate:")
92+
# # # # for domain in domains_covered:
93+
# # # # print(domain)
194
#
2-
# import imaplib
3-
# import getpass
4-
# from email import message_from_string
5-
# import socket
95+
# import dns.resolver
696
#
7-
# import dns.resolver as dnspython
897
#
9-
# def get_mx_records(domain):
98+
# def query_sbl(ip):
1099
# try:
11-
# # Query MX records for the domain
12-
# mx_records = dns.resolver.resolve(domain, 'MX')
13-
# # Extract and return the MX record data
14-
# return [(mx.exchange.to_text(), mx.preference) for mx in mx_records]
15-
# except dns.resolver.NoAnswer:
16-
# print(f"No MX records found for {domain}")
17-
# return []
18-
# except dns.resolver.NXDOMAIN:
19-
# print(f"Domain {domain} not found")
20-
# return []
21-
# except Exception as e:
22-
# print(f"Error: {str(e)}")
23-
# return []
24-
#
25-
#
26-
# # IMAP server settings
27-
# imap_server = ''
28-
# imap_port = 993
100+
# # Construct the reverse DNS lookup domain
101+
# reversed_ip = '.'.join(reversed(ip.split('.')))
102+
# sbl_domain = reversed_ip + '.zen.spamhaus.org'
29103
#
30-
# # User credentials
31-
# email_address = ''
32-
# password = ''
104+
# # Query the SBL DNS server
105+
# result = dns.resolver.resolve(sbl_domain, 'A')
33106
#
34-
# # Connect to the IMAP server
35-
# mail = imaplib.IMAP4_SSL(imap_server, imap_port)
36-
#
37-
# # Log in to the mailbox
38-
# mail.login(email_address, password)
107+
# # If the query returns a result, it means the IP is listed in SBL
108+
# return True
109+
# except dns.resolver.NXDOMAIN:
110+
# # If the domain does not exist, the IP is not listed in SBL
111+
# return False
112+
# except dns.resolver.Timeout:
113+
# # Handle DNS query timeout
114+
# print("DNS query timed out")
115+
# return None
116+
# except dns.resolver.NoAnswer:
117+
# # Handle no DNS answer
118+
# print("No DNS answer")
39119
#
40-
# # Select the INBOX
41-
# mail.select("inbox")
120+
# return None
42121
#
43-
# # Search for all emails in the INBOX
44-
# result, data = mail.search(None, "ALL")
45-
# email_ids = data[0].split()
46122
#
47-
# # Fetch and print header information for each email
48-
# for email_id in email_ids:
49-
# result, message_data = mail.fetch(email_id, "(BODY[HEADER.FIELDS (FROM TO SUBJECT DATE)])")
50-
# raw_email = message_data[0][1].decode('utf-8')
51-
# msg = message_from_string(raw_email)
52-
# FromDomain = msg['From'].split('@')[1].rstrip('>')
53-
# MailServer = get_mx_records(FromDomain)
54-
# print(f'From Domain {FromDomain}')
55-
# print(f'MX Records of the domains {MailServer}')
56-
# print(f'Mail Server From Domain {MailServer}')
57-
# print(f"Email ID: {email_id}")
58-
# print(f"From: {msg['From']}")
59-
# print(f"To: {msg['To']}")
60-
# print(f"Subject: {msg['Subject']}")
61-
# print(f"Date: {msg['Date']}")
62-
# print("-" * 30)
63-
# print(message_data)
123+
# # Example usage
124+
# ip_to_check = '209.85.166.5'
125+
# result = query_sbl(ip_to_check)
126+
# if result is True:
127+
# print(f"The IP {ip_to_check} is listed in Spamhaus Block List (SBL)")
128+
# elif result is False:
129+
# print(f"The IP {ip_to_check} is not listed in Spamhaus Block List (SBL)")
130+
# else:
131+
# print("Unable to determine SBL status for the given IP")
64132
#
65-
# # Logout
66-
# mail.logout()
67-
# #
68-
# # # from cryptography import x509
69-
# # # from cryptography.hazmat.backends import default_backend
70-
# # #
71-
# # # def get_domains_covered(cert_path):
72-
# # # with open(cert_path, 'rb') as cert_file:
73-
# # # cert_data = cert_file.read()
74-
# # # cert = x509.load_pem_x509_certificate(cert_data, default_backend())
75-
# # #
76-
# # # # Check for the Subject Alternative Name (SAN) extension
77-
# # # san_extension = cert.extensions.get_extension_for_class(x509.SubjectAlternativeName)
78-
# # #
79-
# # # if san_extension:
80-
# # # # Extract and print the domains from SAN
81-
# # # san_domains = san_extension.value.get_values_for_type(x509.DNSName)
82-
# # # return san_domains
83-
# # # else:
84-
# # # # If SAN is not present, return the Common Name as a fallback
85-
# # # return [cert.subject.get_attributes_for_oid(x509.NameOID.COMMON_NAME)[0].value]
86-
# # #
87-
# # # # Example usage
88-
# # # cert_path = '/etc/letsencrypt/live/cyberplanner.io/fullchain.pem'
89-
# # # domains_covered = get_domains_covered(cert_path)
90-
# # #
91-
# # # print("Domains covered by the certificate:")
92-
# # # for domain in domains_covered:
93-
# # # print(domain)

0 commit comments

Comments
 (0)