mirror of
https://github.com/r4sas/py-i2phosts
synced 2025-09-01 16:42:11 +00:00
py-i2phosts-injector: check for key conflicts when adding
Now we can see when key for some host are differs with our key
This commit is contained in:
parent
9a6cc81403
commit
6a844c42f0
@ -50,15 +50,18 @@ for line in f:
|
|||||||
else:
|
else:
|
||||||
# Check for already existed hosts in database to avoid unneeded INSERTs
|
# Check for already existed hosts in database to avoid unneeded INSERTs
|
||||||
# beacuse they will fail anyway.
|
# beacuse they will fail anyway.
|
||||||
qs = i2phost.objects.filter(name=hostname)
|
try:
|
||||||
if qs.exists():
|
h = i2phost.objects.get(name=hostname)
|
||||||
if not args.supress:
|
except i2phost.DoesNotExist:
|
||||||
print 'Host %s already exists' % hostname
|
|
||||||
else:
|
|
||||||
if not args.quiet:
|
if not args.quiet:
|
||||||
print 'Adding %s' % hostname
|
print 'Adding %s' % hostname
|
||||||
host = i2phost(name=hostname, b64hash=base64,
|
host = i2phost(name=hostname, b64hash=base64,
|
||||||
description=args.description,
|
description=args.description,
|
||||||
activated=True, external=True)
|
activated=True, external=True)
|
||||||
host.save()
|
host.save()
|
||||||
|
else:
|
||||||
|
if not args.supress:
|
||||||
|
print 'Host %s already exists' % hostname
|
||||||
|
if h.b64hash != base64:
|
||||||
|
print 'Key conflict for host: %s' % hostname
|
||||||
f.close()
|
f.close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user