mirror of
https://github.com/v2fly/v2ray-core
synced 2024-02-27 03:18:06 +00:00
simplify port range
This commit is contained in:
@@ -23,8 +23,8 @@ type InboundDetourHandler struct {
|
||||
|
||||
func (this *InboundDetourHandler) Initialize() error {
|
||||
ports := this.config.PortRange()
|
||||
this.ich = make([]*InboundConnectionHandlerWithPort, 0, ports.To()-ports.From()+1)
|
||||
for i := ports.From(); i <= ports.To(); i++ {
|
||||
this.ich = make([]*InboundConnectionHandlerWithPort, 0, ports.To-ports.From+1)
|
||||
for i := ports.From; i <= ports.To; i++ {
|
||||
ichConfig := this.config.Settings()
|
||||
ich, err := proxyrepo.CreateInboundConnectionHandler(this.config.Protocol(), this.space, ichConfig)
|
||||
if err != nil {
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"encoding/json"
|
||||
|
||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||
v2netjson "github.com/v2ray/v2ray-core/common/net/json"
|
||||
"github.com/v2ray/v2ray-core/shell/point"
|
||||
)
|
||||
|
||||
@@ -28,7 +27,7 @@ func (this *InboundDetourAllocationConfig) Concurrency() int {
|
||||
|
||||
type InboundDetourConfig struct {
|
||||
ProtocolValue string `json:"protocol"`
|
||||
PortRangeValue *v2netjson.PortRange `json:"port"`
|
||||
PortRangeValue *v2net.PortRange `json:"port"`
|
||||
SettingsValue json.RawMessage `json:"settings"`
|
||||
TagValue string `json:"tag"`
|
||||
AllocationValue *InboundDetourAllocationConfig `json:"allocate"`
|
||||
@@ -43,7 +42,7 @@ func (this *InboundDetourConfig) Protocol() string {
|
||||
}
|
||||
|
||||
func (this *InboundDetourConfig) PortRange() v2net.PortRange {
|
||||
return this.PortRangeValue
|
||||
return *this.PortRangeValue
|
||||
}
|
||||
|
||||
func (this *InboundDetourConfig) Settings() []byte {
|
||||
|
||||
@@ -39,19 +39,6 @@ func (this *LogConfig) LogLevel() log.LogLevel {
|
||||
return this.LogLevelValue
|
||||
}
|
||||
|
||||
type PortRange struct {
|
||||
FromValue v2net.Port
|
||||
ToValue v2net.Port
|
||||
}
|
||||
|
||||
func (this *PortRange) From() v2net.Port {
|
||||
return this.FromValue
|
||||
}
|
||||
|
||||
func (this *PortRange) To() v2net.Port {
|
||||
return this.ToValue
|
||||
}
|
||||
|
||||
type InboundDetourAllocationConfig struct {
|
||||
StrategyValue string
|
||||
ConcurrencyValue int
|
||||
@@ -72,7 +59,7 @@ func (this *InboundDetourAllocationConfig) Concurrency() int {
|
||||
|
||||
type InboundDetourConfig struct {
|
||||
*ConnectionConfig
|
||||
PortRangeValue *PortRange
|
||||
PortRangeValue *v2net.PortRange
|
||||
TagValue string
|
||||
AllocationStrategy *InboundDetourAllocationConfig
|
||||
}
|
||||
@@ -86,7 +73,7 @@ func (this *InboundDetourConfig) Tag() string {
|
||||
}
|
||||
|
||||
func (this *InboundDetourConfig) PortRange() v2net.PortRange {
|
||||
return this.PortRangeValue
|
||||
return *this.PortRangeValue
|
||||
}
|
||||
|
||||
type OutboundDetourConfig struct {
|
||||
|
||||
Reference in New Issue
Block a user