Merge branch 'udp-port-validations' into 'master'

Make UDP port validations clearer, allow receive port to be 2238 if forwarding...

See merge request gridtracker.org/gridtracker!7
merge-requests/31/head
Paul Traina 2020-10-31 01:14:40 +00:00
commit 1395bd860e
2 zmienionych plików z 19 dodań i 18 usunięć

Wyświetl plik

@ -419,7 +419,7 @@
<td id="multicastTD" style="display:none" >IP <input id="multicastIpInput" type="text" class="inputTextValue" maxlength="15" size="10" onkeypress='return validIpKeys(event.charCode);' oninput=" if ( ValidateMulticast(this) ) setMulticastIp(); "/></td>
</tr>
<tr>
<td>Port <input id="udpPortInput" type="text" class="inputTextValue" maxlength="5" size="5" onkeypress='return validNumberKeys(event.charCode);' oninput="if ( ValidatePort(this,null, CheckNotRemoteIpPort ) ) setUdpPort();" /></td>
<td>Port <input id="udpPortInput" type="text" class="inputTextValue" maxlength="5" size="5" onkeypress='return validNumberKeys(event.charCode);' oninput="if ( ValidatePort(this, null, CheckReceivePortIsNotForwardPort) ) setUdpPort();" /></td>
</tr>
</table>
</div>
@ -434,10 +434,10 @@
<td ><i>e.g. GridTracker on another host</i></td>
</tr>
<tr>
<td >IP <input id="udpForwardIpInput" type="text" class="inputTextValue" maxlength="15" size="10" onkeypress='return validIpKeys(event.charCode);' oninput=" if ( ValidateIPaddress(this,udpForwardEnable) ) setForwardIp(); "/></td>
<td >IP <input id="udpForwardIpInput" type="text" class="inputTextValue" maxlength="15" size="10" onkeypress='return validIpKeys(event.charCode);' oninput=" if ( ValidateIPaddress(this, udpForwardEnable) ) setForwardIp(); "/></td>
</tr>
<tr>
<td >Port <input id="udpForwardPortInput" type="text" class="inputTextValue" maxlength="5" size="5" onkeypress='return validNumberKeys(event.charCode);' oninput="if ( ValidatePort(this,udpForwardEnable, CheckNotLocalPort ) ) setForwardPort(); " /></td>
<td >Port <input id="udpForwardPortInput" type="text" class="inputTextValue" maxlength="5" size="5" onkeypress='return validNumberKeys(event.charCode);' oninput="if ( ValidatePort(this, udpForwardEnable, CheckForwardPortIsNotReceivePort) ) setForwardPort(); " /></td>
</tr>
<tr>
<td> Enabled?<input title="Enable / Disable UDP Message forwarding" type="checkbox" id="udpForwardEnable" onclick="setUdpForwardEnable(this);" /></td>

Wyświetl plik

@ -8924,7 +8924,7 @@ function setMulticastEnable(checkbox) {
function setUdpForwardEnable(checkbox) {
if (checkbox.checked) {
if (ValidatePort(udpForwardPortInput, null, CheckNotLocalPort) && ValidateIPaddress(udpForwardIpInput,
if (ValidatePort(udpForwardPortInput, null, CheckForwardPortIsNotReceivePort) && ValidateIPaddress(udpForwardIpInput,
null)) {
g_appSettings.wsjtForwardUdpEnable = checkbox.checked;
return;
@ -9316,30 +9316,31 @@ function updateBasedOnIni() {
}
}
function CheckNotRemoteIpPort(value) {
if (udpForwardIpInput.value == "127.0.0.1" && udpForwardPortInput.value == value && g_appSettings.wsjtIP == "")
return true;
return false;
function CheckReceivePortIsNotForwardPort(value) {
if (udpForwardIpInput.value == "127.0.0.1" && udpForwardPortInput.value == value && g_appSettings.wsjtIP == "" && udpForwardEnable.checked) {
return false;
}
return true;
}
function CheckNotLocalPort(value) {
function CheckForwardPortIsNotReceivePort(value) {
if (udpForwardIpInput.value == "127.0.0.1" && udpPortInput.value == value && g_appSettings.wsjtIP == "")
return true;
return false;
return false;
return true;
}
function setForwardIp() {
g_appSettings.wsjtForwardUdpIp = udpForwardIpInput.value;
if (ValidatePort(udpPortInput, null, CheckNotRemoteIpPort)) {
if (ValidatePort(udpPortInput, null, CheckReceivePortIsNotForwardPort)) {
setUdpPort();
}
ValidatePort(udpForwardPortInput, null, CheckNotLocalPort);
ValidatePort(udpForwardPortInput, null, CheckForwardPortIsNotReceivePort);
}
function setForwardPort() {
g_appSettings.wsjtForwardUdpPort = udpForwardPortInput.value;
ValidateIPaddress(udpForwardIpInput, null);
if (ValidatePort(udpPortInput, null, CheckNotRemoteIpPort)) {
if (ValidatePort(udpPortInput, null, CheckReceivePortIsNotForwardPort)) {
setUdpPort();
}
}
@ -9606,7 +9607,7 @@ function ValidateIPaddress(inputText, checkBox) {
function ValidatePort(inputText, checkBox, callBackCheck) {
var value = Number(inputText.value);
if (value > 1023 && value < 65536) {
if (callBackCheck && callBackCheck(value)) {
if (callBackCheck && !callBackCheck(value)) {
inputText.style.color = "#FFF";
inputText.style.backgroundColor = "red";
if (checkBox)
@ -11213,9 +11214,9 @@ function loadPortSettings()
multicastIpInput.value = g_appSettings.wsjtIP;
setMulticastEnable(multicastEnable);
udpPortInput.value = g_appSettings.wsjtUdpPort;
ValidatePort(udpPortInput, null, CheckNotRemoteIpPort);
ValidatePort(udpPortInput, null, CheckReceivePortIsNotForwardPort);
udpForwardPortInput.value = g_appSettings.wsjtForwardUdpPort;
ValidatePort(udpForwardPortInput, null, CheckNotLocalPort);
ValidatePort(udpForwardPortInput, null, CheckForwardPortIsNotReceivePort);
udpForwardIpInput.value = g_appSettings.wsjtForwardUdpIp;
ValidateIPaddress(udpForwardIpInput, null);
udpForwardEnable.checked = g_appSettings.wsjtForwardUdpEnable;
@ -11377,7 +11378,7 @@ function checkWsjtxListener() {
g_wsjtCurrentPort = -1;
g_wsjtCurrentIP = "none";
}
updateWsjtxListener(udpPortInput.value);
updateWsjtxListener(g_appSettings.wsjtUdpPort);
}
var g_instances = {};