mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-19 23:03:08 +00:00
refactor common/net.Port
This commit is contained in:
1 parent
fa7c1069bc
commit
ae056714db
33 files changed
+86
-70
No files matched your search
@@ -27,7 +27,7 @@ type OutboundDetourConfig interface {
|
||||
}
|
||||
|
||||
type PointConfig interface {
|
||||
Port() uint16
|
||||
Port() v2net.Port
|
||||
LogConfig() LogConfig
|
||||
RouterConfig() routerconfig.RouterConfig
|
||||
InboundConfig() ConnectionConfig
|
||||
|
||||
@@ -8,13 +8,14 @@ import (
|
||||
routerconfig "github.com/v2ray/v2ray-core/app/router/config"
|
||||
routerconfigjson "github.com/v2ray/v2ray-core/app/router/config/json"
|
||||
"github.com/v2ray/v2ray-core/common/log"
|
||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||
proxyconfig "github.com/v2ray/v2ray-core/proxy/common/config"
|
||||
"github.com/v2ray/v2ray-core/shell/point/config"
|
||||
)
|
||||
|
||||
// Config is the config for Point server.
|
||||
type Config struct {
|
||||
PortValue uint16 `json:"port"` // Port of this Point server.
|
||||
PortValue v2net.Port `json:"port"` // Port of this Point server.
|
||||
LogConfigValue *LogConfig `json:"log"`
|
||||
RouterConfigValue *routerconfigjson.RouterConfig `json:"routing"`
|
||||
InboundConfigValue *ConnectionConfig `json:"inbound"`
|
||||
@@ -23,7 +24,7 @@ type Config struct {
|
||||
OutboundDetoursValue []*OutboundDetourConfig `json:"outboundDetour"`
|
||||
}
|
||||
|
||||
func (config *Config) Port() uint16 {
|
||||
func (config *Config) Port() v2net.Port {
|
||||
return config.PortValue
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ func TestClientSampleConfig(t *testing.T) {
|
||||
pointConfig, err := json.LoadConfig(filepath.Join(baseDir, "vpoint_socks_vmess.json"))
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
assert.Uint16(pointConfig.Port()).Positive()
|
||||
assert.Uint16(pointConfig.Port().Value()).Positive()
|
||||
assert.Pointer(pointConfig.InboundConfig()).IsNotNil()
|
||||
assert.Pointer(pointConfig.OutboundConfig()).IsNotNil()
|
||||
|
||||
@@ -43,7 +43,7 @@ func TestServerSampleConfig(t *testing.T) {
|
||||
pointConfig, err := json.LoadConfig(filepath.Join(baseDir, "vpoint_vmess_freedom.json"))
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
assert.Uint16(pointConfig.Port()).Positive()
|
||||
assert.Uint16(pointConfig.Port().Value()).Positive()
|
||||
assert.Pointer(pointConfig.InboundConfig()).IsNotNil()
|
||||
assert.Pointer(pointConfig.OutboundConfig()).IsNotNil()
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ func (config *LogConfig) AccessLog() string {
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
PortValue uint16
|
||||
PortValue v2net.Port
|
||||
LogConfigValue *LogConfig
|
||||
RouterConfigValue routerconfig.RouterConfig
|
||||
InboundConfigValue *ConnectionConfig
|
||||
@@ -68,7 +68,7 @@ type Config struct {
|
||||
OutboundDetoursValue []*OutboundDetourConfig
|
||||
}
|
||||
|
||||
func (config *Config) Port() uint16 {
|
||||
func (config *Config) Port() v2net.Port {
|
||||
return config.PortValue
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user