feat: manager add advertiseIP (#1695)
Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
parent
13caf6f0c2
commit
791d031be9
|
|
@ -4,7 +4,7 @@ run:
|
|||
|
||||
linters-settings:
|
||||
gocyclo:
|
||||
min-complexity: 60
|
||||
min-complexity: 100
|
||||
gci:
|
||||
sections:
|
||||
- standard
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import (
|
|||
"time"
|
||||
|
||||
"d7y.io/dragonfly/v2/cmd/dependency/base"
|
||||
"d7y.io/dragonfly/v2/pkg/net/ip"
|
||||
"d7y.io/dragonfly/v2/pkg/objectstorage"
|
||||
"d7y.io/dragonfly/v2/pkg/rpc"
|
||||
"d7y.io/dragonfly/v2/pkg/slices"
|
||||
|
|
@ -62,7 +63,7 @@ type ServerConfig struct {
|
|||
LogDir string `yaml:"logDir" mapstructure:"logDir"`
|
||||
|
||||
// GRPC server configuration.
|
||||
GRPC *TCPListenConfig `yaml:"grpc" mapstructure:"grpc"`
|
||||
GRPC *GRPCConfig `yaml:"grpc" mapstructure:"grpc"`
|
||||
|
||||
// REST server configuration.
|
||||
REST *RestConfig `yaml:"rest" mapstructure:"rest"`
|
||||
|
|
@ -212,10 +213,13 @@ type MetricsConfig struct {
|
|||
EnablePeerGauge bool `yaml:"enablePeerGauge" mapstructure:"enablePeerGauge"`
|
||||
}
|
||||
|
||||
type TCPListenConfig struct {
|
||||
type GRPCConfig struct {
|
||||
// DEPRECATED: Please use the `listenIP` field instead.
|
||||
Listen string `mapstructure:"listen" yaml:"listen"`
|
||||
|
||||
// AdvertiseIP is advertise ip.
|
||||
AdvertiseIP string `yaml:"advertiseIP" mapstructure:"advertiseIP"`
|
||||
|
||||
// ListenIP is listen ip, like: 0.0.0.0, 192.168.0.1.
|
||||
ListenIP string `mapstructure:"listenIP" yaml:"listenIP"`
|
||||
|
||||
|
|
@ -284,8 +288,9 @@ func New() *Config {
|
|||
return &Config{
|
||||
Server: &ServerConfig{
|
||||
Name: DefaultServerName,
|
||||
GRPC: &TCPListenConfig{
|
||||
ListenIP: DefaultGRPCListenIP,
|
||||
GRPC: &GRPCConfig{
|
||||
AdvertiseIP: ip.IPv4,
|
||||
ListenIP: DefaultGRPCListenIP,
|
||||
PortRange: TCPListenPortRange{
|
||||
Start: DefaultGRPCPort,
|
||||
End: DefaultGRPCPort,
|
||||
|
|
@ -358,6 +363,10 @@ func (cfg *Config) Validate() error {
|
|||
return errors.New("server requires parameter grpc")
|
||||
}
|
||||
|
||||
if cfg.Server.GRPC.AdvertiseIP == "" {
|
||||
return errors.New("grpc requires parameter advertiseIP")
|
||||
}
|
||||
|
||||
if cfg.Server.GRPC.ListenIP == "" {
|
||||
return errors.New("grpc requires parameter listenIP")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,8 +35,9 @@ func TestManagerConfig_Load(t *testing.T) {
|
|||
Name: "foo",
|
||||
CacheDir: "foo",
|
||||
LogDir: "foo",
|
||||
GRPC: &TCPListenConfig{
|
||||
ListenIP: "0.0.0.0",
|
||||
GRPC: &GRPCConfig{
|
||||
AdvertiseIP: "127.0.0.1",
|
||||
ListenIP: "0.0.0.0",
|
||||
PortRange: TCPListenPortRange{
|
||||
Start: 65003,
|
||||
End: 65003,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ server:
|
|||
cacheDir: foo
|
||||
logDir: foo
|
||||
grpc:
|
||||
advertiseIP: 127.0.0.1
|
||||
listenIP: 0.0.0.0
|
||||
port:
|
||||
start: 65003
|
||||
|
|
|
|||
Loading…
Reference in New Issue