|
|
@@ -858,3 +858,47 @@ func TestBuildWireguardProxyForClashNoKey(t *testing.T) {
|
|
|
t.Fatalf("buildProxy = %v, want nil for a keyless wireguard client", proxy)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func TestBuildHysteriaProxy_HostAllowInsecureSetsSkipCertVerify(t *testing.T) {
|
|
|
+ svc := &SubClashService{SubService: &SubService{}}
|
|
|
+ inbound := &model.Inbound{
|
|
|
+ Listen: "203.0.113.9",
|
|
|
+ Port: 443,
|
|
|
+ Protocol: model.Hysteria,
|
|
|
+ Remark: "hy",
|
|
|
+ Settings: `{"version":2,"clients":[{"auth":"hyauth","email":"user"}]}`,
|
|
|
+ StreamSettings: `{"security":"tls","tlsSettings":{"serverName":"hy.sni"}}`,
|
|
|
+ }
|
|
|
+ client := model.Client{Email: "user", Auth: "hyauth"}
|
|
|
+ ep := map[string]any{"allowInsecure": true}
|
|
|
+
|
|
|
+ proxy := svc.buildHysteriaProxy(svc.SubService, inbound, client, ep)
|
|
|
+ if proxy == nil {
|
|
|
+ t.Fatal("buildHysteriaProxy returned nil")
|
|
|
+ }
|
|
|
+ if v, _ := proxy["skip-cert-verify"].(bool); !v {
|
|
|
+ t.Fatalf("skip-cert-verify = %v, want true when ep allowInsecure is set", proxy["skip-cert-verify"])
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func TestBuildHysteriaProxy_NoHostAllowInsecureOmitsSkipCertVerify(t *testing.T) {
|
|
|
+ svc := &SubClashService{SubService: &SubService{}}
|
|
|
+ inbound := &model.Inbound{
|
|
|
+ Listen: "203.0.113.9",
|
|
|
+ Port: 443,
|
|
|
+ Protocol: model.Hysteria,
|
|
|
+ Remark: "hy",
|
|
|
+ Settings: `{"version":2,"clients":[{"auth":"hyauth","email":"user"}]}`,
|
|
|
+ StreamSettings: `{"security":"tls","tlsSettings":{"serverName":"hy.sni"}}`,
|
|
|
+ }
|
|
|
+ client := model.Client{Email: "user", Auth: "hyauth"}
|
|
|
+ ep := map[string]any{}
|
|
|
+
|
|
|
+ proxy := svc.buildHysteriaProxy(svc.SubService, inbound, client, ep)
|
|
|
+ if proxy == nil {
|
|
|
+ t.Fatal("buildHysteriaProxy returned nil")
|
|
|
+ }
|
|
|
+ if _, ok := proxy["skip-cert-verify"]; ok {
|
|
|
+ t.Fatalf("skip-cert-verify should be unset without allowInsecure, got %v", proxy["skip-cert-verify"])
|
|
|
+ }
|
|
|
+}
|