[MM-23279] Idiomatic naming (IP) (#18152)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
8f01a1b5a1
Коммит
e0f51f54e1
@@ -24,7 +24,7 @@ const (
|
||||
HeaderEtagServer = "ETag"
|
||||
HeaderEtagClient = "If-None-Match"
|
||||
HeaderForwarded = "X-Forwarded-For"
|
||||
HeaderRealIp = "X-Real-IP"
|
||||
HeaderRealIP = "X-Real-IP"
|
||||
HeaderForwardedProto = "X-Forwarded-Proto"
|
||||
HeaderToken = "token"
|
||||
HeaderCsrfToken = "X-CSRF-Token"
|
||||
|
||||
@@ -46,13 +46,13 @@ func (o *ClusterDiscovery) AutoFillHostname() {
|
||||
}
|
||||
}
|
||||
|
||||
func (o *ClusterDiscovery) AutoFillIpAddress(iface string, ipAddress string) {
|
||||
func (o *ClusterDiscovery) AutoFillIPAddress(iface string, ipAddress string) {
|
||||
// attempt to set the hostname to the first non-local IP address
|
||||
if o.Hostname == "" {
|
||||
if ipAddress != "" {
|
||||
o.Hostname = ipAddress
|
||||
} else {
|
||||
o.Hostname = GetServerIpAddress(iface)
|
||||
o.Hostname = GetServerIPAddress(iface)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func TestClusterDiscovery(t *testing.T) {
|
||||
o.Hostname = ""
|
||||
o.AutoFillHostname()
|
||||
|
||||
o.AutoFillIpAddress("", "")
|
||||
o.AutoFillIPAddress("", "")
|
||||
o.Hostname = ""
|
||||
o.AutoFillIpAddress("", "")
|
||||
o.AutoFillIPAddress("", "")
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ type ClusterInfo struct {
|
||||
Id string `json:"id"`
|
||||
Version string `json:"version"`
|
||||
ConfigHash string `json:"config_hash"`
|
||||
IpAddress string `json:"ipaddress"`
|
||||
IPAddress string `json:"ipaddress"`
|
||||
Hostname string `json:"hostname"`
|
||||
}
|
||||
|
||||
|
||||
@@ -11,11 +11,11 @@ import (
|
||||
)
|
||||
|
||||
func TestClusterInfosJson(t *testing.T) {
|
||||
cluster := ClusterInfo{IpAddress: NewId(), Hostname: NewId()}
|
||||
cluster := ClusterInfo{IPAddress: NewId(), Hostname: NewId()}
|
||||
clusterInfos := make([]*ClusterInfo, 1)
|
||||
clusterInfos[0] = &cluster
|
||||
json := ClusterInfosToJson(clusterInfos)
|
||||
result := ClusterInfosFromJson(strings.NewReader(json))
|
||||
|
||||
assert.Equal(t, clusterInfos[0].IpAddress, result[0].IpAddress, "Ids do not match")
|
||||
assert.Equal(t, clusterInfos[0].IPAddress, result[0].IPAddress, "Ids do not match")
|
||||
}
|
||||
|
||||
@@ -537,7 +537,7 @@ func (s *ServiceSettings) SetDefaults(isUpdate bool) {
|
||||
if isUpdate {
|
||||
// When updating an existing configuration, ensure that defaults are set.
|
||||
if s.TrustedProxyIPHeader == nil {
|
||||
s.TrustedProxyIPHeader = []string{HeaderForwarded, HeaderRealIp}
|
||||
s.TrustedProxyIPHeader = []string{HeaderForwarded, HeaderRealIP}
|
||||
}
|
||||
} else {
|
||||
// When generating a blank configuration, leave the list empty.
|
||||
@@ -844,7 +844,7 @@ type ClusterSettings struct {
|
||||
NetworkInterface *string `access:"environment_high_availability,write_restrictable,cloud_restrictable"`
|
||||
BindAddress *string `access:"environment_high_availability,write_restrictable,cloud_restrictable"`
|
||||
AdvertiseAddress *string `access:"environment_high_availability,write_restrictable,cloud_restrictable"`
|
||||
UseIpAddress *bool `access:"environment_high_availability,write_restrictable,cloud_restrictable"`
|
||||
UseIPAddress *bool `access:"environment_high_availability,write_restrictable,cloud_restrictable"`
|
||||
DEPRECATED_DO_NOT_USE_UseExperimentalGossip *bool `json:"UseExperimentalGossip" access:"environment_high_availability,write_restrictable,cloud_restrictable"` // Deprecated: do not use
|
||||
EnableGossipCompression *bool `access:"environment_high_availability,write_restrictable,cloud_restrictable"`
|
||||
EnableExperimentalGossipEncryption *bool `access:"environment_high_availability,write_restrictable,cloud_restrictable"`
|
||||
@@ -881,8 +881,8 @@ func (s *ClusterSettings) SetDefaults() {
|
||||
s.AdvertiseAddress = NewString("")
|
||||
}
|
||||
|
||||
if s.UseIpAddress == nil {
|
||||
s.UseIpAddress = NewBool(true)
|
||||
if s.UseIPAddress == nil {
|
||||
s.UseIPAddress = NewBool(true)
|
||||
}
|
||||
|
||||
if s.DEPRECATED_DO_NOT_USE_UseExperimentalGossip == nil {
|
||||
|
||||
@@ -320,7 +320,7 @@ func ToJson(v interface{}) []byte {
|
||||
return b
|
||||
}
|
||||
|
||||
func GetServerIpAddress(iface string) string {
|
||||
func GetServerIPAddress(iface string) string {
|
||||
var addrs []net.Addr
|
||||
if iface == "" {
|
||||
var err error
|
||||
|
||||
@@ -343,8 +343,8 @@ func TestIsValidAlphaNum(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetServerIpAddress(t *testing.T) {
|
||||
require.NotEmpty(t, GetServerIpAddress(""), "Should find local ip address")
|
||||
func TestGetServerIPAddress(t *testing.T) {
|
||||
require.NotEmpty(t, GetServerIPAddress(""), "Should find local ip address")
|
||||
}
|
||||
|
||||
func TestIsValidAlphaNumHyphenUnderscore(t *testing.T) {
|
||||
|
||||
Ссылка в новой задаче
Block a user