mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2025-01-30 21:54:39 +00:00
Merge branch 'master' into flask_migrate
This commit is contained in:
commit
003310665c
@ -842,19 +842,30 @@ class Domain(db.Model):
|
|||||||
if domain:
|
if domain:
|
||||||
headers = {}
|
headers = {}
|
||||||
headers['X-API-Key'] = PDNS_API_KEY
|
headers['X-API-Key'] = PDNS_API_KEY
|
||||||
post_data = {
|
|
||||||
"keytype": "ksk",
|
|
||||||
"active": True
|
|
||||||
}
|
|
||||||
try:
|
try:
|
||||||
|
# Enable API-RECTIFY for domain, BEFORE activating DNSSEC
|
||||||
|
post_data = {
|
||||||
|
"api_rectify": True
|
||||||
|
}
|
||||||
|
jdata = utils.fetch_json(urljoin(PDNS_STATS_URL, API_EXTENDED_URL + '/servers/localhost/zones/{0}'.format(domain.name)), headers=headers, method='PUT', data=post_data)
|
||||||
|
if 'error' in jdata:
|
||||||
|
return {'status': 'error', 'msg': 'API-RECTIFY could not be enabled for this domain', 'jdata' : jdata}
|
||||||
|
|
||||||
|
# Activate DNSSEC
|
||||||
|
post_data = {
|
||||||
|
"keytype": "ksk",
|
||||||
|
"active": True
|
||||||
|
}
|
||||||
jdata = utils.fetch_json(urljoin(PDNS_STATS_URL, API_EXTENDED_URL + '/servers/localhost/zones/{0}/cryptokeys'.format(domain.name)), headers=headers, method='POST',data=post_data)
|
jdata = utils.fetch_json(urljoin(PDNS_STATS_URL, API_EXTENDED_URL + '/servers/localhost/zones/{0}/cryptokeys'.format(domain.name)), headers=headers, method='POST',data=post_data)
|
||||||
if 'error' in jdata:
|
if 'error' in jdata:
|
||||||
return {'status': 'error', 'msg': 'Cannot enable DNSSEC for this domain. Error: {0}'.format(jdata['error']), 'jdata' : jdata}
|
return {'status': 'error', 'msg': 'Cannot enable DNSSEC for this domain. Error: {0}'.format(jdata['error']), 'jdata' : jdata}
|
||||||
else:
|
|
||||||
return {'status': 'ok'}
|
return {'status': 'ok'}
|
||||||
|
|
||||||
except:
|
except:
|
||||||
logging.error(traceback.print_exc())
|
logging.error(traceback.print_exc())
|
||||||
return {'status': 'error', 'msg': 'There was something wrong, please contact administrator'}
|
return {'status': 'error', 'msg': 'There was something wrong, please contact administrator'}
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return {'status': 'error', 'msg': 'This domain does not exist'}
|
return {'status': 'error', 'msg': 'This domain does not exist'}
|
||||||
|
|
||||||
@ -866,16 +877,26 @@ class Domain(db.Model):
|
|||||||
if domain:
|
if domain:
|
||||||
headers = {}
|
headers = {}
|
||||||
headers['X-API-Key'] = PDNS_API_KEY
|
headers['X-API-Key'] = PDNS_API_KEY
|
||||||
url = '/servers/localhost/zones/{0}/cryptokeys/{1}'.format(domain.name, key_id)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
jdata = utils.fetch_json(urljoin(PDNS_STATS_URL, API_EXTENDED_URL + url), headers=headers, method='DELETE')
|
# Deactivate DNSSEC
|
||||||
if 'error' in jdata:
|
jdata = utils.fetch_json(urljoin(PDNS_STATS_URL, API_EXTENDED_URL + '/servers/localhost/zones/{0}/cryptokeys/{1}'.format(domain.name, key_id)), headers=headers, method='DELETE')
|
||||||
|
if jdata != True:
|
||||||
return {'status': 'error', 'msg': 'Cannot disable DNSSEC for this domain. Error: {0}'.format(jdata['error']), 'jdata' : jdata}
|
return {'status': 'error', 'msg': 'Cannot disable DNSSEC for this domain. Error: {0}'.format(jdata['error']), 'jdata' : jdata}
|
||||||
else:
|
|
||||||
return {'status': 'ok'}
|
# Disable API-RECTIFY for domain, AFTER deactivating DNSSEC
|
||||||
|
post_data = {
|
||||||
|
"api_rectify": False
|
||||||
|
}
|
||||||
|
jdata = utils.fetch_json(urljoin(PDNS_STATS_URL, API_EXTENDED_URL + '/servers/localhost/zones/{0}'.format(domain.name)), headers=headers, method='PUT', data=post_data)
|
||||||
|
if 'error' in jdata:
|
||||||
|
return {'status': 'error', 'msg': 'API-RECTIFY could not be disabled for this domain', 'jdata' : jdata}
|
||||||
|
|
||||||
|
return {'status': 'ok'}
|
||||||
|
|
||||||
except:
|
except:
|
||||||
return {'status': 'error', 'msg': 'There was something wrong, please contact administrator','id': key_id, 'url': url}
|
logging.error(traceback.print_exc())
|
||||||
|
return {'status': 'error', 'msg': 'There was something wrong, please contact administrator','domain': domain.name, 'id': key_id}
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return {'status': 'error', 'msg': 'This domain doesnot exist'}
|
return {'status': 'error', 'msg': 'This domain doesnot exist'}
|
||||||
|
|
||||||
|
@ -212,6 +212,13 @@ function getdnssec(url, domain){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reload_domains(url) {
|
||||||
|
$.getJSON(url, function(data) {
|
||||||
|
$('#modal_bg_reload_content').html("<i class=\"fa fa-check\"></i> Finished: " + data['result']['msg']);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// pretty JSON
|
// pretty JSON
|
||||||
json_library = {
|
json_library = {
|
||||||
replacer: function(match, pIndent, pKey, pVal, pEnd) {
|
replacer: function(match, pIndent, pKey, pVal, pEnd) {
|
||||||
|
@ -123,7 +123,7 @@
|
|||||||
<div class="col-xs-12">
|
<div class="col-xs-12">
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="box-header">
|
<div class="box-header">
|
||||||
<h3 class="box-title">Hosted Domains</h3>
|
<h3 class="box-title">Hosted Domains</h3>{% if show_bg_domain_button %}<button type="button" class="btn btn-flat btn-primary refresh-bg-button pull-right"><i class="fa fa-refresh"></i> Sync domains </button>{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
<table id="tbl_domain_list" class="table table-bordered table-striped">
|
<table id="tbl_domain_list" class="table table-bordered table-striped">
|
||||||
@ -199,6 +199,12 @@
|
|||||||
modal.modal('show');
|
modal.modal('show');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(document.body).on('click', '.refresh-bg-button', function() {
|
||||||
|
var modal = $("#modal_bg_reload");
|
||||||
|
modal.modal('show');
|
||||||
|
reload_domains($SCRIPT_ROOT + '/dashboard-domains-updater');
|
||||||
|
});
|
||||||
|
|
||||||
$(document.body).on("click", ".button_template", function (e) {
|
$(document.body).on("click", ".button_template", function (e) {
|
||||||
var modal = $("#modal_template");
|
var modal = $("#modal_template");
|
||||||
var domain = $(this).prop('id');
|
var domain = $(this).prop('id');
|
||||||
@ -314,4 +320,29 @@
|
|||||||
<!-- /.modal-dialog -->
|
<!-- /.modal-dialog -->
|
||||||
</div>
|
</div>
|
||||||
<!-- /.modal -->
|
<!-- /.modal -->
|
||||||
|
<div class="modal fade" id="modal_bg_reload">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal"
|
||||||
|
aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
<h4 class="modal-title">Sync domains from nameserver</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
|
||||||
|
<div class="overlay">
|
||||||
|
<div id="modal_bg_reload_content"><i class="fa fa-refresh fa-spin"></i> Update in progress ..</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-flat btn-default pull-right"
|
||||||
|
data-dismiss="modal">Close</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- /.modal-content -->
|
||||||
|
</div>
|
||||||
|
<!-- /.modal-dialog -->
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
20
app/views.py
20
app/views.py
@ -459,7 +459,12 @@ def saml_logout():
|
|||||||
@app.route('/dashboard', methods=['GET', 'POST'])
|
@app.route('/dashboard', methods=['GET', 'POST'])
|
||||||
@login_required
|
@login_required
|
||||||
def dashboard():
|
def dashboard():
|
||||||
d = Domain().update()
|
if not app.config.get('BG_DOMAIN_UPDATES'):
|
||||||
|
logging.debug('Update domains in foreground')
|
||||||
|
d = Domain().update()
|
||||||
|
else:
|
||||||
|
logging.debug('Update domains in background')
|
||||||
|
|
||||||
|
|
||||||
# stats for dashboard
|
# stats for dashboard
|
||||||
domain_count = Domain.query.count()
|
domain_count = Domain.query.count()
|
||||||
@ -473,7 +478,7 @@ def dashboard():
|
|||||||
else:
|
else:
|
||||||
uptime = 0
|
uptime = 0
|
||||||
|
|
||||||
return render_template('dashboard.html', domain_count=domain_count, users=users, history_number=history_number, uptime=uptime, histories=history, dnssec_adm_only=app.config['DNSSEC_ADMINS_ONLY'], pdns_version=app.config['PDNS_VERSION'])
|
return render_template('dashboard.html', domain_count=domain_count, users=users, history_number=history_number, uptime=uptime, histories=history, dnssec_adm_only=app.config['DNSSEC_ADMINS_ONLY'], pdns_version=app.config['PDNS_VERSION'], show_bg_domain_button=app.config['BG_DOMAIN_UPDATES'])
|
||||||
|
|
||||||
|
|
||||||
@app.route('/dashboard-domains', methods=['GET'])
|
@app.route('/dashboard-domains', methods=['GET'])
|
||||||
@ -542,6 +547,17 @@ def dashboard_domains():
|
|||||||
}
|
}
|
||||||
return jsonify(response_data)
|
return jsonify(response_data)
|
||||||
|
|
||||||
|
@app.route('/dashboard-domains-updater', methods=['GET', 'POST'])
|
||||||
|
@login_required
|
||||||
|
def dashboard_domains_updater():
|
||||||
|
logging.debug('Update domains in background')
|
||||||
|
d = Domain().update()
|
||||||
|
|
||||||
|
response_data = {
|
||||||
|
"result": d,
|
||||||
|
}
|
||||||
|
return jsonify(response_data)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/domain/<path:domain_name>', methods=['GET', 'POST'])
|
@app.route('/domain/<path:domain_name>', methods=['GET', 'POST'])
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -130,3 +130,6 @@ DNSSEC_ADMINS_ONLY = False
|
|||||||
|
|
||||||
# EXPERIMENTAL FEATURES
|
# EXPERIMENTAL FEATURES
|
||||||
PRETTY_IPV6_PTR = False
|
PRETTY_IPV6_PTR = False
|
||||||
|
|
||||||
|
# Domain updates in background, for big installations
|
||||||
|
BG_DOMAIN_UPDATES = False
|
||||||
|
@ -120,3 +120,6 @@ DNSSEC_ADMINS_ONLY = True
|
|||||||
|
|
||||||
# EXPERIMENTAL FEATURES
|
# EXPERIMENTAL FEATURES
|
||||||
PRETTY_IPV6_PTR = False
|
PRETTY_IPV6_PTR = False
|
||||||
|
|
||||||
|
# Domain updates in background, for big installations
|
||||||
|
BG_DOMAIN_UPDATES = False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user