mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-16 02:06:13 +01:00
configure default nameservers
This commit is contained in:
@@ -99,7 +99,6 @@
|
||||
<link rel="stylesheet" type="text/css" href="https://www.jsdelivr.com/package/npm/fontawesome">
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="{% static 'baseTemplate/assets/js-core/jquery-core.min.js' %}"></script>
|
||||
<script type="text/javascript">
|
||||
$(window).load(function () {
|
||||
@@ -486,8 +485,8 @@
|
||||
<li class="createNameServer"><a href="{% url 'createNameserver' %}"
|
||||
title="{% trans 'Create Nameserver' %}"><span>{% trans "Create Nameserver" %}</span></a>
|
||||
</li>
|
||||
<!--<li class="createNameServer"><a href="{% url 'configureDefaultNameServers' %}"
|
||||
title="{% trans 'Configure Default Nameservers' %}"><span>{% trans "CConfigure Default Nameservers" %}</span></a>-->
|
||||
<li class="serverACL"><a href="{% url 'configureDefaultNameServers' %}"
|
||||
title="{% trans 'Configure Default Nameservers' %}"><span>{% trans "Config Default Nameservers" %}</span></a>
|
||||
</li>
|
||||
<li class="createDNSZone"><a href="{% url 'createDNSZone' %}"
|
||||
title="{% trans 'Create DNS Zone' %}"><span>{% trans "Create DNS Zone" %}</span></a>
|
||||
|
||||
@@ -18,6 +18,7 @@ from plogical.acl import ACLManager
|
||||
from manageServices.models import PDNSStatus
|
||||
|
||||
class DNSManager:
|
||||
defaultNameServersPath = '/home/cyberpanel/defaultNameservers'
|
||||
|
||||
def loadDNSHome(self, request = None, userID = None):
|
||||
try:
|
||||
@@ -495,15 +496,79 @@ class DNSManager:
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'deleteZone') == 0:
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
if not os.path.exists('/home/cyberpanel/powerdns'):
|
||||
return render(request, 'dns/addDeleteDNSRecords.html', {"status": 0})
|
||||
|
||||
domainsList = ACLManager.findAllDomains(currentACL, userID)
|
||||
data = {}
|
||||
data['domainsList'] = ACLManager.findAllDomains(currentACL, userID)
|
||||
data['status'] = 1
|
||||
|
||||
return render(request, 'dns/configureDefaultNameServers.html', {"domainsList": domainsList, "status": 1})
|
||||
if os.path.exists(DNSManager.defaultNameServersPath):
|
||||
nsData = open(DNSManager.defaultNameServersPath, 'r').readlines()
|
||||
try:
|
||||
data['firstNS'] = nsData[0]
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
data['secondNS'] = nsData[1]
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
data['thirdNS'] = nsData[2]
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
data['forthNS'] = nsData[3]
|
||||
except:
|
||||
pass
|
||||
|
||||
return render(request, 'dns/configureDefaultNameServers.html', data)
|
||||
|
||||
except BaseException, msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
|
||||
def saveNSConfigurations(self, userID = None, data = None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
nsContent = ''
|
||||
|
||||
try:
|
||||
nsContent = '%s\n%s\n%s\n%s\n' % (data['firstNS'], data['secondNS'], data['thirdNS'], data['forthNS'])
|
||||
except:
|
||||
try:
|
||||
nsContent = '%s\n%s\n%s\n' % (data['firstNS'], data['secondNS'], data['thirdNS'])
|
||||
except:
|
||||
try:
|
||||
nsContent = '%s\n%s\n' % (data['firstNS'], data['secondNS'])
|
||||
except:
|
||||
try:
|
||||
nsContent = '%s\n' % (data['firstNS'])
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
writeToFile = open(DNSManager.defaultNameServersPath, 'w')
|
||||
writeToFile.write(nsContent.rstrip('\n'))
|
||||
writeToFile.close()
|
||||
|
||||
|
||||
final_dic = {'status': 1, 'error_message': "None"}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
except BaseException, msg:
|
||||
final_dic = {'status': 0, 'error_message': str(msg)}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
@@ -40,7 +40,6 @@ app.controller('createNameserver', function($scope,$http) {
|
||||
};
|
||||
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
@@ -57,8 +56,7 @@ app.controller('createNameserver', function($scope,$http) {
|
||||
$scope.nameServerTwo = $scope.firstNS;
|
||||
$scope.nameServerOne = $scope.secondNS;
|
||||
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$scope.createNameserverLoading = true;
|
||||
$scope.nameserverCreationFailed = false;
|
||||
$scope.nameserverCreated = true;
|
||||
@@ -68,6 +66,7 @@ app.controller('createNameserver', function($scope,$http) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.createNameserverLoading = true;
|
||||
$scope.nameserverCreationFailed = true;
|
||||
@@ -79,8 +78,6 @@ app.controller('createNameserver', function($scope,$http) {
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
/* Java script code to create NS ends here */
|
||||
|
||||
@@ -112,7 +109,6 @@ app.controller('createDNSZone', function($scope,$http) {
|
||||
};
|
||||
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
@@ -127,8 +123,7 @@ app.controller('createDNSZone', function($scope,$http) {
|
||||
|
||||
$scope.zoneDomain = $scope.zoneDomain;
|
||||
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$scope.createDNSZoneLoading = true;
|
||||
$scope.dnsZoneCreationFailed = false;
|
||||
$scope.dnsZoneCreated = true;
|
||||
@@ -138,6 +133,7 @@ app.controller('createDNSZone', function($scope,$http) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.createDNSZoneLoading = true;
|
||||
$scope.dnsZoneCreationFailed = true;
|
||||
@@ -149,8 +145,6 @@ app.controller('createDNSZone', function($scope,$http) {
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
/* Java script code to delete DNS Zone */
|
||||
@@ -185,9 +179,6 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
|
||||
$(".caaRecord").hide();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var currentSelection = "aRecord";
|
||||
$("#" + currentSelection).addClass("active");
|
||||
|
||||
@@ -202,7 +193,6 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
|
||||
};
|
||||
|
||||
|
||||
|
||||
$scope.fetchRecords = function () {
|
||||
$scope.recordsLoading = false;
|
||||
$scope.addRecordsBox = false;
|
||||
@@ -229,8 +219,7 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
|
||||
data.priority = $scope.priority;
|
||||
data.ttl = $scope.ttl;
|
||||
data.recordType = type;
|
||||
}
|
||||
else if(type === "A"){
|
||||
} else if (type === "A") {
|
||||
|
||||
data.selectedZone = $scope.selectedZone;
|
||||
data.recordName = $scope.recordName;
|
||||
@@ -238,50 +227,43 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
|
||||
data.ttl = $scope.ttl;
|
||||
data.recordType = type;
|
||||
|
||||
}
|
||||
else if(type === "AAAA"){
|
||||
} else if (type === "AAAA") {
|
||||
data.selectedZone = $scope.selectedZone;
|
||||
data.recordName = $scope.recordName;
|
||||
data.recordContentAAAA = $scope.recordContentAAAA;
|
||||
data.ttl = $scope.ttl;
|
||||
data.recordType = type;
|
||||
}
|
||||
else if(type === "CNAME"){
|
||||
} else if (type === "CNAME") {
|
||||
data.selectedZone = $scope.selectedZone;
|
||||
data.recordName = $scope.recordName;
|
||||
data.recordContentCNAME = $scope.recordContentCNAME;
|
||||
data.ttl = $scope.ttl;
|
||||
data.recordType = type;
|
||||
}
|
||||
else if(type === "SPF"){
|
||||
} else if (type === "SPF") {
|
||||
data.selectedZone = $scope.selectedZone;
|
||||
data.recordName = $scope.recordName;
|
||||
data.recordContentSPF = $scope.recordContentSPF;
|
||||
data.ttl = $scope.ttl;
|
||||
data.recordType = type;
|
||||
}
|
||||
else if(type === "SOA"){
|
||||
} else if (type === "SOA") {
|
||||
data.selectedZone = $scope.selectedZone;
|
||||
data.recordName = $scope.selectedZone;
|
||||
data.recordContentSOA = $scope.recordContentSOA;
|
||||
data.ttl = $scope.ttl;
|
||||
data.recordType = type;
|
||||
}
|
||||
else if(type === "TXT"){
|
||||
} else if (type === "TXT") {
|
||||
data.selectedZone = $scope.selectedZone;
|
||||
data.recordName = $scope.recordName;
|
||||
data.recordContentTXT = $scope.recordContentTXT;
|
||||
data.ttl = $scope.ttl;
|
||||
data.recordType = type;
|
||||
}
|
||||
else if(type === "NS"){
|
||||
} else if (type === "NS") {
|
||||
data.selectedZone = $scope.selectedZone;
|
||||
data.recordName = $scope.selectedZone;
|
||||
data.recordContentNS = $scope.recordContentNS;
|
||||
data.ttl = $scope.ttl;
|
||||
data.recordType = type;
|
||||
}
|
||||
else if(type === "SRV"){
|
||||
} else if (type === "SRV") {
|
||||
data.selectedZone = $scope.selectedZone;
|
||||
data.recordName = $scope.recordName;
|
||||
data.recordContentSRV = $scope.recordContentSRV;
|
||||
@@ -297,10 +279,6 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
@@ -328,8 +306,7 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
|
||||
$scope.recordsLoading = true;
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
|
||||
$scope.recordsFetched = true;
|
||||
$scope.recordDeleted = true;
|
||||
@@ -342,6 +319,7 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.addRecordsBox = true;
|
||||
@@ -354,13 +332,11 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
|
||||
$scope.couldNotAddRecord = true;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
function populateCurrentRecords() {
|
||||
|
||||
var selectedZone = $scope.selectedZone;
|
||||
@@ -379,7 +355,6 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
|
||||
};
|
||||
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
@@ -399,8 +374,7 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
|
||||
|
||||
$scope.domainFeteched = $scope.selectedZone;
|
||||
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
|
||||
$scope.addRecordsBox = true;
|
||||
$scope.currentRecords = true;
|
||||
@@ -416,6 +390,7 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.addRecordsBox = true;
|
||||
@@ -451,7 +426,6 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
|
||||
};
|
||||
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
@@ -476,9 +450,7 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
|
||||
populateCurrentRecords();
|
||||
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
|
||||
$scope.addRecordsBox = true;
|
||||
$scope.currentRecords = true;
|
||||
@@ -499,6 +471,7 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.addRecordsBox = false;
|
||||
@@ -514,21 +487,17 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
|
||||
$scope.couldNotAddRecord = true;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
/* Java script code to delete DNS Zone */
|
||||
|
||||
|
||||
|
||||
/* Java script code to delete DNS Zone */
|
||||
|
||||
app.controller('deleteDNSZone', function ($scope, $http) {
|
||||
@@ -563,7 +532,6 @@ app.controller('deleteDNSZone', function($scope,$http) {
|
||||
};
|
||||
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
@@ -580,8 +548,7 @@ app.controller('deleteDNSZone', function($scope,$http) {
|
||||
$scope.deletedZone = $scope.selectedZone;
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
|
||||
$scope.deleteZoneButton = true;
|
||||
$scope.deleteFailure = false;
|
||||
@@ -593,6 +560,7 @@ app.controller('deleteDNSZone', function($scope,$http) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.deleteZoneButton = true;
|
||||
@@ -606,8 +574,70 @@ app.controller('deleteDNSZone', function($scope,$http) {
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
/* Java script code to delete DNS Zone */
|
||||
|
||||
|
||||
/* Java script code to create NS */
|
||||
|
||||
app.controller('configureDefaultNameservers', function ($scope, $http) {
|
||||
|
||||
|
||||
$scope.cyberPanelLoading = true;
|
||||
|
||||
$scope.saveNSConfigurations = function () {
|
||||
$scope.cyberPanelLoading = false;
|
||||
|
||||
|
||||
url = "/dns/saveNSConfigurations";
|
||||
|
||||
var data = {
|
||||
firstNS: $scope.firstNS,
|
||||
secondNS: $scope.secondNS,
|
||||
thirdNS: $scope.thirdNS,
|
||||
forthNS: $scope.forthNS,
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success!',
|
||||
text: 'Default nameservers saved.',
|
||||
type: 'success'
|
||||
});
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
/* Java script code to create NS ends here */
|
||||
@@ -1,6 +1,6 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Create Nameserver - CyberPanel" %}{% endblock %}
|
||||
{% block title %}{% trans "Configure Default Nameserver - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
@@ -9,13 +9,13 @@
|
||||
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Create Nameserver" %} - <a target="_blank" href="http://go.cyberpanel.net/dns-records" style="height: 23px;line-height: 21px;" class="btn btn-border btn-alt border-red btn-link font-red" title=""><span>{% trans "DNS Docs" %}</span></a></h2>
|
||||
<h2>{% trans "Configure Default Nameserver" %} - <a target="_blank" href="http://go.cyberpanel.net/dns-records" style="height: 23px;line-height: 21px;" class="btn btn-border btn-alt border-red btn-link font-red" title=""><span>{% trans "DNS Docs" %}</span></a></h2>
|
||||
<p>{% trans "You can use this page to setup nameservers using which people on the internet can resolve websites hosted on this server." %}</p>
|
||||
</div>
|
||||
<div ng-controller="createNameserver" class="panel">
|
||||
<div ng-controller="configureDefaultNameservers" class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="content-box-header">
|
||||
{% trans "Details" %} <img ng-hide="createNameserverLoading" src="{% static 'images/loading.gif' %}">
|
||||
{% trans "Details" %} <img ng-hide="cyberPanelLoading" src="{% static 'images/loading.gif' %}">
|
||||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
@@ -32,19 +32,9 @@
|
||||
|
||||
<form action="/" class="form-horizontal bordered-row panel-body">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Domain Name" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="dom" type="text" class="form-control" ng-model="domainForNS" required>
|
||||
</div>
|
||||
|
||||
<div class="current-pack">example.com</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "First Nameserver" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<div ng-init="firstNS='{{ firstNS }}'" class="col-sm-6">
|
||||
<input name="firstNS" type="text" class="form-control" ng-model="firstNS" required>
|
||||
</div>
|
||||
|
||||
@@ -52,64 +42,33 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "IP Address" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input value="IP Address for first nameserver." name="firstNSIP" type="text" class="form-control" ng-model="firstNSIP" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Second Nameserver (Back up)" %} </label>
|
||||
<div class="col-sm-6">
|
||||
<label class="col-sm-3 control-label">{% trans "Second Nameserver" %}</label>
|
||||
<div ng-init="secondNS='{{ secondNS }}'" class="col-sm-6">
|
||||
<input name="secondNS" type="text" class="form-control" ng-model="secondNS" required>
|
||||
</div>
|
||||
<div class="current-pack">ns2.example.com</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "IP Address" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="secondNSIP" type="text" class="form-control" ng-model="secondNSIP" required>
|
||||
<label class="col-sm-3 control-label">{% trans "Third Nameserver" %} </label>
|
||||
<div ng-init="thirdNS='{{ thirdNS }}'" class="col-sm-6">
|
||||
<input name="thirdNS" type="text" class="form-control" ng-model="thirdNS" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Forth Nameserver" %}</label>
|
||||
<div ng-init="forthNS='{{ forthNS }}'" class="col-sm-6">
|
||||
<input name="forthNS" type="text" class="form-control" ng-model="forthNS" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="createNameserverFunc()" class="btn btn-primary btn-lg">{% trans "Create Nameserver" %}</button>
|
||||
<button type="button" ng-click="saveNSConfigurations()" class="btn btn-primary btn-lg">{% trans "Save" %}</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-6">
|
||||
<div ng-hide="nameserverCreationFailed" class="alert alert-danger">
|
||||
<p>{% trans "Nameserver cannot be created. Error message:" %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="nameserverCreated" class="alert alert-success">
|
||||
<p>{% trans "The following nameservers were successfully created:" %} <br>
|
||||
|
||||
<strong>{$ nameServerOne $}</strong> <br>
|
||||
<strong>{$ nameServerTwo $}</strong> <br>
|
||||
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="couldNotConnect" class="alert alert-danger">
|
||||
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
@@ -16,4 +16,5 @@ urlpatterns = [
|
||||
url(r'^deleteDNSRecord',views.deleteDNSRecord,name='deleteDNSRecord'),
|
||||
url(r'^deleteDNSZone',views.deleteDNSZone,name='deleteDNSZone'),
|
||||
url(r'^submitZoneDeletion',views.submitZoneDeletion,name='submitZoneDeletion'),
|
||||
url(r'^saveNSConfigurations$', views.saveNSConfigurations, name='saveNSConfigurations'),
|
||||
]
|
||||
@@ -161,6 +161,15 @@ def configureDefaultNameServers(request):
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def saveNSConfigurations(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
dm = DNSManager()
|
||||
return dm.saveNSConfigurations(userID, json.loads(request.body))
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -788,7 +788,6 @@ app.controller('viewContainer', function ($scope, $http) {
|
||||
|
||||
$scope.cAction = function (action) {
|
||||
$('#actionLoading').show();
|
||||
console.log($scope.cName)
|
||||
url = "/docker/doContainerAction";
|
||||
var data = {name: $scope.cName, action: action};
|
||||
var config = {
|
||||
|
||||
@@ -22,6 +22,7 @@ class DNS:
|
||||
nsd_base = "/etc/nsd/nsd.conf"
|
||||
zones_base_dir = "/usr/local/lsws/conf/zones/"
|
||||
create_zone_dir = "/usr/local/lsws/conf/zones"
|
||||
defaultNameServersPath = '/home/cyberpanel/defaultNameservers'
|
||||
|
||||
## DNS Functions
|
||||
|
||||
@@ -82,6 +83,21 @@ class DNS:
|
||||
auth=1)
|
||||
record.save()
|
||||
|
||||
if os.path.exists(DNS.defaultNameServersPath):
|
||||
defaultNS = open(DNS.defaultNameServersPath, 'r').readlines()
|
||||
|
||||
for items in defaultNS:
|
||||
record = Records(domainOwner=zone,
|
||||
domain_id=zone.id,
|
||||
name=topLevelDomain,
|
||||
type="NS",
|
||||
content=items,
|
||||
ttl=3600,
|
||||
prio=0,
|
||||
disabled=0,
|
||||
auth=1)
|
||||
record.save()
|
||||
else:
|
||||
record = Records(domainOwner=zone,
|
||||
domain_id=zone.id,
|
||||
name=topLevelDomain,
|
||||
|
||||
Reference in New Issue
Block a user