Skip to content

Commit a7bdf8d

Browse files
committed
Implemented: FS#334 - IPv6 support
Implemented: FS#1113 - Force client to use only allowed IPs
1 parent 92991d5 commit a7bdf8d

File tree

14 files changed

+130
-444
lines changed

14 files changed

+130
-444
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE `web_domain` ADD `ipv6_address` VARCHAR( 255 ) default NULL AFTER `ip_address`;

install/sql/ispconfig3.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,6 +1474,7 @@ CREATE TABLE `web_domain` (
14741474
`sys_perm_other` varchar(5) default NULL,
14751475
`server_id` int(11) unsigned NOT NULL default '0',
14761476
`ip_address` varchar(39) default NULL,
1477+
`ipv6_address` VARCHAR( 255 ) default NULL
14771478
`domain` varchar(255) default NULL,
14781479
`type` varchar(32) default NULL,
14791480
`parent_domain_id` int(11) unsigned NOT NULL default '0',

interface/web/sites/ajax_get_ip.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@
3535
$app->auth->check_module_permissions('sites');
3636

3737
$server_id = intval($_GET["server_id"]);
38+
$client_group_id = intval($_GET["client_group_id"]);
39+
$ip_type = $app->db->quote($_GET['ip_type']);
3840

3941
if($_SESSION["s"]["user"]["typ"] == 'admin') {
4042

41-
$sql = "SELECT ip_address FROM server_ip WHERE server_id = $server_id";
43+
$sql = "SELECT ip_address FROM server_ip WHERE ip_type = '$ip_type' AND server_id = $server_id";
4244
$ips = $app->db->queryAllRecords($sql);
4345
// $ip_select = "<option value=''></option>";
4446
$ip_select = "*";

interface/web/sites/form/web_domain.tform.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,22 @@
8282
'datatype' => 'VARCHAR',
8383
'formtype' => 'SELECT',
8484
'default' => '',
85-
'datasource' => array ( 'type' => 'SQL',
86-
'querystring' => 'SELECT ip_address,ip_address FROM server_ip WHERE {AUTHSQL} ORDER BY ip_address',
85+
/*'datasource' => array ( 'type' => 'SQL',
86+
'querystring' => "SELECT ip_address,ip_address FROM server_ip WHERE ip_type = 'IPv4' AND {AUTHSQL} ORDER BY ip_address",
8787
'keyfield'=> 'ip_address',
8888
'valuefield'=> 'ip_address'
89-
),
89+
),*/
90+
'value' => ''
91+
),
92+
'ipv6_address' => array (
93+
'datatype' => 'VARCHAR',
94+
'formtype' => 'SELECT',
95+
'default' => '',
96+
/*'datasource' => array ( 'type' => 'SQL',
97+
'querystring' => "SELECT ip_address,ip_address FROM server_ip WHERE ip_type = 'IPv6' AND {AUTHSQL} ORDER BY ip_address",
98+
'keyfield'=> 'ip_address',
99+
'valuefield'=> 'ip_address'
100+
),*/
90101
'value' => ''
91102
),
92103
'domain' => array (

interface/web/sites/lib/lang/en_web_domain.lng

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ $wb["active_txt"] = 'Active';
2121
$wb["document_root_txt"] = 'Documentroot';
2222
$wb["system_user_txt"] = 'Linux User';
2323
$wb["system_group_txt"] = 'Linux Group';
24-
$wb["ip_address_txt"] = 'IP-Address';
24+
$wb["ip_address_txt"] = 'IPv4-Address';
25+
$wb["ipv6_address_txt"] = 'IPv6-Address';
2526
$wb["vhost_type_txt"] = 'VHost Type';
2627
$wb["hd_quota_txt"] = 'Harddisk Quota';
2728
$wb["traffic_quota_txt"] = 'Traffic Quota';

interface/web/sites/templates/web_domain_edit.htm

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@ <h2><tmpl_var name="list_head_txt"></h2>
1515
<input type="hidden" name="server_id" value="{tmpl_var name='server_id_value'}" />
1616
<tmpl_else>
1717
<label for="server_id">{tmpl_var name='server_id_txt'}</label>
18-
<select name="server_id" id="server_id" class="selectInput" onChange="loadOptionInto('ip_address','sites/ajax_get_ip.php?server_id='+document.getElementById('server_id').value)">
18+
<select name="server_id" id="server_id" class="selectInput" onChange="reloadWebIP()">
1919
{tmpl_var name='server_id'}
2020
</select>
2121
</tmpl_if>
2222
</div>
2323
<div class="ctrlHolder">
2424
<label for="client_group_id">{tmpl_var name='client_group_id_txt'}</label>
25-
<select name="client_group_id" id="client_group_id" class="selectInput">
25+
<select name="client_group_id" id="client_group_id" class="selectInput" onChange="reloadWebIP()">
2626
{tmpl_var name='client_group_id'}
2727
</select>
2828
</div>
2929
</tmpl_if>
3030
<tmpl_if name="is_reseller">
3131
<div class="ctrlHolder">
3232
<label for="client_group_id">{tmpl_var name='client_group_id_txt'}</label>
33-
<select name="client_group_id" id="client_group_id" class="selectInput">
33+
<select name="client_group_id" id="client_group_id" class="selectInput" onChange="reloadWebIP()">
3434
{tmpl_var name='client_group_id'}
3535
</select>
3636
</div>
@@ -40,6 +40,12 @@ <h2><tmpl_var name="list_head_txt"></h2>
4040
<select name="ip_address" id="ip_address" class="selectInput formLengthIPv4">
4141
{tmpl_var name='ip_address'}
4242
</select>
43+
</div>
44+
<div class="ctrlHolder">
45+
<label for="ipv6_address">{tmpl_var name='ipv6_address_txt'}</label>
46+
<select name="ipv6_address" id="ipv6_address" class="selectInput formLengthIPv4">
47+
{tmpl_var name='ipv6_address'}
48+
</select>
4349
</div>
4450
<div class="ctrlHolder">
4551
<label for="domain">{tmpl_var name='domain_txt'}</label>
@@ -158,5 +164,10 @@ <h2><tmpl_var name="list_head_txt"></h2>
158164
}
159165
});
160166
}
167+
168+
function reloadWebIP() {
169+
loadOptionInto('ip_address','sites/ajax_get_ip.php?ip_type=IPv4&server_id='+document.getElementById('server_id').value)&client_group_id='+document.getElementById('client_group_id').value);
170+
loadOptionInto('ipv6_address','sites/ajax_get_ip.php?ip_type=IPv6&server_id='+document.getElementById('server_id').value)&client_group_id='+document.getElementById('client_group_id').value);
171+
}
161172

