mirror of
https://github.com/v2fly/v2ray-core
synced 2024-02-27 03:18:06 +00:00
Add Port as a type
This commit is contained in:
@@ -67,7 +67,7 @@ func TestDetourConfig(t *testing.T) {
|
||||
|
||||
detour := detours[0]
|
||||
assert.String(detour.Protocol()).Equals("dokodemo-door")
|
||||
assert.Uint16(detour.PortRange().From()).Equals(uint16(28394))
|
||||
assert.Uint16(detour.PortRange().To()).Equals(uint16(28394))
|
||||
assert.Uint16(detour.PortRange().From().Value()).Equals(uint16(28394))
|
||||
assert.Uint16(detour.PortRange().To().Value()).Equals(uint16(28394))
|
||||
assert.Pointer(detour.Settings()).IsNotNil()
|
||||
}
|
||||
|
||||
@@ -24,15 +24,15 @@ type LogConfig struct {
|
||||
}
|
||||
|
||||
type PortRange struct {
|
||||
FromValue uint16
|
||||
ToValue uint16
|
||||
FromValue v2net.Port
|
||||
ToValue v2net.Port
|
||||
}
|
||||
|
||||
func (this *PortRange) From() uint16 {
|
||||
func (this *PortRange) From() v2net.Port {
|
||||
return this.FromValue
|
||||
}
|
||||
|
||||
func (this *PortRange) To() uint16 {
|
||||
func (this *PortRange) To() v2net.Port {
|
||||
return this.ToValue
|
||||
}
|
||||
|
||||
|
||||
@@ -2,13 +2,14 @@ package point
|
||||
|
||||
import (
|
||||
"github.com/v2ray/v2ray-core/common/log"
|
||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||
"github.com/v2ray/v2ray-core/common/retry"
|
||||
"github.com/v2ray/v2ray-core/proxy/common/connhandler"
|
||||
"github.com/v2ray/v2ray-core/shell/point/config"
|
||||
)
|
||||
|
||||
type InboundConnectionHandlerWithPort struct {
|
||||
port uint16
|
||||
port v2net.Port
|
||||
handler connhandler.InboundConnectionHandler
|
||||
}
|
||||
|
||||
@@ -45,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)
|
||||
err := ich.handler.Listen(ich.port.Value())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user