Merge pull request #52 from dr-dolomite/development-socat

Added Various Changes Ready For Merge
This commit is contained in:
Cameron Thompson
2024-05-14 00:48:43 -04:00
committed by GitHub
6 changed files with 2574 additions and 158 deletions

View File

@@ -0,0 +1,11 @@
#!/bin/bash
# Execute the uptime command and store the result
uptime_output=$(uptime)
# Set header for plain text content
echo "Content-Type: text/plain"
echo ""
# Output the uptime result
echo "$uptime_output"

View File

@@ -92,6 +92,10 @@
<th scope="row">Firmware version</th> <th scope="row">Firmware version</th>
<td class="col-md-2" x-text="firmwareVersion"></td> <td class="col-md-2" x-text="firmwareVersion"></td>
</tr> </tr>
<tr>
<th scope="row">Phone Number</th>
<td class="col-md-2" x-text="phoneNumber"></td>
</tr>
<tr> <tr>
<th scope="row">IMSI</th> <th scope="row">IMSI</th>
<td class="col-md-2" x-text="imsi"></td> <td class="col-md-2" x-text="imsi"></td>
@@ -135,7 +139,7 @@
</tr> </tr>
<tr> <tr>
<th scope="row">Simple Admin Version</th> <th scope="row">Simple Admin Version</th>
<td class="col-md-2">SimpleAdminRev-Alpha-0.5</td> <td class="col-md-2">SimpleAdminRev-Alpha-0.7</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@@ -225,6 +229,7 @@
lanIp: "-", lanIp: "-",
wwanIpv4: "-", wwanIpv4: "-",
wwanIpv6: "-", wwanIpv6: "-",
phoneNumber: "Unknown",
simpleAdminVersion: "-", simpleAdminVersion: "-",
atcmd: null, atcmd: null,
atCommandResponse: "", atCommandResponse: "",
@@ -262,7 +267,7 @@
fetchATCommand() { fetchATCommand() {
this.atcmd = this.atcmd =
'AT+CGMI;+CGMM;+QGMR;+CIMI;+ICCID;+CGSN;+QMAP="LANIP";+QMAP="WWAN"'; 'AT+CGMI;+CGMM;+QGMR;+CIMI;+ICCID;+CGSN;+QMAP="LANIP";+QMAP="WWAN";+CNUM';
this.isLoading = true; this.isLoading = true;
fetch( fetch(
"/cgi-bin/get_atcommand?" + "/cgi-bin/get_atcommand?" +
@@ -297,7 +302,13 @@
this.lanIp = lines[13].trim().split(",")[3]; this.lanIp = lines[13].trim().split(",")[3];
this.wwanIpv4 = lines[15].trim().split(",")[4].replace(/"/g, ""); this.wwanIpv4 = lines[15].trim().split(",")[4].replace(/"/g, "");
this.wwanIpv6 = lines[16].trim().split(",")[4].replace(/"/g, ""); this.wwanIpv6 = lines[16].trim().split(",")[4].replace(/"/g, "");
this.simpleAdminVersion = "SimpleAdminRev-Alpha-0.5"; this.phoneNumber = lines[18].trim().split(",")[1].replace(/"/g, "");
if (this.phoneNumber === "") {
this.phoneNumber = "Unknown";
}
this.simpleAdminVersion = "SimpleAdminRev-Alpha-0.6";
this.isLoading = false; this.isLoading = false;
}, },

View File

@@ -202,6 +202,10 @@
<th scope="row">IPv<sup>6</sup></th> <th scope="row">IPv<sup>6</sup></th>
<td x-text="ipv6"></td> <td x-text="ipv6"></td>
</tr> </tr>
<tr>
<th scope="row">Uptime</th>
<td x-text="uptime"></td>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>
@@ -611,6 +615,7 @@
newRefreshRate: null, newRefreshRate: null,
refreshRate: 3, refreshRate: 3,
intervalId: null, intervalId: null,
uptime: "Unknown",
fetchNetworkInfo() { fetchNetworkInfo() {
this.atcmd = this.atcmd =
'AT+QTEMP;+QUIMSLOT?;+QSPN;+CGCONTRDP=1;+QMAP="WWANIP";+QENG="servingcell";+QCAINFO'; 'AT+QTEMP;+QUIMSLOT?;+QSPN;+CGCONTRDP=1;+QMAP="WWANIP";+QENG="servingcell";+QCAINFO';
@@ -1004,7 +1009,9 @@
// Calculate the NR bandwidth // Calculate the NR bandwidth
this.bandwidth += this.bandwidth +=
" / NR " + this.calculate_nr_bw(nr_bw).toString() + " MHz"; " / NR " +
this.calculate_nr_bw(nr_bw).toString() +
" MHz";
// Parse the PCIs // Parse the PCIs
this.pcc_pci = lines[28].split(",")[5].replace(/"/g, ""); this.pcc_pci = lines[28].split(",")[5].replace(/"/g, "");
@@ -1197,6 +1204,145 @@
}); });
}, },
fetchUpTime() {
// Content-Type: text/plain
//
// 1 hour 44, minute
fetch("/cgi-bin/get_uptime")
.then((response) => response.text())
.then((data) => {
// Example result
// 01:17:02 up 3 days, 2:41, load average: 0.65, 0.66, 0.60
// Look for xx days in the result
const days = data.match(/(\d+) day/);
// Do the same for hours
const hours = data.match(/(\d+) hour/);
// Do the same for minutes
const minutes = data.match(/(\d+) minute/);
// 2:41
const hoursAndMinutes = data.match(/(\d+):(\d+),/);
if (hoursAndMinutes != null) {
if (days != null) {
if (days[1] === "1") {
if (hoursAndMinutes[1] === "1") {
this.uptime =
days[1] +
" day, " +
hoursAndMinutes[1] +
" hour " +
hoursAndMinutes[2] +
" minutes";
} else if (hoursAndMinutes[2] === 1) {
this.uptime =
days[1] +
" day, " +
hoursAndMinutes[1] +
" hours " +
hoursAndMinutes[2] +
" minute";
} else {
this.uptime =
days[1] +
" day, " +
hoursAndMinutes[1] +
" hours " +
hoursAndMinutes[2] +
" minutes";
}
} else {
if (hoursAndMinutes[1] === "1") {
this.uptime =
days[1] +
" days, " +
hoursAndMinutes[1] +
" hour " +
hoursAndMinutes[2] +
" minutes";
} else if (hoursAndMinutes[2] === 1) {
this.uptime =
days[1] +
" days, " +
hoursAndMinutes[1] +
" hours " +
hoursAndMinutes[2] +
" minute";
} else {
this.uptime =
days[1] +
" days, " +
hoursAndMinutes[1] +
" hours " +
hoursAndMinutes[2] +
" minutes";
}
}
} else {
if (hoursAndMinutes[1] === "1") {
this.uptime =
hoursAndMinutes[1] +
" hour " +
hoursAndMinutes[2] +
" minutes";
} else if (hoursAndMinutes[2] === 1) {
this.uptime =
hoursAndMinutes[1] +
" hours " +
hoursAndMinutes[2] +
" minute";
} else {
this.uptime =
hoursAndMinutes[1] +
" hours " +
hoursAndMinutes[2] +
" minutes";
}
}
} else if (days != null) {
if (hours != null) {
if (days[1] === "1") {
if (hours[1] === "1") {
this.uptime = days[1] + " day, " + hours[1] + " hour";
} else {
this.uptime = days[1] + " day, " + hours[1] + " hours";
}
} else {
if (hours[1] === "1") {
this.uptime = days[1] + " days, " + hours[1] + " hour";
} else {
this.uptime = days[1] + " days, " + hours[1] + " hours";
}
}
} else if (minutes != null) {
if (days[1] === "1") {
if (minutes[1] === "1") {
this.uptime =
days[1] + " day, " + minutes[1] + " minute";
} else {
this.uptime =
days[1] + " day, " + minutes[1] + " minutes";
}
} else {
if (minutes[1] === "1") {
this.uptime =
days[1] + " days, " + minutes[1] + " minute";
} else {
this.uptime =
days[1] + " days, " + minutes[1] + " minutes";
}
}
} else {
if (days[1] === "1") {
this.uptime = days[1] + " day";
} else {
this.uptime = days[1] + " days";
}
}
}
});
},
updateRefreshRate() { updateRefreshRate() {
// Check if the refresh rate is less than 3 // Check if the refresh rate is less than 3
if (this.newRefreshRate < 3) { if (this.newRefreshRate < 3) {
@@ -1247,6 +1393,8 @@
this.internetConnection = "Disconnected"; this.internetConnection = "Disconnected";
}); });
this.fetchUpTime();
this.lastUpdate = new Date().toLocaleString(); this.lastUpdate = new Date().toLocaleString();
console.log("Initialized"); console.log("Initialized");
@@ -1273,6 +1421,8 @@
this.internetConnection = "Disconnected"; this.internetConnection = "Disconnected";
}); });
this.fetchUpTime();
this.lastUpdate = new Date().toLocaleString(); this.lastUpdate = new Date().toLocaleString();
console.log("Refreshed"); console.log("Refreshed");
}, this.refreshRate * 1000); }, this.refreshRate * 1000);