162173
</script>

interface/web/sites/web_domain_edit.php

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ function onShowEnd() {
9494
$app->tpl->setVar("server_id","<option value='$client[default_webserver]'>$tmp[server_name]</option>");
9595
unset($tmp);
9696

97-
// Fill the IP select field with the IP addresses that are allowed for this client
98-
$sql = "SELECT ip_address FROM server_ip WHERE server_id = ".$client['default_webserver']." AND client_id=0 OR client_id=".$_SESSION['s']['user']['client_id'];
97+
//* Fill the IPv4 select field with the IP addresses that are allowed for this client
98+
$sql = "SELECT ip_address FROM server_ip WHERE server_id = ".$client['default_webserver']." AND ip_type = 'IPv4' AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
9999
$ips = $app->db->queryAllRecords($sql);
100100
$ip_select = "<option value='*'>*</option>";
101101
//$ip_select = "";
@@ -108,6 +108,21 @@ function onShowEnd() {
108108
$app->tpl->setVar("ip_address",$ip_select);
109109
unset($tmp);
110110
unset($ips);
111+
112+
//* Fill the IPv6 select field with the IP addresses that are allowed for this client
113+
$sql = "SELECT ip_address FROM server_ip WHERE server_id = ".$client['default_webserver']." AND ip_type = 'IPv6' AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
114+
$ips = $app->db->queryAllRecords($sql);
115+
$ip_select = "<option value=''></option>";
116+
//$ip_select = "";
117+
if(is_array($ips)) {
118+
foreach( $ips as $ip) {
119+
$selected = ($ip["ip_address"] == $this->dataRecord["ipv6_address"])?'SELECTED':'';
120+
$ip_select .= "<option value='$ip[ip_address]' $selected>$ip[ip_address]</option>\r\n";
121+
}
122+
}
123+
$app->tpl->setVar("ipv6_address",$ip_select);
124+
unset($tmp);
125+
unset($ips);
111126

112127
//* Reseller: If the logged in user is not admin and has sub clients (is a reseller)
113128
} elseif ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) {
@@ -135,8 +150,8 @@ function onShowEnd() {
135150
}
136151
$app->tpl->setVar("client_group_id",$client_select);
137152

138-
// Fill the IP select field with the IP addresses that are allowed for this client
139-
$sql = "SELECT ip_address FROM server_ip WHERE server_id = ".$client['default_webserver']." AND client_id=0 OR client_id=".$_SESSION['s']['user']['client_id'];
153+
//* Fill the IPv4 select field with the IP addresses that are allowed for this client
154+
$sql = "SELECT ip_address FROM server_ip WHERE server_id = ".$client['default_webserver']." AND ip_type = 'IPv4' AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
140155
$ips = $app->db->queryAllRecords($sql);
141156
$ip_select = "<option value='*'>*</option>";
142157
//$ip_select = "";
@@ -149,6 +164,21 @@ function onShowEnd() {
149164
$app->tpl->setVar("ip_address",$ip_select);
150165
unset($tmp);
151166
unset($ips);
167+
168+
//* Fill the IPv6 select field with the IP addresses that are allowed for this client
169+
$sql = "SELECT ip_address FROM server_ip WHERE server_id = ".$client['default_webserver']." AND ip_type = 'IPv6' AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
170+
$ips = $app->db->queryAllRecords($sql);
171+
$ip_select = "<option value=''></option>";
172+
//$ip_select = "";
173+
if(is_array($ips)) {
174+
foreach( $ips as $ip) {
175+
$selected = ($ip["ip_address"] == $this->dataRecord["ipv6_address"])?'SELECTED':'';
176+
$ip_select .= "<option value='$ip[ip_address]' $selected>$ip[ip_address]</option>\r\n";
177+
}
178+
}
179+
$app->tpl->setVar("ipv6_address",$ip_select);
180+
unset($tmp);
181+
unset($ips);
152182

153183
//* Admin: If the logged in user is admin
154184
} else {
@@ -161,8 +191,9 @@ function onShowEnd() {
161191
$tmp = $app->db->queryOneRecord("SELECT server_id FROM server WHERE web_server = 1 ORDER BY server_name LIMIT 0,1");
162192
$server_id = $tmp['server_id'];
163193
}
164-
165-
$sql = "SELECT ip_address FROM server_ip WHERE server_id = $server_id";
194+
195+
//* Fill the IPv4 select field
196+
$sql = "SELECT ip_address FROM server_ip WHERE ip_type = 'IPv4' AND server_id = $server_id";
166197
$ips = $app->db->queryAllRecords($sql);
167198
$ip_select = "<option value='*'>*</option>";
168199
//$ip_select = "";
@@ -175,6 +206,21 @@ function onShowEnd() {
175206
$app->tpl->setVar("ip_address",$ip_select);
176207
unset($tmp);
177208
unset($ips);
209+
210+
//* Fill the IPv6 select field
211+
$sql = "SELECT ip_address FROM server_ip WHERE ip_type = 'IPv6' AND server_id = $server_id";
212+
$ips = $app->db->queryAllRecords($sql);
213+
$ip_select = "<option value=''></option>";
214+
//$ip_select = "";
215+
if(is_array($ips)) {
216+
foreach( $ips as $ip) {
217+
$selected = ($ip["ip_address"] == $this->dataRecord["ipv6_address"])?'SELECTED':'';
218+
$ip_select .= "<option value='$ip[ip_address]' $selected>$ip[ip_address]</option>\r\n";
219+
}
220+
}
221+
$app->tpl->setVar("ipv6_address",$ip_select);
222+
unset($tmp);
223+
unset($ips);
178224

179225
// Fill the client select field
180226
$sql = "SELECT groupid, name FROM sys_group WHERE client_id > 0 ORDER BY name";

server/conf/nginx_reverseproxy_rewrites.conf.master

Lines changed: 0 additions & 9 deletions
This file was deleted.

server/conf/nginx_reverseproxy_vhost.conf.master

Lines changed: 0 additions & 69 deletions
This file was deleted.

server/conf/ufw.before.rules.master

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)