[skip ci] [Pre] avoid npe

This commit is contained in:
gVisor bot 2022-03-23 13:48:21 +08:00
parent 35ceca309f
commit b8996bac73
5 changed files with 5 additions and 5 deletions

View file

@ -97,7 +97,7 @@ func (f *Fallback) SupportUDP() bool {
// MarshalJSON implements C.ProxyAdapter
func (f *Fallback) MarshalJSON() ([]byte, error) {
var all []string
all := []string{}
for _, proxy := range f.proxies(false) {
all = append(all, proxy.Name())
}

View file

@ -150,7 +150,7 @@ func (lb *LoadBalance) proxies(touch bool) []C.Proxy {
// MarshalJSON implements C.ProxyAdapter
func (lb *LoadBalance) MarshalJSON() ([]byte, error) {
var all []string
all := []string{}
for _, proxy := range lb.proxies(false) {
all = append(all, proxy.Name())
}

View file

@ -69,7 +69,7 @@ func (r *Relay) DialContext(ctx context.Context, metadata *C.Metadata, opts ...d
// MarshalJSON implements C.ProxyAdapter
func (r *Relay) MarshalJSON() ([]byte, error) {
var all []string
all := []string{}
for _, proxy := range r.rawProxies(false) {
all = append(all, proxy.Name())
}

View file

@ -50,7 +50,7 @@ func (s *Selector) SupportUDP() bool {
// MarshalJSON implements C.ProxyAdapter
func (s *Selector) MarshalJSON() ([]byte, error) {
var all []string
all := []string{}
for _, proxy := range getProvidersProxies(s.providers, false, s.filter) {
all = append(all, proxy.Name())
}

View file

@ -123,7 +123,7 @@ func (u *URLTest) SupportUDP() bool {
// MarshalJSON implements C.ProxyAdapter
func (u *URLTest) MarshalJSON() ([]byte, error) {
var all []string
all := []string{}
for _, proxy := range u.proxies(false) {
all = append(all, proxy.Name())
}