refactor common/net.Port

This commit is contained in:
Darien Raymond committed 2015-12-02 20:44:01 +00:00
1 parent fa7c1069bc
commit ae056714db
33 files changed
+86 -70

No files matched your search

+1 -1
View File
@@ -27,7 +27,7 @@ type OutboundDetourConfig interface {
}
type PointConfig interface {
Port() uint16
Port() v2net.Port
LogConfig() LogConfig
RouterConfig() routerconfig.RouterConfig
InboundConfig() ConnectionConfig
+3 -2
View File
@@ -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
}
+2 -2
View File
@@ -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()
+2 -2
View File
@@ -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
}
+1 -1
View File
@@ -46,7 +46,7 @@ func (this *InboundDetourHandler) Initialize() error {
func (this *InboundDetourHandler) Start() error {
for _, ich := range this.ich {
return retry.Timed(100 /* times */, 100 /* ms */).On(func() error {
err := ich.handler.Listen(ich.port.Value())
err := ich.handler.Listen(ich.port)
if err != nil {
return err
}
+1 -1
View File
@@ -12,7 +12,7 @@ import (
// Point is an single server in V2Ray system.
type Point struct {
port uint16
port v2net.Port
ich connhandler.InboundConnectionHandler
och connhandler.OutboundConnectionHandler
idh []*InboundDetourHandler