added various changes

This commit is contained in:
Russel Yasol
2024-05-14 12:36:11 +08:00
parent b260cf369e
commit 12cebf6900
3 changed files with 265 additions and 105 deletions

View File

@@ -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,29 +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>
</tbody>
</table>
</div>
@@ -301,14 +318,14 @@
<label class="form-label">Cell Scanner</label>
<div class="d-grid gap-1 w-full">
<!-- -->
<a
class="btn btn-warning"
type="button"
href="/scanner.html"
role="button"
>
Go to Cell Scanner
</a>
<a
class="btn btn-warning"
type="button"
href="/scanner.html"
role="button"
>
Go to Cell Scanner
</a>
<!-- </a> -->
</div>
</div>
@@ -384,9 +401,11 @@
ttlvalue: 0,
ttlStatus: false,
newTTL: null,
ethPassStatus: false,
ipPassMode: "Unspecified",
ipPassStatus: false,
usbNetMode: "Unspecified",
currentUsbNetMode: "Unknown",
DNSProxyStatus: true,
USBModeStatus: true,
closeModal() {
this.confirmModal = false;
@@ -421,6 +440,7 @@
this.atCommandResponse = data;
this.isLoading = false;
this.isClean = false;
this.fetchCurrentSettings();
})
.catch((error) => {
console.error("Error: ", error);
@@ -462,18 +482,27 @@
this.showRebootModal();
},
ethPassthroughEnable() {
this.atcmd = 'AT+QMAP="MPDN_RULE",0,1,0,1,1,"FF:FF:FF:FF:FF:FF"';
this.sendATCommand().then(() => {
this.fetchCurrentSettings();
});
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();
} 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().then(() => {
this.fetchCurrentSettings();
});
this.sendATCommand();
},
onBoardDNSProxyEnable() {
@@ -490,23 +519,39 @@
});
},
usbModeEnable() {
this.atcmd = "AT+QMAPWAC=1";
this.sendATCommand().then(() => {
this.fetchCurrentSettings();
});
},
usbModeDisable() {
this.atcmd = "AT+QMAPWAC=0";
this.sendATCommand().then(() => {
this.fetchCurrentSettings();
});
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({
@@ -520,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(
@@ -541,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
@@ -590,6 +644,7 @@
});
},
init() {
this.fetchCurrentSettings();
this.fetchTTL();
},
};