refine whatsapp bridge defaults and webui polish

This commit is contained in:
lpf
2026-03-10 12:07:56 +08:00
parent 8a6a2755de
commit c7b159d2ed
29 changed files with 1389 additions and 432 deletions

View File

@@ -3,6 +3,7 @@ package channels
import (
"context"
"encoding/json"
"net"
"testing"
"time"
@@ -63,6 +64,32 @@ func TestBridgeStatusURLWithNestedPath(t *testing.T) {
}
}
func TestIsLocalRemoteAddr(t *testing.T) {
ipv4Net := &net.IPNet{IP: net.ParseIP("192.168.1.10"), Mask: net.CIDRMask(24, 32)}
ipv6Net := &net.IPNet{IP: net.ParseIP("fe80::1"), Mask: net.CIDRMask(64, 128)}
tests := []struct {
name string
remoteAddr string
want bool
}{
{name: "loopback", remoteAddr: "127.0.0.1:4321", want: true},
{name: "local interface ipv4", remoteAddr: "192.168.1.10:4321", want: true},
{name: "local interface ipv6", remoteAddr: "[fe80::1]:4321", want: true},
{name: "non local ip", remoteAddr: "192.168.1.11:4321", want: false},
{name: "invalid host", remoteAddr: "not-an-ip", want: false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := isLocalRemoteAddr(tt.remoteAddr, []net.Addr{ipv4Net, ipv6Net})
if got != tt.want {
t.Fatalf("got %v want %v", got, tt.want)
}
})
}
}
func TestNormalizeWhatsAppRecipientJID(t *testing.T) {
tests := []struct {
input string