2264
simpleadmin/www/scanner.html Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -82,7 +82,7 @@
class="form-control" class="form-control"
placeholder="ATI" placeholder="ATI"
id="atOutputBox" id="atOutputBox"
style="height: 220px" style="height: 210px"
x-text="atCommandResponse" x-text="atCommandResponse"
readonly readonly
> >
@@ -169,13 +169,24 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row">ETH IP Passthrough</th> <th scope="row">IP Passthrough</th>
<td>
<select
class="form-select"
id="ipPassModeSelect"
x-model="ipPassMode"
>
<option selected>Passthrough Mode</option>
<option value="ETH">ETH</option>
<option value="USB">USB</option>
</select>
</td>
<td> <td>
<button <button
type="submit" type="submit"
class="btn btn-primary" class="btn btn-primary"
@click="ethPassthroughEnable()" @click="ipPassThroughEnable()"
x-show="ethPassStatus === false" x-show="ipPassStatus === false"
:disabled="isLoading" :disabled="isLoading"
> >
Enable Enable
@@ -183,14 +194,43 @@
<button <button
type="submit" type="submit"
class="btn btn-danger" class="btn btn-danger"
@click="ethPassthroughDisable()" @click="ipPassThroughDisable()"
x-show="ethPassStatus === true" x-show="ipPassStatus === true"
:disabled="isLoading" :disabled="isLoading"
> >
Disable Disable
</button> </button>
</td> </td>
</tr> </tr>
<tr>
<th scope="row">Data Call Method</th>
<td>
<select
class="form-select"
id="usbNetModeSelect"
x-model="usbNetMode"
>
<option
selected
x-text="currentUsbNetMode"
></option>
<option value="RMNET">RMNET</option>
<option value="ECM">ECM (Recommended)</option>
<option value="MBIM">MBIM</option>
<option value="RNDIS">RNDIS</option>
</select>
</td>
<td>
<button
type="submit"
class="btn btn-primary"
@click="usbNetModeChanger()"
:disabled="isLoading"
>
Change
</button>
</td>
</tr>
<tr> <tr>
<th scope="row">Onboard DNS Proxy</th> <th scope="row">Onboard DNS Proxy</th>
<td> <td>
@@ -214,55 +254,6 @@
</button> </button>
</td> </td>
</tr> </tr>
<tr>
<th scope="row">USB Mode</th>
<td>
<button
type="submit"
class="btn btn-primary"
@click="usbModeEnable()"
x-show="USBModeStatus === true"
:disabled="isLoading"
>
Enable
</button>
<button
type="submit"
class="btn btn-danger"
@click="usbModeDisable()"
x-show="USBModeStatus === false"
:disabled="isLoading"
>
Disable
</button>
</td>
</tr>
<tr>
<th scope="row">Scan Neighbour LTE</th>
<td>
<button
type="submit"
class="btn btn-primary"
@click="scanLTE()"
:disabled="isLoading"
>
Scan LTE
</button>
</td>
</tr>
<tr>
<th scope="row">Scan Neighbour NSA</th>
<td>
<button
type="submit"
class="btn btn-primary"
@click="scanNSA()"
:disabled="isLoading"
>
Scan NSA
</button>
</td>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>
@@ -313,7 +304,7 @@
Set TTL Value to 0 to disable. Set TTL Value to 0 to disable.
</div> </div>
</div> </div>
<div class="d-grid gap-2"> <div class="d-grid gap-1">
<button <button
class="btn btn-primary" class="btn btn-primary"
type="button" type="button"
@@ -324,30 +315,18 @@
</div> </div>
</div> </div>
<div class="card-text"> <div class="card-text">
<!-- Select Input Scan Here --> <label class="form-label">Cell Scanner</label>
<div class="mb-3"> <div class="d-grid gap-1 w-full">
<label for="networkScan" class="form-label" <!-- -->
>Network Scan</label <a
> class="btn btn-warning"
<select
class="form-select"
id="networkScan"
x-model="fullScanModeType"
>
<option selected>Choose Scan Mode</option>
<option value="LTE">LTE</option>
<option value="NR5G">NR5G</option>
<option value="ALL">ALL</option>
</select>
</div>
<div class="d-grid gap-2">
<button
class="btn btn-primary"
type="button" type="button"
@click="fullScanMode()" href="/scanner.html"
:disabled="isLoading" role="button"
x-text="scanStart ? 'Scanning... Please wait.' : 'Start Scan'" >
></button> Go to Cell Scanner
</a>
<!-- </a> -->
</div> </div>
</div> </div>
</div> </div>
@@ -422,11 +401,11 @@
ttlvalue: 0, ttlvalue: 0,
ttlStatus: false, ttlStatus: false,
newTTL: null, newTTL: null,
ethPassStatus: false, ipPassMode: "Unspecified",
ipPassStatus: false,
usbNetMode: "Unspecified",
currentUsbNetMode: "Unknown",
DNSProxyStatus: true, DNSProxyStatus: true,
USBModeStatus: true,
fullScanModeType: "",
scanStart: false,
closeModal() { closeModal() {
this.confirmModal = false; this.confirmModal = false;
@@ -461,6 +440,7 @@
this.atCommandResponse = data; this.atCommandResponse = data;
this.isLoading = false; this.isLoading = false;
this.isClean = false; this.isClean = false;
this.fetchCurrentSettings();
}) })
.catch((error) => { .catch((error) => {
console.error("Error: ", error); console.error("Error: ", error);
@@ -502,87 +482,76 @@
this.showRebootModal(); this.showRebootModal();
}, },
ethPassthroughEnable() { ipPassThroughEnable() {
this.atcmd = 'AT+QMAP="MPDN_RULE",0,1,0,1,1,"FF:FF:FF:FF:FF:FF"'; if (this.ipPassMode != "Unspecified") {
if (this.ipPassMode == "ETH") {
this.atcmd =
'AT+QMAP="MPDN_RULE",0,1,0,1,1,"FF:FF:FF:FF:FF:FF"';
this.sendATCommand(); this.sendATCommand();
this.fetchCurrentSettings(); } else if (this.ipPassMode == "USB") {
this.atcmd =
'AT+QMAP="MPDN_RULE",0,1,0,3,1,"FF:FF:FF:FF:FF:FF"';
this.sendATCommand();
} else {
console.error("Invalid IP Passthrough Mode");
}
} else {
console.error("IP Passthrough Mode not specified");
}
}, },
ethPassthroughDisable() { ipPassThroughDisable() {
this.atcmd = 'AT+QMAP="MPDN_RULE",0'; this.atcmd = 'AT+QMAP="MPDN_RULE",0';
this.sendATCommand(); this.sendATCommand();
this.fetchCurrentSettings();
}, },
onBoardDNSProxyEnable() { onBoardDNSProxyEnable() {
this.atcmd = 'AT+QMAP="DHCPV4DNS","enable"'; this.atcmd = 'AT+QMAP="DHCPV4DNS","enable"';
this.sendATCommand(); this.sendATCommand().then(() => {
this.fetchCurrentSettings(); this.fetchCurrentSettings();
});
}, },
onBoardDNSProxyDisable() { onBoardDNSProxyDisable() {
this.atcmd = 'AT+QMAP="DHCPV4DNS","disable"'; this.atcmd = 'AT+QMAP="DHCPV4DNS","disable"';
this.sendATCommand(); this.sendATCommand().then(() => {
this.fetchCurrentSettings(); this.fetchCurrentSettings();
});
}, },
usbModeEnable() { usbNetModeChanger() {
this.atcmd = "AT+QMAPWAC=1"; if (this.usbNetMode != "Unspecified") {
this.sendATCommand(); if (this.usbNetMode == "RMNET") {
this.fetchCurrentSettings(); this.atcmd = 'AT+QCFG="usbnet",0;';
}, this.sendATCommand().then(() => {
this.rebootDevice();
usbModeDisable() { });
this.atcmd = "AT+QMAPWAC=0"; } else if (this.usbNetMode == "ECM") {
this.sendATCommand(); this.atcmd = 'AT+QCFG="usbnet",1;';
this.fetchCurrentSettings(); this.sendATCommand().then(() => {
}, this.rebootDevice();
});
scanLTE() { } else if (this.usbNetMode == "MBIM") {
this.atcmd = 'AT+QENG="neighbourcell"'; this.atcmd = 'AT+QCFG="usbnet",2;';
this.sendATCommand(); this.sendATCommand().then(() => {
}, this.rebootDevice();
});
scanNSA() { } else if (this.usbNetMode == "RNDIS") {
this.atcmd = this.atcmd = 'AT+QCFG="usbnet",3;';
'AT+QNWCFG="nr5g_meas_info",1;+QNWCFG="nr5g_meas_info"'; this.sendATCommand().then(() => {
this.sendATCommand(); this.rebootDevice();
}, });
} else {
fullScanMode() { console.log("USB Net Mode Invalid");
switch (this.fullScanModeType) { }
case "LTE": } else {
this.atcmd = "AT+QSCAN=1,1"; console.error("USB Net Mode not specified");
this.scanStart = true;
this.atCommandResponse =
"Scanning all available LTE networks... This might take a while.";
this.sendATCommand();
this.scanStart = false;
break;
case "NR5G":
this.atcmd = "AT+QSCAN=2,1";
this.scanStart = true;
this.atCommandResponse =
"Scanning all available NR5G-SA networks... This might take a while.";
this.sendATCommand();
this.scanStart = false;
break;
case "ALL":
this.atcmd = "AT+QSCAN=3,1";
this.scanStart = true;
this.atCommandResponse =
"Scanning all available networks... This might take a while.";
this.sendATCommand();
this.scanStart = false;
break;
default:
alert("Select a Scan Mode First");
} }
}, },
fetchCurrentSettings() { fetchCurrentSettings() {
this.fetchATCommand = this.fetchATCommand =
'AT+QMAP="MPDN_RULE";+QMAP="DHCPV4DNS";+QMAPWAC?'; 'AT+QMAP="MPDN_RULE";+QMAP="DHCPV4DNS";+QCFG="usbnet"';
fetch( fetch(
"/cgi-bin/get_atcommand?" + "/cgi-bin/get_atcommand?" +
new URLSearchParams({ new URLSearchParams({
@@ -596,15 +565,16 @@
// Set the value of currentSettingsResponse // Set the value of currentSettingsResponse
this.currentSettingsResponse = data; this.currentSettingsResponse = data;
const currentData = data.split("\n"); const currentData = data.split("\n");
console.log("Lines: ", currentData);
const testEthpass = currentData[1].match( const testEthpass = currentData[1].match(
/\+QMAP: "MPDN_rule",0,0,0,0,0/ /\+QMAP: "MPDN_rule",0,0,0,0,0/
); );
if (testEthpass) { if (testEthpass) {
this.ethPassStatus = false; this.ipPassStatus = false;
} else { } else {
this.ethPassStatus = true; this.ipPassStatus = true;
} }
const testDNSProxy = currentData[6].match( const testDNSProxy = currentData[6].match(
@@ -617,12 +587,20 @@
this.DNSProxyStatus = false; this.DNSProxyStatus = false;
} }
const testUSBMode = currentData[8].match(/\+QMAPWAC: 1/); const testUSBNet = currentData[8].match(
/\+QCFG: "usbnet",(\d)/
);
if (testUSBMode) { if (testUSBNet[1] == "0") {
this.USBModeStatus = true; this.currentUsbNetMode = "RMNET";
} else if (testUSBNet[1] == "1") {
this.currentUsbNetMode = "ECM";
} else if (testUSBNet[1] == "2") {
this.currentUsbNetMode = "MBIM";
} else if (testUSBNet[1] == "3") {
this.currentUsbNetMode = "RNDIS";
} else { } else {
this.USBModeStatus = false; this.currentUsbNetMode = "Unknown";
} }
// clear atcmd // clear atcmd
@@ -666,8 +644,8 @@
}); });
}, },
init() { init() {
this.fetchTTL();
this.fetchCurrentSettings(); this.fetchCurrentSettings();
this.fetchTTL();
}, },
}; };
} }

View File

@@ -158,6 +158,7 @@ echo -e "\e[1;31m2) Installing simpleadmin from the $GITTREE branch\e[0m"
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/settings.html wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/settings.html
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/sms.html wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/sms.html
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/logout.html wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/logout.html
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/scanner.html
sleep 1 sleep 1
cd $SIMPLE_ADMIN_DIR/www/js cd $SIMPLE_ADMIN_DIR/www/js
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/js/alpinejs.min.js wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/js/alpinejs.min.js
@@ -178,6 +179,7 @@ echo -e "\e[1;31m2) Installing simpleadmin from the $GITTREE branch\e[0m"
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/cgi-bin/get_ttl_status wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/cgi-bin/get_ttl_status
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/cgi-bin/set_ttl wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/cgi-bin/set_ttl
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/cgi-bin/send_sms wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/cgi-bin/send_sms
wget https://raw.githubusercontent.com/$GITUSER/quectel-rgmii-toolkit/$GITTREE/simpleadmin/www/cgi-bin/get_uptime
sleep 1 sleep 1
cd / cd /
chmod +x $SIMPLE_ADMIN_DIR/www/cgi-bin/* chmod +x $SIMPLE_ADMIN_DIR/www/cgi-bin/*