mirror of
https://github.com/YunoHost-Apps/hotspot_ynh.git
synced 2024-09-03 19:25:53 +02:00
wifi_ssid, ip6_net and ip4_nat_prefix uniqueness now checked
This commit is contained in:
parent
50522f8136
commit
ae4988d05b
3 changed files with 26 additions and 14 deletions
2
TODO
2
TODO
|
@ -2,7 +2,5 @@
|
|||
|
||||
* multissid
|
||||
** WEB: update is_connected_through_hotspot feature
|
||||
** WEB: check if ipv6 delgated prefixes and ipv4 nat prefixes are unique
|
||||
** WEB: fix the now broken wifiparty button
|
||||
** INIT: differentiate ipv6 and ipv4 in is_dhcpd_running
|
||||
** INIT: use insserv instead of update-rc.d and update service dependencies
|
||||
|
|
|
@ -151,6 +151,9 @@ dispatch_put('/settings', function() {
|
|||
|
||||
$wifi_device_exists = ($retcode == 0);
|
||||
$service_enabled = isset($_POST['service_enabled']) ? 1 : 0;
|
||||
$wifi_ssid_uniqueness = array();
|
||||
$ip4_nat_prefix_uniqueness = array();
|
||||
$ip6_net_uniqueness = array();
|
||||
$ssids = array();
|
||||
$id = 0;
|
||||
|
||||
|
@ -167,6 +170,24 @@ dispatch_put('/settings', function() {
|
|||
$ssid['wifi_passphrase'] = 'none';
|
||||
}
|
||||
|
||||
if(in_array($ssid['wifi_ssid'], $wifi_ssid_uniqueness)) {
|
||||
throw new Exception(T_('All Wifi names must be unique'));
|
||||
} else {
|
||||
array_push($wifi_ssid_uniqueness, $ssid['wifi_ssid']);
|
||||
}
|
||||
|
||||
if(in_array($ssid['ip4_nat_prefix'], $ip4_nat_prefix_uniqueness)) {
|
||||
throw new Exception(T_('All IPv4 NAT prefixes must be unique'));
|
||||
} else {
|
||||
array_push($ip4_nat_prefix_uniqueness, $ssid['ip4_nat_prefix']);
|
||||
}
|
||||
|
||||
if($ssid['ip6_net'] != 'none' && in_array($ssid['ip6_net'], $ip6_net_uniqueness)) {
|
||||
throw new Exception(T_('All IPv6 delegated prefixes must be unique'));
|
||||
} else {
|
||||
array_push($ip6_net_uniqueness, $ssid['ip6_net']);
|
||||
}
|
||||
|
||||
if(empty($ssid['wifi_ssid']) || empty($ssid['wifi_passphrase'])) {
|
||||
throw new Exception(T_('Your Wifi Hotspot needs a name and a password'));
|
||||
}
|
||||
|
@ -236,7 +257,7 @@ dispatch_put('/settings', function() {
|
|||
array_push($ssids, $ssid);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
flash('error', T_('SSID')." $id: ".$e->getMessage().' ('.T_('configuration not updated').').');
|
||||
flash('error', T_('Hotspot')." $id: ".$e->getMessage().' ('.T_('configuration not updated').').');
|
||||
goto redirect;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ function tabsClick() {
|
|||
return false;
|
||||
}
|
||||
|
||||
function dropDownClick() {
|
||||
function deviceDropDownClick() {
|
||||
var menu = $(this).parent();
|
||||
var items = menu.children();
|
||||
var button = menu.prev();
|
||||
|
@ -50,6 +50,8 @@ function dropDownClick() {
|
|||
button.append(' <span class="caret"></span>');
|
||||
|
||||
input.val($(this).text());
|
||||
|
||||
updateNbSsidRemaining();
|
||||
}
|
||||
|
||||
function updateNbSsidRemaining() {
|
||||
|
@ -95,7 +97,7 @@ $(document).ready(function() {
|
|||
$('.btn-group').button();
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
|
||||
$('.dropdown-menu li').click(dropDownClick);
|
||||
$('.dropdown-menu li').click(deviceDropDownClick);
|
||||
|
||||
$('.switch').bootstrapToggle();
|
||||
|
||||
|
@ -177,14 +179,6 @@ $(document).ready(function() {
|
|||
var clone = $('#ssids').children().first().clone();
|
||||
var id = parseInt($('.ssid').length);
|
||||
|
||||
clone.find('.dropdownmenu').each(function(i) {
|
||||
var initial = $('#ssids').children().first().find('.dropdownmenu');
|
||||
var clone = initial.eq(i).clone(true, true);
|
||||
|
||||
$(this).after(clone);
|
||||
$(this).remove();
|
||||
});
|
||||
|
||||
clone.find('[name]').each(function() {
|
||||
$(this).attr('name', $(this).attr('name').replace('[0]', '[' + id + ']'));
|
||||
});
|
||||
|
@ -221,7 +215,6 @@ $(document).ready(function() {
|
|||
clone.find('.switch').bootstrapToggle();
|
||||
clone.find('.wifi_secure').change(wifiSecureBtn);
|
||||
clone.find('.nav-tabs a').click(tabsClick);
|
||||
clone.find('.dropdown-menu li').click(dropDownClick);
|
||||
clone.find('.wifi_passphrase').hide();
|
||||
|
||||
clone.find('h3').each(function() {
|
||||
|
|
Loading…
Add table
Reference in a new issue