Skip to content

Commit

Permalink
support managing udp interfaces in ui
Browse files Browse the repository at this point in the history
  • Loading branch information
liamcottle committed Jul 12, 2024
1 parent ea8f76b commit f2a0373
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 5 deletions.
37 changes: 37 additions & 0 deletions meshchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,43 @@ async def index(request):
interface_details["listen_ip"] = data.get('listen_ip')
interface_details["listen_port"] = data.get('listen_port')

# handle udp interface
if interface_type == "UDPInterface":

interface_listen_ip = data.get('listen_ip')
interface_listen_port = data.get('listen_port')
interface_forward_ip = data.get('forward_ip')
interface_forward_port = data.get('forward_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)

# ensure forward ip provided
if interface_forward_ip is None or interface_forward_ip == "":
return web.json_response({
"message": "Forward IP is required",
}, status=422)

# ensure forward port provided
if interface_forward_port is None or interface_forward_port == "":
return web.json_response({
"message": "Forward Port is required",
}, status=422)

interface_details["listen_ip"] = data.get('listen_ip')
interface_details["listen_port"] = data.get('listen_port')
interface_details["forward_ip"] = data.get('forward_ip')
interface_details["forward_port"] = data.get('forward_port')

# handle rnode interface
if interface_type == "RNodeInterface":

Expand Down
46 changes: 41 additions & 5 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,11 @@
{{ iface.type }} • {{ iface.listen_ip }}:{{ iface.listen_port }}
</span>

<!-- udp interface -->
<span v-else-if="iface.type === 'UDPInterface'">
{{ iface.type }} • {{ iface.listen_ip }}:{{ iface.listen_port }} • {{ iface.forward_ip }}:{{ iface.forward_port }}
</span>

<!-- rnode interface details -->
<span v-else-if="iface.type === 'RNodeInterface'">
{{ iface.type }} • {{ iface.port }} • freq={{ iface.frequency }} • bw={{ iface.bandwidth }} • power={{ iface.txpower }}dBm • sf={{ iface.spreadingfactor }} • cr={{ iface.codingrate }}
Expand Down Expand Up @@ -1071,6 +1076,7 @@
<option value="RNodeInterface">RNodeInterface</option>
<option value="TCPClientInterface">TCPClientInterface</option>
<option value="TCPServerInterface">TCPServerInterface</option>
<option value="UDPInterface">UDPInterface</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>
Expand All @@ -1090,17 +1096,29 @@
</div>

<!-- interface listen ip -->
<div v-if="newInterfaceType === 'TCPServerInterface'" class="mb-2">
<div v-if="newInterfaceType === 'TCPServerInterface' || newInterfaceType === 'UDPInterface'" 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">
<div v-if="newInterfaceType === 'TCPServerInterface' || newInterfaceType === 'UDPInterface'" 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 forward ip -->
<div v-if="newInterfaceType === 'UDPInterface'" class="mb-2">
<label class="block mb-2 text-sm font-medium text-gray-900">Forward IP</label>
<input type="text" placeholder="255.255.255.255" v-model="newInterfaceForwardIp" 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 === 'UDPInterface'" class="mb-2">
<label class="block mb-2 text-sm font-medium text-gray-900">Forward Port</label>
<input type="text" placeholder="1234" v-model="newInterfaceForwardPort" 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>
Expand Down Expand Up @@ -1282,6 +1300,9 @@
newInterfaceListenIp: null,
newInterfaceListenPort: null,

newInterfaceForwardIp: null,
newInterfaceForwardPort: null,

newInterfacePort: null,
newInterfaceFrequency: null,
newInterfaceBandwidth: null,
Expand Down Expand Up @@ -2055,6 +2076,10 @@
// example: "TCPServerInterface[TCP Server Interface/0.0.0.0:4242]";
return `TCPServerInterface[${interfaceName}/${iface.listen_ip}:${iface.listen_port}]`;
}
case "UDPInterface": {
// example: "UDPInterface[UDP Interface/0.0.0.0:1234]";
return `UDPInterface[${interfaceName}/${iface.listen_ip}:${iface.listen_port}]`;
}
default: {
// example: "RNodeInterface[RNode LoRa Interface Fast]",
return `${iface.type}[${interfaceName}]`;
Expand Down Expand Up @@ -2729,10 +2754,14 @@
this.newInterfaceTargetHost = null;
this.newInterfaceTargetPort = null;

// tcp server interface
// tcp server interface & udp interface
this.newInterfaceListenIp = null;
this.newInterfaceListenPort = null;

// udp interface
this.newInterfaceForwardIp = null;
this.newInterfaceForwardPort = null;

// rnode interface
this.newInterfacePort = null;
this.newInterfaceFrequency = null;
Expand Down Expand Up @@ -2761,10 +2790,14 @@
this.newInterfaceTargetHost = iface.target_host;
this.newInterfaceTargetPort = iface.target_port;

// tcp server interface
// tcp server interface & udp interface
this.newInterfaceListenIp = iface.listen_ip;
this.newInterfaceListenPort = iface.listen_port;

// udp interface
this.newInterfaceForwardIp = iface.forward_ip;
this.newInterfaceForwardPort = iface.forward_port;

// rnode interface
this.newInterfacePort = iface.port;
this.newInterfaceFrequency = iface.frequency;
Expand Down Expand Up @@ -2808,9 +2841,12 @@
// tcp client interface
target_host: this.newInterfaceTargetHost,
target_port: this.newInterfaceTargetPort,
// tcp server interface
// tcp server interface & udp interface
listen_ip: this.newInterfaceListenIp,
listen_port: this.newInterfaceListenPort,
// udp interface
forward_ip: this.newInterfaceForwardIp,
forward_port: this.newInterfaceForwardPort,
// rnode interface
port: this.newInterfacePort,
frequency: this.newInterfaceFrequency,
Expand Down

0 comments on commit f2a0373

Please sign in to comment.