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">
|
<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" src="{% static 'baseTemplate/assets/js-core/jquery-core.min.js' %}"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(window).load(function () {
|
$(window).load(function () {
|
||||||
@@ -319,7 +318,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<a class="header-btn" id="logout-btn" href="{% url 'logout' %}" title="{% trans 'Logout' %}">
|
<a class="header-btn" id="logout-btn" href="{% url 'logout' %}" title="{% trans 'Logout' %}">
|
||||||
<i class="glyph-icon icon-power-off"></i>
|
<i class="glyph-icon icon-power-off"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
|
||||||
@@ -374,7 +373,7 @@
|
|||||||
title="{% trans 'Create New User' %}"><span>{% trans "Create New User" %}</span></a>
|
title="{% trans 'Create New User' %}"><span>{% trans "Create New User" %}</span></a>
|
||||||
</li>
|
</li>
|
||||||
<li class="listUsers"><a href="{% url 'listUsers' %}"
|
<li class="listUsers"><a href="{% url 'listUsers' %}"
|
||||||
title="{% trans 'List Users' %}"><span>{% trans "List Users" %}</span></a>
|
title="{% trans 'List Users' %}"><span>{% trans "List Users" %}</span></a>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="{% url 'modifyUsers' %}"
|
<li><a href="{% url 'modifyUsers' %}"
|
||||||
title="{% trans 'Modify User' %}"><span>{% trans "Modify User" %}</span></a></li>
|
title="{% trans 'Modify User' %}"><span>{% trans "Modify User" %}</span></a></li>
|
||||||
@@ -437,7 +436,7 @@
|
|||||||
title="{% trans 'Create Package' %}"><span>{% trans "Create Package" %}</span></a>
|
title="{% trans 'Create Package' %}"><span>{% trans "Create Package" %}</span></a>
|
||||||
</li>
|
</li>
|
||||||
<li class="listPackages"><a href="{% url 'listPackages' %}"
|
<li class="listPackages"><a href="{% url 'listPackages' %}"
|
||||||
title="{% trans 'List Packages' %}"><span>{% trans "List Packages" %}</span></a>
|
title="{% trans 'List Packages' %}"><span>{% trans "List Packages" %}</span></a>
|
||||||
</li>
|
</li>
|
||||||
<li class="deletePackage"><a href="{% url 'deletePackage' %}"
|
<li class="deletePackage"><a href="{% url 'deletePackage' %}"
|
||||||
title="{% trans 'Delete Package' %}"><span>{% trans "Delete Package" %}</span></a>
|
title="{% trans 'Delete Package' %}"><span>{% trans "Delete Package" %}</span></a>
|
||||||
@@ -486,8 +485,8 @@
|
|||||||
<li class="createNameServer"><a href="{% url 'createNameserver' %}"
|
<li class="createNameServer"><a href="{% url 'createNameserver' %}"
|
||||||
title="{% trans 'Create Nameserver' %}"><span>{% trans "Create Nameserver" %}</span></a>
|
title="{% trans 'Create Nameserver' %}"><span>{% trans "Create Nameserver" %}</span></a>
|
||||||
</li>
|
</li>
|
||||||
<!--<li class="createNameServer"><a href="{% url 'configureDefaultNameServers' %}"
|
<li class="serverACL"><a href="{% url 'configureDefaultNameServers' %}"
|
||||||
title="{% trans 'Configure Default Nameservers' %}"><span>{% trans "CConfigure Default Nameservers" %}</span></a>-->
|
title="{% trans 'Configure Default Nameservers' %}"><span>{% trans "Config Default Nameservers" %}</span></a>
|
||||||
</li>
|
</li>
|
||||||
<li class="createDNSZone"><a href="{% url 'createDNSZone' %}"
|
<li class="createDNSZone"><a href="{% url 'createDNSZone' %}"
|
||||||
title="{% trans 'Create DNS Zone' %}"><span>{% trans "Create DNS Zone" %}</span></a>
|
title="{% trans 'Create DNS Zone' %}"><span>{% trans "Create DNS Zone" %}</span></a>
|
||||||
@@ -515,7 +514,7 @@
|
|||||||
title="{% trans 'Create Email Account' %}"><span>{% trans "Create Email" %}</span></a>
|
title="{% trans 'Create Email Account' %}"><span>{% trans "Create Email" %}</span></a>
|
||||||
</li>
|
</li>
|
||||||
<li class="listEmails"><a href="{% url 'listEmails' %}"
|
<li class="listEmails"><a href="{% url 'listEmails' %}"
|
||||||
title="{% trans 'List Emails' %}"><span>{% trans "List Emails" %}</span></a>
|
title="{% trans 'List Emails' %}"><span>{% trans "List Emails" %}</span></a>
|
||||||
</li>
|
</li>
|
||||||
<li class="deleteEmail"><a href="{% url 'deleteEmailAccount' %}"
|
<li class="deleteEmail"><a href="{% url 'deleteEmailAccount' %}"
|
||||||
title="{% trans 'Delete Email Account' %}"><span>{% trans "Delete Email" %}</span></a>
|
title="{% trans 'Delete Email Account' %}"><span>{% trans "Delete Email" %}</span></a>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ from plogical.acl import ACLManager
|
|||||||
from manageServices.models import PDNSStatus
|
from manageServices.models import PDNSStatus
|
||||||
|
|
||||||
class DNSManager:
|
class DNSManager:
|
||||||
|
defaultNameServersPath = '/home/cyberpanel/defaultNameservers'
|
||||||
|
|
||||||
def loadDNSHome(self, request = None, userID = None):
|
def loadDNSHome(self, request = None, userID = None):
|
||||||
try:
|
try:
|
||||||
@@ -495,15 +496,79 @@ class DNSManager:
|
|||||||
try:
|
try:
|
||||||
currentACL = ACLManager.loadedACL(userID)
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
|
|
||||||
if ACLManager.currentContextPermission(currentACL, 'deleteZone') == 0:
|
if currentACL['admin'] == 1:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
return ACLManager.loadError()
|
return ACLManager.loadError()
|
||||||
|
|
||||||
if not os.path.exists('/home/cyberpanel/powerdns'):
|
if not os.path.exists('/home/cyberpanel/powerdns'):
|
||||||
return render(request, 'dns/addDeleteDNSRecords.html', {"status": 0})
|
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:
|
except BaseException, msg:
|
||||||
return HttpResponse(str(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)
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
{% extends "baseTemplate/index.html" %}
|
{% extends "baseTemplate/index.html" %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% block title %}{% trans "Create Nameserver - CyberPanel" %}{% endblock %}
|
{% block title %}{% trans "Configure Default Nameserver - CyberPanel" %}{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% load static %}
|
{% load static %}
|
||||||
@@ -9,13 +9,13 @@
|
|||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div id="page-title">
|
<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>
|
<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>
|
||||||
<div ng-controller="createNameserver" class="panel">
|
<div ng-controller="configureDefaultNameservers" class="panel">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<h3 class="content-box-header">
|
<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>
|
</h3>
|
||||||
<div class="example-box-wrapper">
|
<div class="example-box-wrapper">
|
||||||
|
|
||||||
@@ -32,19 +32,9 @@
|
|||||||
|
|
||||||
<form action="/" class="form-horizontal bordered-row panel-body">
|
<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">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label">{% trans "First Nameserver" %}</label>
|
<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>
|
<input name="firstNS" type="text" class="form-control" ng-model="firstNS" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -52,64 +42,33 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label">{% trans "IP Address" %}</label>
|
<label class="col-sm-3 control-label">{% trans "Second Nameserver" %}</label>
|
||||||
<div class="col-sm-6">
|
<div ng-init="secondNS='{{ secondNS }}'" 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">
|
|
||||||
<input name="secondNS" type="text" class="form-control" ng-model="secondNS" required>
|
<input name="secondNS" type="text" class="form-control" ng-model="secondNS" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="current-pack">ns2.example.com</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label">{% trans "IP Address" %}</label>
|
<label class="col-sm-3 control-label">{% trans "Third Nameserver" %} </label>
|
||||||
<div class="col-sm-6">
|
<div ng-init="thirdNS='{{ thirdNS }}'" class="col-sm-6">
|
||||||
<input name="secondNSIP" type="text" class="form-control" ng-model="secondNSIP" required>
|
<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>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label"></label>
|
<label class="col-sm-3 control-label"></label>
|
||||||
<div class="col-sm-4">
|
<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>
|
</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>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,4 +16,5 @@ urlpatterns = [
|
|||||||
url(r'^deleteDNSRecord',views.deleteDNSRecord,name='deleteDNSRecord'),
|
url(r'^deleteDNSRecord',views.deleteDNSRecord,name='deleteDNSRecord'),
|
||||||
url(r'^deleteDNSZone',views.deleteDNSZone,name='deleteDNSZone'),
|
url(r'^deleteDNSZone',views.deleteDNSZone,name='deleteDNSZone'),
|
||||||
url(r'^submitZoneDeletion',views.submitZoneDeletion,name='submitZoneDeletion'),
|
url(r'^submitZoneDeletion',views.submitZoneDeletion,name='submitZoneDeletion'),
|
||||||
|
url(r'^saveNSConfigurations$', views.saveNSConfigurations, name='saveNSConfigurations'),
|
||||||
]
|
]
|
||||||
@@ -161,6 +161,15 @@ def configureDefaultNameServers(request):
|
|||||||
return redirect(loadLoginPage)
|
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) {
|
$scope.cAction = function (action) {
|
||||||
$('#actionLoading').show();
|
$('#actionLoading').show();
|
||||||
console.log($scope.cName)
|
|
||||||
url = "/docker/doContainerAction";
|
url = "/docker/doContainerAction";
|
||||||
var data = {name: $scope.cName, action: action};
|
var data = {name: $scope.cName, action: action};
|
||||||
var config = {
|
var config = {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ class DNS:
|
|||||||
nsd_base = "/etc/nsd/nsd.conf"
|
nsd_base = "/etc/nsd/nsd.conf"
|
||||||
zones_base_dir = "/usr/local/lsws/conf/zones/"
|
zones_base_dir = "/usr/local/lsws/conf/zones/"
|
||||||
create_zone_dir = "/usr/local/lsws/conf/zones"
|
create_zone_dir = "/usr/local/lsws/conf/zones"
|
||||||
|
defaultNameServersPath = '/home/cyberpanel/defaultNameservers'
|
||||||
|
|
||||||
## DNS Functions
|
## DNS Functions
|
||||||
|
|
||||||
@@ -82,27 +83,42 @@ class DNS:
|
|||||||
auth=1)
|
auth=1)
|
||||||
record.save()
|
record.save()
|
||||||
|
|
||||||
record = Records(domainOwner=zone,
|
if os.path.exists(DNS.defaultNameServersPath):
|
||||||
domain_id=zone.id,
|
defaultNS = open(DNS.defaultNameServersPath, 'r').readlines()
|
||||||
name=topLevelDomain,
|
|
||||||
type="NS",
|
|
||||||
content='ns1.%s' % (topLevelDomain),
|
|
||||||
ttl=3600,
|
|
||||||
prio=0,
|
|
||||||
disabled=0,
|
|
||||||
auth=1)
|
|
||||||
record.save()
|
|
||||||
|
|
||||||
record = Records(domainOwner=zone,
|
for items in defaultNS:
|
||||||
domain_id=zone.id,
|
record = Records(domainOwner=zone,
|
||||||
name=topLevelDomain,
|
domain_id=zone.id,
|
||||||
type="NS",
|
name=topLevelDomain,
|
||||||
content='ns2.%s' % (topLevelDomain),
|
type="NS",
|
||||||
ttl=3600,
|
content=items,
|
||||||
prio=0,
|
ttl=3600,
|
||||||
disabled=0,
|
prio=0,
|
||||||
auth=1)
|
disabled=0,
|
||||||
record.save()
|
auth=1)
|
||||||
|
record.save()
|
||||||
|
else:
|
||||||
|
record = Records(domainOwner=zone,
|
||||||
|
domain_id=zone.id,
|
||||||
|
name=topLevelDomain,
|
||||||
|
type="NS",
|
||||||
|
content='ns1.%s' % (topLevelDomain),
|
||||||
|
ttl=3600,
|
||||||
|
prio=0,
|
||||||
|
disabled=0,
|
||||||
|
auth=1)
|
||||||
|
record.save()
|
||||||
|
|
||||||
|
record = Records(domainOwner=zone,
|
||||||
|
domain_id=zone.id,
|
||||||
|
name=topLevelDomain,
|
||||||
|
type="NS",
|
||||||
|
content='ns2.%s' % (topLevelDomain),
|
||||||
|
ttl=3600,
|
||||||
|
prio=0,
|
||||||
|
disabled=0,
|
||||||
|
auth=1)
|
||||||
|
record.save()
|
||||||
|
|
||||||
content = "ns1." + topLevelDomain + " hostmaster." + topLevelDomain + " 1 10800 3600 604800 3600"
|
content = "ns1." + topLevelDomain + " hostmaster." + topLevelDomain + " 1 10800 3600 604800 3600"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user