support creating tcp server interfaces in ui

This commit is contained in:
liamcottle 2024-07-12 11:41:28 +12:00
parent f37d5d4aa4
commit 59887728c5
2 changed files with 49 additions and 0 deletions

View file

@ -359,6 +359,27 @@ class ReticulumMeshChat:
interface_details["target_host"] = data.get('target_host')
interface_details["target_port"] = data.get('target_port')
# handle tcp server interface
if interface_type == "TCPServerInterface":
interface_listen_ip = data.get('listen_ip')
interface_listen_port = data.get('listen_port')
# ensure listen ip provided
if interface_listen_ip is None or interface_listen_ip == "":
return web.json_response({
"message": "Listen IP is required",
}, status=422)
# ensure listen port provided
if interface_listen_port is None or interface_listen_port == "":
return web.json_response({
"message": "Listen Port is required",
}, status=422)
interface_details["listen_ip"] = data.get('listen_ip')
interface_details["listen_port"] = data.get('listen_port')
# handle rnode interface
if interface_type == "RNodeInterface":

View file

@ -1069,6 +1069,7 @@
<option value="AutoInterface">AutoInterface</option>
<option value="RNodeInterface">RNodeInterface</option>
<option value="TCPClientInterface">TCPClientInterface</option>
<option value="TCPServerInterface">TCPServerInterface</option>
</select>
<div class="text-xs text-gray-600">
Need help? <a class="text-blue-500 underline" href="https://markqvist.github.io/Reticulum/manual/interfaces.html" target="_blank">Reticulum Docs: Configuring Interfaces</a>
@ -1087,6 +1088,18 @@
<input type="text" placeholder="1234" v-model="newInterfaceTargetPort" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5">
</div>
<!-- interface listen ip -->
<div v-if="newInterfaceType === 'TCPServerInterface'" class="mb-2">
<label class="block mb-2 text-sm font-medium text-gray-900">Listen IP</label>
<input type="text" placeholder="0.0.0.0" v-model="newInterfaceListenIp" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5">
</div>
<!-- interface listen port -->
<div v-if="newInterfaceType === 'TCPServerInterface'" class="mb-2">
<label class="block mb-2 text-sm font-medium text-gray-900">Listen Port</label>
<input type="text" placeholder="1234" v-model="newInterfaceListenPort" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5">
</div>
<!-- interface port -->
<div v-if="newInterfaceType === 'RNodeInterface'" class="mb-2">
<label class="block mb-2 text-sm font-medium text-gray-900">Port</label>
@ -1261,9 +1274,13 @@
newInterfaceName: null,
newInterfaceType: null,
newInterfaceTargetHost: null,
newInterfaceTargetPort: null,
newInterfaceListenIp: null,
newInterfaceListenPort: null,
newInterfacePort: null,
newInterfaceFrequency: null,
newInterfaceBandwidth: null,
@ -2711,6 +2728,10 @@
this.newInterfaceTargetHost = null;
this.newInterfaceTargetPort = null;
// tcp server interface
this.newInterfaceListenIp = null;
this.newInterfaceListenPort = null;
// rnode interface
this.newInterfacePort = null;
this.newInterfaceFrequency = null;
@ -2739,6 +2760,10 @@
this.newInterfaceTargetHost = iface.target_host;
this.newInterfaceTargetPort = iface.target_port;
// tcp server interface
this.newInterfaceListenIp = iface.listen_ip;
this.newInterfaceListenPort = iface.listen_port;
// rnode interface
this.newInterfacePort = iface.port;
this.newInterfaceFrequency = iface.frequency;
@ -2782,6 +2807,9 @@
// tcp client interface
target_host: this.newInterfaceTargetHost,
target_port: this.newInterfaceTargetPort,
// tcp server interface
listen_ip: this.newInterfaceListenIp,
listen_port: this.newInterfaceListenPort,
// rnode interface
port: this.newInterfacePort,
frequency: this.newInterfaceFrequency,