From e19d8002a8200dcc32288b706ba48d8ebef77f14 Mon Sep 17 00:00:00 2001 From: v2ray Date: Tue, 29 Dec 2015 20:52:35 +0100 Subject: [PATCH] Refresh rate of a inbound detour allocation --- shell/point/config.go | 5 +++-- shell/point/json/inbound_detour.go | 5 +++++ shell/point/testing/mocks/config.go | 5 +++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/shell/point/config.go b/shell/point/config.go index 34d8985f9..81b5cb333 100644 --- a/shell/point/config.go +++ b/shell/point/config.go @@ -30,8 +30,9 @@ const ( ) type InboundDetourAllocationConfig interface { - Strategy() string - Concurrency() int + Strategy() string // Allocation strategy of this inbound detour. + Concurrency() int // Number of handlers (ports) running in parallel. + Refresh() int // Number of seconds before a handler is regenerated. } type InboundDetourConfig interface { diff --git a/shell/point/json/inbound_detour.go b/shell/point/json/inbound_detour.go index 50d779fbb..a7604e1b0 100644 --- a/shell/point/json/inbound_detour.go +++ b/shell/point/json/inbound_detour.go @@ -12,6 +12,11 @@ import ( type InboundDetourAllocationConfig struct { StrategyValue string `json:"strategy"` ConcurrencyValue int `json:"concurrency"` + RefreshSec int `json:"refresh"` +} + +func (this *InboundDetourAllocationConfig) Refresh() int { + return this.RefreshSec } func (this *InboundDetourAllocationConfig) Strategy() string { diff --git a/shell/point/testing/mocks/config.go b/shell/point/testing/mocks/config.go index 7085fc0ec..b094e9a4f 100644 --- a/shell/point/testing/mocks/config.go +++ b/shell/point/testing/mocks/config.go @@ -55,6 +55,11 @@ func (this *PortRange) To() v2net.Port { type InboundDetourAllocationConfig struct { StrategyValue string ConcurrencyValue int + RefreshSec int +} + +func (this *InboundDetourAllocationConfig) Refresh() int { + return this.RefreshSec } func (this *InboundDetourAllocationConfig) Strategy() string {