Skip to content

Commit c4a355f

Browse files
authored
Dev (#417)
## v1.0.13 **Improvements** - Show QR Code for Guest WiFi - New "guestonly" policy for Guest APs
1 parent 64899e6 commit c4a355f

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed

RELEASE-NOTES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# Secure Programmable Router (SPR) Release Notes
2+
## v1.0.13
3+
**Improvements**
4+
- Show QR Code for Guest WiFi
5+
- New "guestonly" policy for Guest APs
6+
27
## v1.0.12
38
**Improvements**
49
- Golang version update & module upgrades

api/code/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ type DeviceEntry struct {
126126
DeviceDisabled bool //tbd deprecate this in favor of only using the policy name.
127127
}
128128

129-
var ValidPolicyStrings = []string{"wan", "lan", "dns", "api", "lan_upstream", "noapi", "disabled", "quarantine", "dns:family"}
129+
var ValidPolicyStrings = []string{"wan", "lan", "dns", "api", "lan_upstream", "noapi", "guestonly", "disabled", "quarantine", "dns:family"}
130130

131131
var config = APIConfig{}
132132

api/code/dhcp.go

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"os"
2222
"os/exec"
2323
"regexp"
24+
"slices"
2425
"strconv"
2526
"strings"
2627
"sync"
@@ -62,6 +63,14 @@ type DHCPResponse struct {
6263
LeaseTime string
6364
}
6465

66+
type DHCPFail struct {
67+
MAC string
68+
Identifier string
69+
Name string
70+
Iface string
71+
Reason string
72+
}
73+
6574
var DHCPmtx sync.Mutex
6675

6776
func SUBNETP1(subnet string) string {
@@ -321,7 +330,8 @@ func handleDHCPResult(MAC string, IP string, Router string, Name string, Iface s
321330

322331
//guest ssid defaults
323332
if strings.Contains(Iface, ExtraBSSPrefix) {
324-
newDevice.Policies = []string{"wan", "dns", "noapi"}
333+
//guestonly policy -> can only exist on the guest AP
334+
newDevice.Policies = []string{"wan", "dns", "noapi", "guestonly"}
325335
newDevice.DeviceTags = []string{"guest"}
326336
}
327337

@@ -386,6 +396,24 @@ func dhcpRequest(w http.ResponseWriter, r *http.Request) {
386396
devices := getDevicesJson()
387397
val, exists := devices[dhcp.MAC]
388398

399+
if exists {
400+
if strings.Contains(dhcp.Iface, ExtraBSSPrefix) {
401+
//ensure the device had the guestonly policy
402+
//this should only happen if a MAC is already known for a device
403+
if !slices.Contains(val.Policies, "guestonly") {
404+
fail := DHCPFail{}
405+
fail.Iface = dhcp.Iface
406+
fail.MAC = dhcp.MAC
407+
fail.Identifier = dhcp.Identifier
408+
fail.Name = dhcp.Name
409+
fail.Reason = "Missing GuestOnly Policy, Possible MAC Spoofing"
410+
SprbusPublish("dhcp:spoof", fail)
411+
http.Error(w, "Refuse dhcp from wanif", 400)
412+
return
413+
}
414+
}
415+
}
416+
389417
if exists && val.RecentIP != "" && isTinyNetIPLocked(val.RecentIP) {
390418
IP = val.RecentIP
391419
Router = RouterFromTinyIP(IP)

frontend/src/components/Wifi/WifiGuestNetworkParameters.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
import { EyeIcon } from 'lucide-react-native'
3131

3232
import { Select } from 'components/Select'
33+
import DeviceQRCode from 'components/Devices/DeviceQRCode'
3334

3435
let modes = [
3536
{ label: '5 & 6 GHz', value: 'a' },
@@ -343,6 +344,11 @@ const WifiChannelParameters = ({
343344
autoComplete="off"
344345
/>
345346
</Input>
347+
<>
348+
{(uipasswordType == 'text') && (
349+
<DeviceQRCode ssid={extraSSID} psk={guestPassword} type="WPA" />
350+
)}
351+
</>
346352
{'password' in errors ? (
347353
<FormControlError>
348354
<FormControlErrorText>

0 commit comments

Comments
 (0)