diff --git a/infra/conf/http.go b/infra/conf/http.go index d4092f88..84155d54 100644 --- a/infra/conf/http.go +++ b/infra/conf/http.go @@ -64,12 +64,21 @@ type HTTPClientConfig struct { func (v *HTTPClientConfig) Build() (proto.Message, error) { config := new(http.ClientConfig) if v.Address != nil { - v.Servers = []*HTTPRemoteConfig{ - { - Address: v.Address, - Port: v.Port, - Users: []json.RawMessage{{}}, - }, + if len(v.Username) == 0 { + v.Servers = []*HTTPRemoteConfig{ + { + Address: v.Address, + Port: v.Port, + }, + } + } else { + v.Servers = []*HTTPRemoteConfig{ + { + Address: v.Address, + Port: v.Port, + Users: []json.RawMessage{{}}, + }, + } } } config.Server = make([]*protocol.ServerEndpoint, len(v.Servers)) diff --git a/infra/conf/socks.go b/infra/conf/socks.go index 6955001f..1d7c6249 100644 --- a/infra/conf/socks.go +++ b/infra/conf/socks.go @@ -82,12 +82,21 @@ type SocksClientConfig struct { func (v *SocksClientConfig) Build() (proto.Message, error) { config := new(socks.ClientConfig) if v.Address != nil { - v.Servers = []*SocksRemoteConfig{ - { - Address: v.Address, - Port: v.Port, - Users: []json.RawMessage{{}}, - }, + if len(v.Username) == 0 { + v.Servers = []*SocksRemoteConfig{ + { + Address: v.Address, + Port: v.Port, + }, + } + } else { + v.Servers = []*SocksRemoteConfig{ + { + Address: v.Address, + Port: v.Port, + Users: []json.RawMessage{{}}, + }, + } } } config.Server = make([]*protocol.ServerEndpoint, len(v.Servers))