Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alt gateway in DHCP #731

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions package/gargoyle-i18n/files/www/languages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><%~ LMSect %></h3>
</div>
<div class="panel-body">
<span>
<img src="i18n/graphics/globe-and-flags.png" width='80px' height='84px' />
Expand Down
7 changes: 6 additions & 1 deletion package/gargoyle/files/www/about.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<div class="col-lg-12">
<div class="panel panel-default">

<div class="panel-heading">
<h3 class="panel-title"><%~ CSect %></h3>
</div>
<div class="panel-body">
<p><span class="contributer">Eric Bishop (<a href="http://gargoyle-router.com">gargoyle-router.com</a>):</span> <%~ EBishop %></p>

Expand Down Expand Up @@ -44,12 +47,14 @@

</div>

<h1 class="page-header"><%~ LSect %></h1>
<div class="row">

<div class="col-lg-12">
<div class="panel panel-default">

<div class="panel-heading">
<h3 class="panel-title"><%~ LSect %></h3>
</div>
<div class="panel-body">
<h3>Gargoyle is copyright &copy; 2008-2016 by Eric Bishop</h3>

Expand Down
3 changes: 3 additions & 0 deletions package/gargoyle/files/www/connlimits.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
<div class="row">
<div class="col-lg-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><%~ CLSect %></h3>
</div>
<div class="panel-body">
<div class="row form-group">
<label class="col-xs-5" for="max_connections" id="max_connections_label"><%~ MaxC %>:</label>
Expand Down
3 changes: 3 additions & 0 deletions package/gargoyle/files/www/conntrack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><%~ CCSect %></h3>
</div>
<div class="panel-body">
<div class="row form-group">
<label class="col-xs-5" for="refresh_rate"><%~ RRate %>:</label>
Expand Down
28 changes: 23 additions & 5 deletions package/gargoyle/files/www/dhcp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
echo "var dhcpEnabled = true;"
echo "var subnet=\"$subnet\";"
echo "var dhcpSection = getDhcpSection(uciOriginal);"

echo "var hostData = new Array();"
if [ -e /etc/hosts ] ; then
awk ' $0 ~ /^[\t ]*[0-9]/ {print "hostData.push([\""$1"\",\""$2"\"]);"};' /etc/hosts
Expand Down Expand Up @@ -61,11 +61,14 @@ for (etherIndex in etherData)
<div class="row">
<div class="col-lg-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><%~ dhcp.DHCPstp %></h3>
</div>
<div class="panel-body">
<div class="row form-group" id="dhcp_enabled_container">
<span class="col-xs-12">
<input type="checkbox" id="dhcp_enabled" onclick="setEnabled(this.checked)" />
<label id="dhcp_enabled_label" for="dhcp_enabled"><%~ dhcp.SrvE %></label>
<label id="dhcp_enabled_label" for="dhcp_enabled"><%~ SrvE %></label>
</span>
</div>

Expand All @@ -89,14 +92,29 @@ for (etherIndex in etherData)
</span>
</div>

<div id="alt_gateway_check_container" class="row form-group">
<span class="col-xs-12">
<input type="checkbox" id="dhcp_use_alt_gateway" onclick="enableAssociatedField(this, 'alt_gateway', defaultAltGateway)"/>
<label id="dhcp_alt_gateway_label" for="dhcp_use_alt_gateway"><%~ UseAltGW %>:</label>
</span>
</div>

<div id="alt_gateway_container" class="row form-group">
<label class="col-xs-5" for="alt_gateway" id="alt_gateway_label"><%~ AltGW %>:</label>
<span class="col-xs-7">
<% echo -n "$subnet" %>
<input type="text" class="form-control" id="alt_gateway" onkeyup="proofreadNumeric(this)" size="5" maxlength="3" />
</span>
</div>

<div id="dhcp_lease_container" class="row form-group">
<label class="col-xs-5" for="dhcp_lease" id="dhcp_lease_label"><%~ LsTm %>:</label>
<span class="col-xs-7">
<input type="text" class="form-control" onkeyup="proofreadNumeric(this)" id="dhcp_lease" size="5" maxlength="4" />
<em>(<%~ hours %>)</em>
<input type="text" class="form-control" onkeyup="proofreadNumeric(this)" id="dhcp_lease" size="5" maxlength="5" />
<em>(<%~ minutes %>)</em>
</span>
</div>

