-
Notifications
You must be signed in to change notification settings - Fork 0
/
ApplicationCore.py
62 lines (51 loc) · 2 KB
/
ApplicationCore.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import sys
import logging
import dns.resolver
import dns.update
import dns.zone
class Federation(): #legacy naming :(
def __init__(self):
logging.debug("initializing DNS Class")
#self.resolver = dns.resolver.Resolver()
#self.resolver.nameservers = ['10.77.137.19'] #for testing
def ResolveDns(self):
try:
query=self.resolver.query(self.lineedit_resolve_host.text(), 'A')
except:
print('try again')
for answer in query:
self.textbox.append(str(answer))
print(answer)
# query = dns.resolver.query('gmail.com', 'MX')
#for data in query:
# self.textbox.append("test "+str(data.exchange))
# print('Host', data.exchange, 'has preference', data.preference)
def UpdateDnsA(self,host,ip,domain,type,dnsip):
logging.debug('UpdateDnsA: '+host+' '+ip+' '+domain+' '+dnsip)
update = dns.update.Update(domain)
update.replace(host, 3600, type, ip)
try:
logging.debug('UpdateDnsA: writing to dns server')
response = dns.query.tcp(update, dnsip)
except:
logging.info('Writing A record failed')
logging.exception('')
#self.lineedit_resolve_host.setText(host+'.test.com')
#self.lineedit_srv.setText('test.com')
def UpdateDnsSrv(self,port,host,domain,dnsip):
update=dns.update.Update(domain)
update.add('_xmpp-server._tcp',3600,'SRV','0 0 5269 '+host)
try:
logging.debug('UpdateDnsSrv: writing to dns server')
response = dns.query.tcp(update, dnsip)
except:
logging.info('Writing SRV failed')
logging.exception('')
def GetSrvRecords(self):
domain='_xmpp-server._tcp.'+self.lineedit_srv.text()
print(domain)
queryresult = self.resolver.query(domain, 'SRV')
#for answers in queryresult:
# print(answers)
#except:
# print("couldn't find srv")