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>
<td class="col-md-2" x-text="firmwareVersion"></td>
</tr>
<tr>
<th scope="row">Phone Number</th>
<td class="col-md-2" x-text="phoneNumber"></td>
</tr>
<tr>
<th scope="row">IMSI</th>
<td class="col-md-2" x-text="imsi"></td>
@@ -135,7 +139,7 @@
</tr>
<tr>
<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>
</tbody>
</table>
@@ -225,6 +229,7 @@
lanIp: "-",
wwanIpv4: "-",
wwanIpv6: "-",
phoneNumber: "Unknown",
simpleAdminVersion: "-",
atcmd: null,
atCommandResponse: "",
@@ -262,7 +267,7 @@
fetchATCommand() {
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;
fetch(
"/cgi-bin/get_atcommand?" +
@@ -297,7 +302,13 @@
this.lanIp = lines[13].trim().split(",")[3];
this.wwanIpv4 = lines[15].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;
},

View File

@@ -202,6 +202,10 @@
<th scope="row">IPv<sup>6</sup></th>
<td x-text="ipv6"></td>
</tr>
<tr>
<th scope="row">Uptime</th>
<td x-text="uptime"></td>
</tr>
</tbody>
</table>
</div>
@@ -611,6 +615,7 @@
newRefreshRate: null,
refreshRate: 3,
intervalId: null,
uptime: "Unknown",
fetchNetworkInfo() {
this.atcmd =
'AT+QTEMP;+QUIMSLOT?;+QSPN;+CGCONTRDP=1;+QMAP="WWANIP";+QENG="servingcell";+QCAINFO';
@@ -1004,7 +1009,9 @@
// Calculate the NR bandwidth
this.bandwidth +=
" / NR " + this.calculate_nr_bw(nr_bw).toString() + " MHz";
" / NR " +
this.calculate_nr_bw(nr_bw).toString() +
" MHz";
// Parse the PCIs
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() {
// Check if the refresh rate is less than 3
if (this.newRefreshRate < 3) {
@@ -1247,6 +1393,8 @@
this.internetConnection = "Disconnected";
});
this.fetchUpTime();
this.lastUpdate = new Date().toLocaleString();
console.log("Initialized");
@@ -1273,6 +1421,8 @@
this.internetConnection = "Disconnected";
});
this.fetchUpTime();
this.lastUpdate = new Date().toLocaleString();
console.log("Refreshed");
}, 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"
placeholder="ATI"
id="atOutputBox"
style="height: 220px"
style="height: 210px"
x-text="atCommandResponse"
readonly
>
@@ -169,13 +169,24 @@
</td>
</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>
<button
type="submit"
class="btn btn-primary"
@click="ethPassthroughEnable()"
x-show="ethPassStatus === false"
@click="ipPassThroughEnable()"
x-show="ipPassStatus === false"
:disabled="isLoading"
>
Enable
@@ -183,14 +194,43 @@
<button
type="submit"
class="btn btn-danger"
@click="ethPassthroughDisable()"
x-show="ethPassStatus === true"
@click="ipPassThroughDisable()"
x-show="ipPassStatus === true"
:disabled="isLoading"
>
Disable
</button>
</td>
</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>
<th scope="row">Onboard DNS Proxy</th>
<td>
@@ -214,55 +254,6 @@
</button>
</td>
</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>
</table>
</div>
@@ -313,7 +304,7 @@
Set TTL Value to 0 to disable.
</div>
</div>
<div class="d-grid gap-2">
<div class="d-grid gap-1">
<button
class="btn btn-primary"
type="button"
@@ -324,30 +315,18 @@
</div>
</div>
<div class="card-text">
<!-- Select Input Scan Here -->
<div class="mb-3">
<label for="networkScan" class="form-label"
>Network Scan</label
>
<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"
<label class="form-label">Cell Scanner</label>
<div class="d-grid gap-1 w-full">
<!-- -->
<a
class="btn btn-warning"
type="button"
@click="fullScanMode()"
:disabled="isLoading"
x-text="scanStart ? 'Scanning... Please wait.' : 'Start Scan'"
></button>
href="/scanner.html"
role="button"
>
Go to Cell Scanner
</a>
<!-- </a> -->
</div>
</div>
</div>
@@ -422,11 +401,11 @@
ttlvalue: 0,
ttlStatus: false,
newTTL: null,
ethPassStatus: false,
ipPassMode: "Unspecified",
ipPassStatus: false,
usbNetMode: "Unspecified",
currentUsbNetMode: "Unknown",
DNSProxyStatus: true,
USBModeStatus: true,
fullScanModeType: "",
scanStart: false,
closeModal() {
this.confirmModal = false;
@@ -461,6 +440,7 @@
this.atCommandResponse = data;
this.isLoading = false;
this.isClean = false;
this.fetchCurrentSettings();
})
.catch((error) => {
console.error("Error: ", error);
@@ -502,87 +482,76 @@
this.showRebootModal();
},
ethPassthroughEnable() {
this.atcmd = 'AT+QMAP="MPDN_RULE",0,1,0,1,1,"FF:FF:FF:FF:FF:FF"';
ipPassThroughEnable() {
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.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.sendATCommand();
this.fetchCurrentSettings();
},
onBoardDNSProxyEnable() {
this.atcmd = 'AT+QMAP="DHCPV4DNS","enable"';
this.sendATCommand();
this.sendATCommand().then(() => {
this.fetchCurrentSettings();
});
},
onBoardDNSProxyDisable() {
this.atcmd = 'AT+QMAP="DHCPV4DNS","disable"';
this.sendATCommand();
this.sendATCommand().then(() => {
this.fetchCurrentSettings();
});
},
usbModeEnable() {
this.atcmd = "AT+QMAPWAC=1";
this.sendATCommand();
this.fetchCurrentSettings();
},
usbModeDisable() {
this.atcmd = "AT+QMAPWAC=0";
this.sendATCommand();
this.fetchCurrentSettings();
},
scanLTE() {
this.atcmd = 'AT+QENG="neighbourcell"';
this.sendATCommand();
},
scanNSA() {
this.atcmd =
'AT+QNWCFG="nr5g_meas_info",1;+QNWCFG="nr5g_meas_info"';
this.sendATCommand();
},
fullScanMode() {
switch (this.fullScanModeType) {
case "LTE":
this.atcmd = "AT+QSCAN=1,1";
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");
usbNetModeChanger() {
if (this.usbNetMode != "Unspecified") {
if (this.usbNetMode == "RMNET") {
this.atcmd = 'AT+QCFG="usbnet",0;';
this.sendATCommand().then(() => {
this.rebootDevice();
});
} else if (this.usbNetMode == "ECM") {
this.atcmd = 'AT+QCFG="usbnet",1;';
this.sendATCommand().then(() => {
this.rebootDevice();
});
} else if (this.usbNetMode == "MBIM") {
this.atcmd = 'AT+QCFG="usbnet",2;';
this.sendATCommand().then(() => {
this.rebootDevice();
});
} else if (this.usbNetMode == "RNDIS") {
this.atcmd = 'AT+QCFG="usbnet",3;';
this.sendATCommand().then(() => {
this.rebootDevice();
});
} else {
console.log("USB Net Mode Invalid");
}
} else {
console.error("USB Net Mode not specified");
}
},
fetchCurrentSettings() {
this.fetchATCommand =
'AT+QMAP="MPDN_RULE";+QMAP="DHCPV4DNS";+QMAPWAC?';
'AT+QMAP="MPDN_RULE";+QMAP="DHCPV4DNS";+QCFG="usbnet"';
fetch(
"/cgi-bin/get_atcommand?" +
new URLSearchParams({
@@ -596,15 +565,16 @@
// Set the value of currentSettingsResponse
this.currentSettingsResponse = data;
const currentData = data.split("\n");
console.log("Lines: ", currentData);
const testEthpass = currentData[1].match(
/\+QMAP: "MPDN_rule",0,0,0,0,0/
);
if (testEthpass) {
this.ethPassStatus = false;
this.ipPassStatus = false;
} else {
this.ethPassStatus = true;
this.ipPassStatus = true;
}
const testDNSProxy = currentData[6].match(
@@ -617,12 +587,20 @@
this.DNSProxyStatus = false;
}
const testUSBMode = currentData[8].match(/\+QMAPWAC: 1/);
const testUSBNet = currentData[8].match(
/\+QCFG: "usbnet",(\d)/
);
if (testUSBMode) {
this.USBModeStatus = true;
if (testUSBNet[1] == "0") {
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 {
this.USBModeStatus = false;
this.currentUsbNetMode = "Unknown";
}
// clear atcmd
@@ -666,8 +644,8 @@
});
},
init() {
this.fetchTTL();
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/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/scanner.html
sleep 1
cd $SIMPLE_ADMIN_DIR/www/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/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/get_uptime
sleep 1
cd /
chmod +x $SIMPLE_ADMIN_DIR/www/cgi-bin/*