mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-16 10:22:45 +00:00
This commit add the ability for ctrld to gather client information, including mac/ip/hostname, and send to Control-D server through a config per upstream. - Add send_client_info upstream config. - Read/Watch dnsmasq leases files on supported platforms. - Add corresponding client info to DoH query header All of these only apply for Control-D upstream, though.
39 lines
767 B
Go
39 lines
767 B
Go
package router
|
|
|
|
import (
|
|
"bytes"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func Test_merlinParsePostConf(t *testing.T) {
|
|
origContent := "# foo"
|
|
data := strings.Join([]string{
|
|
merlinDNSMasqPostConfTmpl,
|
|
"\n",
|
|
merlinDNSMasqPostConfMarker,
|
|
"\n",
|
|
}, "\n")
|
|
|
|
tests := []struct {
|
|
name string
|
|
data string
|
|
expected string
|
|
}{
|
|
{"empty", "", ""},
|
|
{"no ctrld", origContent, origContent},
|
|
{"ctrld with data", data + origContent, origContent},
|
|
{"ctrld without data", data, ""},
|
|
}
|
|
|
|
for _, tc := range tests {
|
|
tc := tc
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
//t.Parallel()
|
|
if got := merlinParsePostConf([]byte(tc.data)); !bytes.Equal(got, []byte(tc.expected)) {
|
|
t.Errorf("unexpected result, want: %q, got: %q", tc.expected, string(got))
|
|
}
|
|
})
|
|
}
|
|
}
|