mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-08 22:50:26 +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:
|
||||
headers = {}
|
||||
headers['X-API-Key'] = PDNS_API_KEY
|
||||
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
|
||||
}
|
||||
try:
|
||||
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:
|
||||
return {'status': 'error', 'msg': 'Cannot enable DNSSEC for this domain. Error: {0}'.format(jdata['error']), 'jdata' : jdata}
|
||||
else:
|
||||
|
||||
return {'status': 'ok'}
|
||||
|
||||
except:
|
||||
logging.error(traceback.print_exc())
|
||||
return {'status': 'error', 'msg': 'There was something wrong, please contact administrator'}
|
||||
|
||||
else:
|
||||
return {'status': 'error', 'msg': 'This domain does not exist'}
|
||||
|
||||
@ -866,16 +877,26 @@ class Domain(db.Model):
|
||||
if domain:
|
||||
headers = {}
|
||||
headers['X-API-Key'] = PDNS_API_KEY
|
||||
url = '/servers/localhost/zones/{0}/cryptokeys/{1}'.format(domain.name, key_id)
|
||||
|
||||
try:
|
||||
jdata = utils.fetch_json(urljoin(PDNS_STATS_URL, API_EXTENDED_URL + url), headers=headers, method='DELETE')
|
||||
if 'error' in jdata:
|
||||
# Deactivate DNSSEC
|
||||
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}
|
||||
else:
|
||||
|
||||
# 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:
|
||||
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:
|
||||
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
|
||||
json_library = {
|
||||
replacer: function(match, pIndent, pKey, pVal, pEnd) {
|
||||
|
@ -123,7 +123,7 @@
|
||||
<div class="col-xs-12">
|
||||
<div class="box">
|
||||
<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 class="box-body">
|
||||
<table id="tbl_domain_list" class="table table-bordered table-striped">
|
||||
@ -199,6 +199,12 @@
|
||||
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) {
|
||||
var modal = $("#modal_template");
|
||||
var domain = $(this).prop('id');
|
||||
@ -314,4 +320,29 @@
|
||||
<!-- /.modal-dialog -->
|
||||
</div>
|
||||
<!-- /.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 %}
|
||||
|
18
app/views.py
18
app/views.py
@ -459,7 +459,12 @@ def saml_logout():
|
||||
@app.route('/dashboard', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def dashboard():
|
||||
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
|
||||
domain_count = Domain.query.count()
|
||||
@ -473,7 +478,7 @@ def dashboard():
|
||||
else:
|
||||
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'])
|
||||
@ -542,6 +547,17 @@ def dashboard_domains():
|
||||
}
|
||||
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'])
|
||||
@login_required
|
||||
|
@ -130,3 +130,6 @@ DNSSEC_ADMINS_ONLY = False
|
||||
|
||||
# EXPERIMENTAL FEATURES
|
||||
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
|
||||
PRETTY_IPV6_PTR = False
|
||||
|
||||
# Domain updates in background, for big installations
|
||||
BG_DOMAIN_UPDATES = False
|
||||
|
Loading…
Reference in New Issue
Block a user