mirror of
https://github.com/Py-KMS-Organization/py-kms.git
synced 2025-05-13 06:34:45 -04:00
client: handle dns exceptions #51
This commit is contained in:
parent
ddb99ddc1e
commit
c74a64cc67
2 changed files with 13 additions and 7 deletions
|
@ -143,9 +143,9 @@ user@host ~/path/to/folder/py-kms $ python3 pykms_Server.py -V DEBUG
|
|||
user@host ~/path/to/folder/py-kms $ python3 pykms_Client.py -V DEBUG
|
||||
```
|
||||
|
||||
If you wish to get KMS server from DNS server: (ie perform a DNS resolution on _vlmcs._tcp.domain.tld). If ever there are several answers, only the first one is selected.
|
||||
If you wish to get KMS server from DNS server: (ie perform a DNS resolution on _vlmcs._tcp.domain.tld, if ever there are several answers, only the first one is selected.)
|
||||
```
|
||||
user@host ~/path/to/folder/py-kms $ python3 pykms_Server.py -V DEBUG -F STDOUT -D contoso.com
|
||||
user@host ~/path/to/folder/py-kms $ python3 pykms_Client.py -V DEBUG -F STDOUT -D contoso.com
|
||||
user@host ~/path/to/folder/py-kms $ python3 pykms_Client.py -V DEBUG -F STDOUT -D contoso.com
|
||||
```
|
||||
|
||||
|
|
|
@ -198,11 +198,17 @@ def client_connect():
|
|||
|
||||
if clt_config['discovery'] is not None:
|
||||
loggerclt.info(f'Using Domain: {clt_config["discovery"]}')
|
||||
r = dns.resolver.query('_vlmcs._tcp.' + clt_config['discovery'], dns.rdatatype.SRV)
|
||||
r= None
|
||||
try:
|
||||
r = dns.resolver.resolve('_vlmcs._tcp.' + clt_config['discovery'], dns.rdatatype.SRV)
|
||||
for a in r:
|
||||
loggerclt.debug(f'answer KMS server: {a.target} , port: {a.port}')
|
||||
clt_config['ip'] = socket.gethostbyname(r[0].target.to_text())
|
||||
clt_config['port'] = r[0].port
|
||||
except (dns.exception.Timeout, dns.resolver.NXDOMAIN) as e:
|
||||
pretty_printer(log_obj = loggerclt.warning,
|
||||
put_text = "{reverse}{red}{bold}Cannot resolve '%s'. Error: '%s'...{end}" %(clt_config['discovery'],
|
||||
str(e)))
|
||||
|
||||
loggerclt.info("Connecting to %s on port %d" % (clt_config['ip'], clt_config['port']))
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue