You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
regexp.MustCompile(`^❗ You are connected via a DERP relay, not directly, peer-to-peer \(p2p\)$`),
746
+
regexp.MustCompile(`^❗ Agent is potentially behind a hard NAT, as multiple endpoints were retrieved from different STUN servers$`),
747
+
},
748
+
},
749
+
{
750
+
name: "AgentInterfaceWarnings",
751
+
diags: cliui.ConnDiags{
752
+
PingP2P: true,
753
+
AgentNetcheck: &healthsdk.AgentNetcheckReport{
754
+
Interfaces: healthsdk.InterfacesReport{
755
+
BaseReport: healthsdk.BaseReport{
756
+
Warnings: []health.Message{
757
+
health.Messagef(health.CodeInterfaceSmallMTU, "network interface eth0 has MTU 1280, (less than 1378), which may cause problems with direct connections"),
758
+
},
759
+
},
760
+
},
761
+
},
762
+
},
763
+
want: []*regexp.Regexp{
764
+
regexp.MustCompile(`^❗ Agent: network interface eth0 has MTU 1280, \(less than 1378\), which may cause problems with direct connections$`),
765
+
regexp.MustCompile(`^✔ You are connected directly, peer-to-peer \(p2p\)$`),
766
+
},
767
+
},
768
+
{
769
+
name: "LocalInterfaceWarnings",
770
+
diags: cliui.ConnDiags{
771
+
PingP2P: true,
772
+
LocalInterfaces: &healthsdk.InterfacesReport{
773
+
BaseReport: healthsdk.BaseReport{
774
+
Warnings: []health.Message{
775
+
health.Messagef(health.CodeInterfaceSmallMTU, "network interface eth1 has MTU 1310, (less than 1378), which may cause problems with direct connections"),
776
+
},
777
+
},
778
+
},
779
+
},
780
+
want: []*regexp.Regexp{
781
+
regexp.MustCompile(`^❗ Client: network interface eth1 has MTU 1310, \(less than 1378\), which may cause problems with direct connections$`),
782
+
regexp.MustCompile(`^✔ You are connected directly, peer-to-peer \(p2p\)$`),
783
+
},
784
+
},
785
+
}
786
+
for_, tc:=rangetestCases {
787
+
tc:=tc
788
+
t.Run(tc.name, func(t*testing.T) {
789
+
t.Parallel()
790
+
r, w:=io.Pipe()
791
+
gofunc() {
792
+
deferw.Close()
793
+
cliui.ConnDiagnostics(w, tc.diags)
794
+
}()
795
+
s:=bufio.NewScanner(r)
796
+
i:=0
797
+
got:=make([]string, 0)
798
+
fors.Scan() {
799
+
got=append(got, s.Text())
800
+
ifi<len(tc.want) {
801
+
reg:=tc.want[i]
802
+
ifreg.Match(s.Bytes()) {
803
+
i++
804
+
}
805
+
}
806
+
}
807
+
ifi<len(tc.want) {
808
+
t.Logf("failed to match regexp: %s\ngot:\n%s", tc.want[i].String(), strings.Join(got, "\n"))
0 commit comments