Use ptr receiver in all Upstream methods

This commit is contained in:
freddygv 2021-12-13 16:16:50 -07:00
parent d647141a7d
commit f4ddb5432c
1 changed files with 12 additions and 3 deletions

View File

@ -503,15 +503,24 @@ func (u *Upstream) ToKey() UpstreamKey {
}
}
func (u Upstream) HasLocalPortOrSocket() bool {
func (u *Upstream) HasLocalPortOrSocket() bool {
if u == nil {
return false
}
return (u.LocalBindPort != 0 || u.LocalBindSocketPath != "")
}
func (u Upstream) UpstreamIsUnixSocket() bool {
func (u *Upstream) UpstreamIsUnixSocket() bool {
if u == nil {
return false
}
return (u.LocalBindPort == 0 && u.LocalBindAddress == "" && u.LocalBindSocketPath != "")
}
func (u Upstream) UpstreamAddressToString() string {
func (u *Upstream) UpstreamAddressToString() string {
if u == nil {
return ""
}
if u.UpstreamIsUnixSocket() {
return u.LocalBindSocketPath
}