mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2025-01-07 10:55:40 +00:00
Add DNSSEC information into domain list. Adjustemnt in domain list table
This commit is contained in:
parent
7c46c149f8
commit
990bbe5260
@ -357,8 +357,9 @@ class Domain(db.Model):
|
|||||||
serial = db.Column(db.Integer)
|
serial = db.Column(db.Integer)
|
||||||
notified_serial = db.Column(db.Integer)
|
notified_serial = db.Column(db.Integer)
|
||||||
last_check = db.Column(db.Integer)
|
last_check = db.Column(db.Integer)
|
||||||
|
dnssec = db.Column(db.Integer)
|
||||||
|
|
||||||
def __int__(self, id=None, name=None, master=None, type='NATIVE', serial=None, notified_serial=None, last_check=None):
|
def __int__(self, id=None, name=None, master=None, type='NATIVE', serial=None, notified_serial=None, last_check=None, dnssec=None):
|
||||||
self.id = id
|
self.id = id
|
||||||
self.name = name
|
self.name = name
|
||||||
self.master = master
|
self.master = master
|
||||||
@ -366,6 +367,7 @@ class Domain(db.Model):
|
|||||||
self.serial = serial
|
self.serial = serial
|
||||||
self.notified_serial = notified_serial
|
self.notified_serial = notified_serial
|
||||||
self.last_check = last_check
|
self.last_check = last_check
|
||||||
|
self.dnssec = dnssec
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<Domain %r>' % (self.name)
|
return '<Domain %r>' % (self.name)
|
||||||
@ -443,6 +445,7 @@ class Domain(db.Model):
|
|||||||
d.serial = data['serial']
|
d.serial = data['serial']
|
||||||
d.notified_serial = data['notified_serial']
|
d.notified_serial = data['notified_serial']
|
||||||
d.last_check = data['last_check']
|
d.last_check = data['last_check']
|
||||||
|
d.dnssec = data['dnssec']
|
||||||
else:
|
else:
|
||||||
# add new domain
|
# add new domain
|
||||||
d = Domain()
|
d = Domain()
|
||||||
@ -452,6 +455,7 @@ class Domain(db.Model):
|
|||||||
d.serial = data['serial']
|
d.serial = data['serial']
|
||||||
d.notified_serial = data['notified_serial']
|
d.notified_serial = data['notified_serial']
|
||||||
d.last_check = data['last_check']
|
d.last_check = data['last_check']
|
||||||
|
d.dnssec = data['dnssec']
|
||||||
db.session.add(d)
|
db.session.add(d)
|
||||||
try:
|
try:
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
@ -573,6 +577,26 @@ class Domain(db.Model):
|
|||||||
else:
|
else:
|
||||||
return {'status': 'error', 'msg': 'This domain doesnot exist'}
|
return {'status': 'error', 'msg': 'This domain doesnot exist'}
|
||||||
|
|
||||||
|
def get_domain_dnssec(self, domain_name):
|
||||||
|
"""
|
||||||
|
Get domain DNSSEC information
|
||||||
|
"""
|
||||||
|
domain = Domain.query.filter(Domain.name == domain_name).first()
|
||||||
|
if domain:
|
||||||
|
headers = {}
|
||||||
|
headers['X-API-Key'] = PDNS_API_KEY
|
||||||
|
try:
|
||||||
|
jdata = utils.fetch_json(urlparse.urljoin(PDNS_STATS_URL, '/servers/localhost/zones/%s/cryptokeys' % domain.name), headers=headers, method='GET')
|
||||||
|
if 'error' in jdata:
|
||||||
|
return {'status': 'error', 'msg': 'DNSSEC is not enabled for this domain'}
|
||||||
|
else:
|
||||||
|
return {'status': 'ok', 'dnssec': jdata}
|
||||||
|
except:
|
||||||
|
return {'status': 'error', 'msg': 'There was something wrong, please contact administrator'}
|
||||||
|
else:
|
||||||
|
return {'status': 'error', 'msg': 'This domain doesnot exist'}
|
||||||
|
|
||||||
|
|
||||||
class DomainUser(db.Model):
|
class DomainUser(db.Model):
|
||||||
__tablename__ = 'domain_user'
|
__tablename__ = 'domain_user'
|
||||||
id = db.Column(db.Integer, primary_key = True)
|
id = db.Column(db.Integer, primary_key = True)
|
||||||
|
@ -42,6 +42,8 @@ var TableManaged = function () {
|
|||||||
"orderable": true
|
"orderable": true
|
||||||
}, {
|
}, {
|
||||||
"orderable": true
|
"orderable": true
|
||||||
|
}, {
|
||||||
|
"orderable": true
|
||||||
}, {
|
}, {
|
||||||
"orderable": false
|
"orderable": false
|
||||||
}],
|
}],
|
||||||
@ -50,10 +52,10 @@ var TableManaged = function () {
|
|||||||
[5, 15, 20, "All"] // change per page values here
|
[5, 15, 20, "All"] // change per page values here
|
||||||
],
|
],
|
||||||
// set the initial value
|
// set the initial value
|
||||||
"pageLength": 5,
|
"pageLength": 10,
|
||||||
"pagingType": "bootstrap_full_number",
|
"pagingType": "bootstrap_full_number",
|
||||||
"language": {
|
"language": {
|
||||||
"search": "My search: ",
|
"search": "Search: ",
|
||||||
"lengthMenu": " _MENU_ records",
|
"lengthMenu": " _MENU_ records",
|
||||||
"paginate": {
|
"paginate": {
|
||||||
"previous":"Prev",
|
"previous":"Prev",
|
||||||
@ -64,10 +66,10 @@ var TableManaged = function () {
|
|||||||
},
|
},
|
||||||
"columnDefs": [{ // set default column settings
|
"columnDefs": [{ // set default column settings
|
||||||
'orderable': false,
|
'orderable': false,
|
||||||
'targets': [0]
|
'targets': [5]
|
||||||
}, {
|
}, {
|
||||||
"searchable": false,
|
"searchable": false,
|
||||||
"targets": [0]
|
"targets": [5]
|
||||||
}],
|
}],
|
||||||
"order": [
|
"order": [
|
||||||
[1, "asc"]
|
[1, "asc"]
|
||||||
@ -96,6 +98,50 @@ var TableManaged = function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
tableWrapper.find('.dataTables_length select').addClass("form-control input-xsmall input-inline"); // modify table per page dropdown
|
tableWrapper.find('.dataTables_length select').addClass("form-control input-xsmall input-inline"); // modify table per page dropdown
|
||||||
|
|
||||||
|
function getdnssec(url){
|
||||||
|
$.getJSON(url, function(data) {
|
||||||
|
if (data['status'] == 'error'){
|
||||||
|
bootbox.alert({
|
||||||
|
title: 'DNSSEC',
|
||||||
|
message: 'DNSSEC is not enabled for this domain.'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var dnssec_msg = '';
|
||||||
|
var dnssec = data['dnssec'];
|
||||||
|
for (var i = 0; i < dnssec.length; i++) {
|
||||||
|
if (dnssec[i]['active']){
|
||||||
|
dnssec_msg += '<form class="bootbox-form">'+
|
||||||
|
'<h3><strong>'+dnssec[i]['keytype']+'</strong></h3>'+
|
||||||
|
'<strong>DNSKEY</strong>'+
|
||||||
|
'<input class="bootbox-input bootbox-input-text form-control" autocomplete="off" type="text" readonly="true" value="'+dnssec[i]['dnskey']+'">'+
|
||||||
|
'</form>'+
|
||||||
|
'<br/>';
|
||||||
|
if(dnssec[i]['ds']){
|
||||||
|
var dsList = dnssec[i]['ds'];
|
||||||
|
dnssec_msg += '<strong>DS</strong>';
|
||||||
|
for (var j = 0; j < dsList.length; j++){
|
||||||
|
dnssec_msg += '<input class="bootbox-input bootbox-input-text form-control" autocomplete="off" type="text" readonly="true" value="'+dsList[j]+'">';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bootbox.alert({
|
||||||
|
title: 'DNSSEC',
|
||||||
|
message: dnssec_msg
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
table.on('click', '.dnssec', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var nRow = $(this).parents('tr')[0];
|
||||||
|
var domain_name = nRow.cells[0].innerText;
|
||||||
|
getdnssec('/domain/'+ domain_name +'/dnssec');
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var initTableConfig = function () {
|
var initTableConfig = function () {
|
||||||
|
@ -69,12 +69,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<table class="table table-striped table-bordered table-hover" id="tb_vps_list">
|
<table class="table table-striped table-bordered table-hover" id="tb_domain_list">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
Name
|
Name
|
||||||
</th>
|
</th>
|
||||||
|
<th>
|
||||||
|
DNSSEC
|
||||||
|
</th>
|
||||||
<th>
|
<th>
|
||||||
Kind
|
Kind
|
||||||
</th>
|
</th>
|
||||||
@ -95,6 +98,13 @@
|
|||||||
<td>
|
<td>
|
||||||
<a href="{{ url_for('domain', domain_name=domain.name) }}"><strong>{{ domain.name }}</strong></a>
|
<a href="{{ url_for('domain', domain_name=domain.name) }}"><strong>{{ domain.name }}</strong></a>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if domain.dnssec %}
|
||||||
|
<a href="javascript:;" class="btn default btn-xs blue dnssec"><i class="fa fa-lock"></i>Enabled</a>
|
||||||
|
{% else %}
|
||||||
|
<a href="javascript:;" class="btn default btn-xs gray dnssec"><i class="fa fa-unlock-alt"></i>Disabled</a>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ domain.type }}
|
{{ domain.type }}
|
||||||
</td>
|
</td>
|
||||||
@ -135,6 +145,7 @@
|
|||||||
<!-- BEGIN PAGE LEVEL SCRIPTS -->
|
<!-- BEGIN PAGE LEVEL SCRIPTS -->
|
||||||
<script src="{{ url_for('static', filename='global/scripts/metronic.js') }}" type="text/javascript"></script>
|
<script src="{{ url_for('static', filename='global/scripts/metronic.js') }}" type="text/javascript"></script>
|
||||||
<script src="{{ url_for('static', filename='admin/layout2/scripts/layout.js') }}" type="text/javascript"></script>
|
<script src="{{ url_for('static', filename='admin/layout2/scripts/layout.js') }}" type="text/javascript"></script>
|
||||||
|
<script src="{{ url_for('static', filename='global/plugins/bootbox/bootbox.min.js') }}" type="text/javascript"></script>
|
||||||
<!-- END PAGE LEVEL SCRIPTS -->
|
<!-- END PAGE LEVEL SCRIPTS -->
|
||||||
<!-- TABLE PLUGINS -->
|
<!-- TABLE PLUGINS -->
|
||||||
<script type="text/javascript" src="{{ url_for('static', filename='global/plugins/select2/select2.min.js') }}"></script>
|
<script type="text/javascript" src="{{ url_for('static', filename='global/plugins/select2/select2.min.js') }}"></script>
|
||||||
|
@ -308,6 +308,14 @@ def record_delete(domain_name, record_name, record_type):
|
|||||||
return redirect(url_for('domain', domain_name=domain_name))
|
return redirect(url_for('domain', domain_name=domain_name))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/domain/<string:domain_name>/dnssec', methods=['GET'])
|
||||||
|
@login_required
|
||||||
|
def domain_dnssec(domain_name):
|
||||||
|
domain = Domain()
|
||||||
|
dnssec = domain.get_domain_dnssec(domain_name)
|
||||||
|
return make_response(jsonify(dnssec), 200)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/admin', methods=['GET', 'POST'])
|
@app.route('/admin', methods=['GET', 'POST'])
|
||||||
@login_required
|
@login_required
|
||||||
@admin_role_required
|
@admin_role_required
|
||||||
|
Loading…
Reference in New Issue
Block a user