Skip to content

Commit 96ec5e5

Browse files
authored
fix(dot11r): drop duplicate json mac tag so the BSSID serializes (#1391) (#1395)
Dot11rIface had both MAC and Mac fields with the same json tag, a leftover from a rename. encoding/json silently drops ambiguous duplicates, so the BSSID never reached the wire and the 802.11r table (Roaming page) always showed '-' in its MAC column. go vet flagged it as 'repeats json tag'. The mixed-case field was dead code (everyone uses MAC); removed. New serialization regression test. Closes #1391
1 parent df86ade commit 96ec5e5

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

‎server-go/internal/adapters/dot11r_test.go‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package adapters
22

3-
import "testing"
3+
import (
4+
"encoding/json"
5+
"strings"
6+
"testing"
7+
)
48

59
// TestParseUciWirelessFlint2 usa la salida real de `uci show wireless` del
610
// Flint2 (gateway de Mandor) como fixture. Cubre:
@@ -240,3 +244,16 @@ func TestDot11rSkip(t *testing.T) {
240244
}
241245
}
242246
}
247+
248+
// #1391: el tag json "mac" estaba duplicado (campos MAC y Mac) y
249+
// encoding/json no serializaba NINGUNO: la tabla 802.11r del front
250+
// (Roaming.tsx) pintaba la columna MAC siempre "-". Anti-regresión.
251+
func TestDot11rIfaceSerializesMAC(t *testing.T) {
252+
raw, err := json.Marshal(Dot11rIface{SSID: "temiscira", MAC: "AA:BB:CC:DD:EE:FF"})
253+
if err != nil {
254+
t.Fatal(err)
255+
}
256+
if !strings.Contains(string(raw), `"mac":"AA:BB:CC:DD:EE:FF"`) {
257+
t.Fatalf("mac no serializada: %s", raw)
258+
}
259+
}

‎server-go/internal/adapters/types.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,6 @@ type Dot11rIface struct {
798798
Ifname string `json:"ifname"` // wlan0, wlan1 (puede estar vacío en configs muy nuevas)
799799
SSID string `json:"ssid"`
800800
MAC string `json:"mac"` // macaddr (BSSID del BSS)
801-
Mac string `json:"mac"` // macaddr (BSSID del BSS)
802801
Channel int `json:"channel,omitempty"` // mapeado desde radio.channel
803802
Band string `json:"band,omitempty"` // "2.4 GHz"|"5 GHz" desde radio.band
804803

0 commit comments

Comments
 (0)