diff --git a/option/inbound.go b/option/inbound.go index a2b23461..5c744f36 100644 --- a/option/inbound.go +++ b/option/inbound.go @@ -109,6 +109,8 @@ func (h *Inbound) UnmarshalJSON(bytes []byte) error { v = &h.TUICOptions case C.TypeHysteria2: v = &h.Hysteria2Options + case "": + return E.New("missing inbound type") default: return E.New("unknown inbound type: ", h.Type) } diff --git a/option/outbound.go b/option/outbound.go index f6593228..40f8a160 100644 --- a/option/outbound.go +++ b/option/outbound.go @@ -119,6 +119,8 @@ func (h *Outbound) UnmarshalJSON(bytes []byte) error { v = &h.SelectorOptions case C.TypeURLTest: v = &h.URLTestOptions + case "": + return E.New("missing outbound type") default: return E.New("unknown outbound type: ", h.Type) } diff --git a/option/tls_acme.go b/option/tls_acme.go index aa3f2377..17d515e2 100644 --- a/option/tls_acme.go +++ b/option/tls_acme.go @@ -40,6 +40,8 @@ func (o ACMEDNS01ChallengeOptions) MarshalJSON() ([]byte, error) { v = o.AliDNSOptions case C.DNSProviderCloudflare: v = o.CloudflareOptions + case "": + return nil, E.New("missing provider type") default: return nil, E.New("unknown provider type: " + o.Provider) } diff --git a/option/v2ray_transport.go b/option/v2ray_transport.go index 56fb71d6..fcd81f94 100644 --- a/option/v2ray_transport.go +++ b/option/v2ray_transport.go @@ -7,7 +7,7 @@ import ( ) type _V2RayTransportOptions struct { - Type string `json:"type,omitempty"` + Type string `json:"type"` HTTPOptions V2RayHTTPOptions `json:"-"` WebsocketOptions V2RayWebsocketOptions `json:"-"` QUICOptions V2RayQUICOptions `json:"-"` @@ -20,8 +20,6 @@ type V2RayTransportOptions _V2RayTransportOptions func (o V2RayTransportOptions) MarshalJSON() ([]byte, error) { var v any switch o.Type { - case "": - return nil, nil case C.V2RayTransportTypeHTTP: v = o.HTTPOptions case C.V2RayTransportTypeWebsocket: @@ -32,6 +30,8 @@ func (o V2RayTransportOptions) MarshalJSON() ([]byte, error) { v = o.GRPCOptions case C.V2RayTransportTypeHTTPUpgrade: v = o.HTTPUpgradeOptions + case "": + return nil, E.New("missing transport type") default: return nil, E.New("unknown transport type: " + o.Type) }