mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 01:57:12 -05:00
Outbound detour config
This commit is contained in:
parent
8597642002
commit
1d4b98ab9a
@ -5,7 +5,7 @@ type RouterConfig interface {
|
||||
Settings() interface{}
|
||||
}
|
||||
|
||||
type ConnectionTag string
|
||||
type DetourTag string
|
||||
|
||||
type ConnectionConfig interface {
|
||||
Protocol() string
|
||||
@ -27,6 +27,12 @@ type InboundDetourConfig interface {
|
||||
Settings() interface{}
|
||||
}
|
||||
|
||||
type OutboundDetourConfig interface {
|
||||
Protocol() string
|
||||
Tag() DetourTag
|
||||
Settings() interface{}
|
||||
}
|
||||
|
||||
type PointConfig interface {
|
||||
Port() uint16
|
||||
LogConfig() LogConfig
|
||||
|
@ -12,11 +12,12 @@ import (
|
||||
|
||||
// Config is the config for Point server.
|
||||
type Config struct {
|
||||
PortValue uint16 `json:"port"` // Port of this Point server.
|
||||
LogConfigValue *LogConfig `json:"log"`
|
||||
InboundConfigValue *ConnectionConfig `json:"inbound"`
|
||||
OutboundConfigValue *ConnectionConfig `json:"outbound"`
|
||||
InboundDetoursValue []*InboundDetourConfig `json:"inboundDetour"`
|
||||
PortValue uint16 `json:"port"` // Port of this Point server.
|
||||
LogConfigValue *LogConfig `json:"log"`
|
||||
InboundConfigValue *ConnectionConfig `json:"inbound"`
|
||||
OutboundConfigValue *ConnectionConfig `json:"outbound"`
|
||||
InboundDetoursValue []*InboundDetourConfig `json:"inboundDetour"`
|
||||
OutboundDetoursValue []*OutboundDetourConfig `json:"outboundDetour"`
|
||||
}
|
||||
|
||||
func (config *Config) Port() uint16 {
|
||||
@ -52,6 +53,14 @@ func (this *Config) InboundDetours() []config.InboundDetourConfig {
|
||||
return detours
|
||||
}
|
||||
|
||||
func (this *Config) OutboundDetours() []config.OutboundDetourConfig {
|
||||
detours := make([]config.OutboundDetourConfig, len(this.OutboundDetoursValue))
|
||||
for idx, detour := range this.OutboundDetoursValue {
|
||||
detours[idx] = detour
|
||||
}
|
||||
return detours
|
||||
}
|
||||
|
||||
func LoadConfig(file string) (*Config, error) {
|
||||
fixedFile := os.ExpandEnv(file)
|
||||
rawConfig, err := ioutil.ReadFile(fixedFile)
|
||||
|
26
app/point/config/json/outbound_detour.go
Normal file
26
app/point/config/json/outbound_detour.go
Normal file
@ -0,0 +1,26 @@
|
||||
package json
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/v2ray/v2ray-core/app/point/config"
|
||||
proxyconfig "github.com/v2ray/v2ray-core/proxy/common/config"
|
||||
)
|
||||
|
||||
type OutboundDetourConfig struct {
|
||||
ProtocolValue string `json:"protocol"`
|
||||
TagValue string `json:"tag"`
|
||||
SettingsValue json.RawMessage `json:"settings"`
|
||||
}
|
||||
|
||||
func (this *OutboundDetourConfig) Protocol() string {
|
||||
return this.ProtocolValue
|
||||
}
|
||||
|
||||
func (this *OutboundDetourConfig) Tag() config.DetourTag {
|
||||
return config.DetourTag(this.TagValue)
|
||||
}
|
||||
|
||||
func (this *OutboundDetourConfig) Settings() interface{} {
|
||||
return loadConnectionConfig(this.SettingsValue, this.ProtocolValue, proxyconfig.TypeOutbound)
|
||||
}
|
@ -12,7 +12,7 @@ var (
|
||||
)
|
||||
|
||||
type Router interface {
|
||||
TakeDetour(v2net.Packet) (config.ConnectionTag, error)
|
||||
TakeDetour(v2net.Packet) (config.DetourTag, error)
|
||||
}
|
||||
|
||||
type RouterFactory interface {
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
type WildcardRouter struct {
|
||||
}
|
||||
|
||||
func (router *WildcardRouter) TakeDetour(packet v2net.Packet) (config.ConnectionTag, error) {
|
||||
func (router *WildcardRouter) TakeDetour(packet v2net.Packet) (config.DetourTag, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user