</div>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions package/gargoyle/files/www/identification.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
<div class="row">
<div class="col-lg-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><%~ IdSect %></h3>
</div>
<div class="panel-body">
<div class="row form-group">
<label class="col-xs-5" for="hostname" id="hostname_label"><%~ HsNm %></label>
Expand Down
2 changes: 1 addition & 1 deletion package/gargoyle/files/www/js/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var openDnsFS = ["208.67.222.123", "208.67.220.123" ];
var nortonCSA = ["199.85.126.10", "199.85.127.10" ];
var nortonCSB = ["199.85.126.20", "199.85.127.20" ];
var nortonCSC = ["199.85.126.30", "199.85.127.30" ];
var quad9DNS = ["9.9.9.9" ];
var quad9DNS = ["9.9.9.9", "149.112.112.112" ];

var ncDns = [ "178.32.31.41", "106.187.47.17", "176.58.118.172" ]
var onDns = [ "66.244.95.20", "95.211.32.162", "95.142.171.235" ]
Expand Down
89 changes: 66 additions & 23 deletions package/gargoyle/files/www/js/dhcp.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ function saveChanges()
else
{
setControlsEnabled(false, true);

uci = uciOriginal.clone();
uci.remove('dhcp', dhcpSection, 'ignore');
uci.remove('dhcp', dhcpSection, 'dhcp_option');
uci.set('dhcp', dhcpSection, 'interface', 'lan');
dhcpIds = ['dhcp_start', ['dhcp_start','dhcp_end'], 'dhcp_lease'];
dhcpVisIds = ['dhcp_start', 'dhcp_end', 'dhcp_lease'];
Expand All @@ -32,13 +33,18 @@ function saveChanges()

dhcpFunctions = [setVariableFromValue, setVariableFromCombined, setVariableFromModifiedValue];
limitParams = [false, function(values){ return (parseInt(values[1]) - parseInt(values[0]) + 1); }];
leaseParams = [false, function(value){ return value + "h"; }];
leaseParams = [false, function(value){ return value + "m"; }];
dhcpParams = [false, limitParams,leaseParams];

setVariables(dhcpIds, dhcpVisIds, uci, dhcpPkgs, dhcpSections, dhcpOptions, dhcpFunctions, dhcpParams);


if(document.getElementById("dhcp_use_alt_gateway").checked && document.getElementById('alt_gateway').value != defaultAltGateway)
{
uci.set('dhcp', dhcpSection, 'dhcp_option', '3,' + subnet + document.getElementById('alt_gateway').value)
}

dhcpWillBeEnabled = true;
if(document.getElementById("dhcp_enabled").checked )
if (document.getElementById("dhcp_enabled").checked )
{
uci.remove("dhcp", "lan", "ignore");
}
Expand Down Expand Up @@ -148,40 +154,55 @@ function resetData()
tableContainer.appendChild(staticIpTable);


dhcpIds = ['dhcp_start', 'dhcp_end', 'dhcp_lease'];
dhcpPkgs = ['dhcp',['dhcp','dhcp'],'dhcp'];
dhcpSections = [dhcpSection,[dhcpSection,dhcpSection],dhcpSection];
dhcpOptions = ['start', ['start','limit'], 'leasetime'];
dhcpIds = ['dhcp_start', 'dhcp_end', 'dhcp_lease', 'dhcp_use_alt_gateway', 'alt_gateway'];
dhcpPkgs = ['dhcp',['dhcp','dhcp'],'dhcp','dhcp','dhcp'];
dhcpSections = [dhcpSection,[dhcpSection,dhcpSection],dhcpSection,dhcpSection,dhcpSection];
dhcpOptions = ['start', ['start','limit'], 'leasetime', 'dhcp_option', 'dhcp_option'];

defaultAltGateway = ((uciOriginal.get("network", "lan", "ipaddr")).split("."))[3];
enabledTest = function(value){return value != 1;};
endCombineFunc= function(values) { return (parseInt(values[0])+parseInt(values[1])-1); };
useAltGatewayTest=function(v){v = (v== null ? '' : (v.split(","))[0]); return (v=='' || v!='3' ? false : true);};
leaseModFunc = function(value)
{
var leaseHourValue;
var leaseMinValue;
if(value.match(/.*h/))
{
leaseHourValue=value.substr(0,value.length-1);
leaseMinValue=value.substr(0,value.length-1)*60;
}
else if(value.match(/.*m/))
{
leaseHourValue=value.substr(0,value.length-1)/(60);
leaseMinValue=value.substr(0,value.length-1);
}
else if(value.match(/.*s/))
{
leaseHourValue=value.substr(0,value.length-1)/(60*60);
leaseMinValue=value.substr(0,value.length-1)/(60);
}
return leaseHourValue;
return leaseMinValue;
};
GWModFunc = function(v)
{
v = (v== null ? '' : v.split(","));
v = (v.length < 2 ? '' : v[1].split("."));
v = (v.length < 4 ? '' : v[3]);
if (v!='')
{
v = (parseInt(v) < 1 || parseInt(v) > 254 ? '' : v);
}
return v;
};

dhcpParams = [100, [endCombineFunc,150],[12,leaseModFunc]];
dhcpFunctions = [loadValueFromVariable, loadValueFromMultipleVariables, loadValueFromModifiedVariable];
dhcpParams = [100, [endCombineFunc,150],[720,leaseModFunc], useAltGatewayTest, [defaultAltGateway,GWModFunc]];
dhcpFunctions = [loadValueFromVariable, loadValueFromMultipleVariables, loadValueFromModifiedVariable, loadChecked, loadValueFromModifiedVariable];

loadVariables(uciOriginal, dhcpIds, dhcpPkgs, dhcpSections, dhcpOptions, dhcpParams, dhcpFunctions);


document.getElementById("dhcp_enabled").checked = dhcpEnabled;
setEnabled(document.getElementById('dhcp_enabled').checked);

enableAssociatedField(document.getElementById('dhcp_use_alt_gateway'), 'alt_gateway', defaultAltGateway);


var firewallDefaultSections = uciOriginal.getAllSectionsOfType("firewall", "defaults");
var blockMismatches = uciOriginal.get("firewall", firewallDefaultSections[0], "enforce_dhcp_assignments") == "1" ? true : false;
document.getElementById("block_mismatches").checked = blockMismatches;
Expand Down Expand Up @@ -249,20 +270,20 @@ function staticFromConnected()

function setEnabled(enabled)
{
var ids=['dhcp_start', 'dhcp_end', 'dhcp_lease', 'block_mismatches', 'add_host', 'add_mac', 'add_ip', 'add_button'];
var ids=['dhcp_start', 'dhcp_end', 'dhcp_use_alt_gateway', 'alt_gateway', 'dhcp_lease', 'block_mismatches', 'add_host', 'add_mac', 'add_ip', 'add_button'];
var altgwchk = document.getElementById('dhcp_use_alt_gateway').checked;
var idIndex;
for (idIndex in ids)
{
var element = document.getElementById(ids[idIndex]);
setElementEnabled(element, enabled, "");
setElementEnabled(element, (element.id == 'alt_gateway' ? altgwchk && enabled : enabled), (element.type == 'text' ? element.value : ''));
}

var staticIpTable = document.getElementById('staticip_table_container').firstChild;
setRowClasses(staticIpTable, enabled);

resetHostnameMacList();


}

function addStatic()
Expand Down Expand Up @@ -348,10 +369,10 @@ function proofreadStatic(controlDocument, tableDocument, excludeRow)

function proofreadAll()
{
dhcpIds = ['dhcp_start', 'dhcp_end', 'dhcp_lease'];
labelIds= ['dhcp_start_label', 'dhcp_end_label', 'dhcp_lease_label'];
functions = [validateNumeric, validateNumeric, validateNumeric];
returnCodes = [0,0,0];
dhcpIds = ['dhcp_start', 'dhcp_end', 'dhcp_lease', 'alt_gateway'];
labelIds= ['dhcp_start_label', 'dhcp_end_label', 'dhcp_lease_label', 'alt_gateway_label'];
functions = [validateNumeric, validateNumeric, validateNumeric, validateNumeric];
returnCodes = [0,0,0,0];
visibilityIds= dhcpIds;
errors = proofreadFields(dhcpIds, labelIds, functions, returnCodes, visibilityIds);

Expand All @@ -363,16 +384,38 @@ function proofreadAll()
var ip = uciOriginal.get("network", "lan", "ipaddr");
var start = parseInt(document.getElementById("dhcp_start").value);
var end = parseInt(document.getElementById("dhcp_end").value );
var gate = parseInt(document.getElementById("alt_gateway").value );
var lease = parseInt(document.getElementById("dhcp_lease").value );

if(!rangeInSubnet(mask, ip, start, end))
{
errors.push(dhcpS.dsubErr);
}

if(lease < 1 || lease > 71582788)
{
errors.push(dhcpS.leaseERR);
}

var ipEnd = parseInt( (ip.split("."))[3] );

if(ipEnd >= start && ipEnd <= end)
{
errors.push(dhcpS.dipErr);
}

if(document.getElementById("dhcp_use_alt_gateway").checked)
{
var range = getSubnetRange(mask, ip);
if(gate <= range[0] || gate >= range[1])
{
errors.push(dhcpS.rangeGWErr);
}
if(gate >= start && gate <= end)
{
errors.push(dhcpS.leaseGWErr);
}
}
}

return errors;
Expand Down
5 changes: 4 additions & 1 deletion package/gargoyle/files/www/login.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ var passInvalid = false;

<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><%~ LSect %></h3>
</div>
<div class="panel-body">
<div class="row form-group">
<label class="sr-only" for="password" id="password_label"><%~ EAdmP %></label>
Expand Down
3 changes: 3 additions & 0 deletions package/gargoyle/files/www/time.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
<div class="row">
<div class="col-lg-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><%~ Section %></h3>
</div>
<div class="panel-body">
<div class="row form-group">
<label class="col-xs-5" id="current_time_label" for="current_time"><%~ CurrTime %>:</label>
Expand Down
3 changes: 3 additions & 0 deletions package/gargoyle/files/www/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
<div id="upgrade_section" class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><%~ UpFrm %></h3>
</div>
<div class="panel-body">
<div class="row form-group">
<div class="col-lg-12">
Expand Down
4 changes: 3 additions & 1 deletion package/gargoyle/files/www/wol.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ var arpLines;

<div class="col-lg-12">
<div class="panel panel-default">

<div class="panel-heading">
<h3 class="panel-title"><%~ WLSect %></h3>
</div>
<div class="panel-body">
<div id="wol_table_container" class="table-responsive"></div>

Expand Down
5 changes: 4 additions & 1 deletion package/plugin-gargoyle-adblock/files/www/ablock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
<h1 class="page-header"><%~ ablock.Adblock %></h1>
<div class="row">
<div class="col-lg-6">
<div class="panel panel-default">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><%~ Adblock %></h3>
</div>
<div class="panel-body">
<div class="row form-group">
<span class="col-xs-12">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ for (tab_idx in cron_data) {
<label class="col-xs-5 col-sm-3" id="bandwidthIntervalLabel" for="bandwidthIntervalSelect"><%~ email.BandwidthInterval %></label>
<span class="col-xs-7 col-sm-9">
<select id="bandwidthIntervalSelect" class="form-control" disabled>
<option value="minutes"><%~ email.minutes %></option>
<option value="quarter hours"><%~ email.quarterhours %></option>
<option value="hours"><%~ email.hours %></option>
<option value="days"><%~ email.days %></option>
<option value="minute"><%~ email.minutes %></option>
<option value="900"><%~ email.quarterhours %></option>
<option value="hour"><%~ email.hours %></option>
<option value="day"><%~ email.days %></option>
</select>
</span>

Expand Down
Loading