mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 10:08:15 -05:00
json config for domain override
This commit is contained in:
parent
c9c2338f05
commit
43dfb8ced3
@ -30,13 +30,29 @@ var (
|
|||||||
}, "protocol", "settings")
|
}, "protocol", "settings")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func toProtocolList(s []string) ([]proxyman.KnownProtocols, error) {
|
||||||
|
kp := make([]proxyman.KnownProtocols, 0, 8)
|
||||||
|
for _, p := range s {
|
||||||
|
switch strings.ToLower(p) {
|
||||||
|
case "http":
|
||||||
|
kp = append(kp, proxyman.KnownProtocols_HTTP)
|
||||||
|
case "https", "tls", "ssl":
|
||||||
|
kp = append(kp, proxyman.KnownProtocols_TLS)
|
||||||
|
default:
|
||||||
|
return nil, newError("Unknown protocol: ", p)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return kp, nil
|
||||||
|
}
|
||||||
|
|
||||||
type InboundConnectionConfig struct {
|
type InboundConnectionConfig struct {
|
||||||
Port uint16 `json:"port"`
|
Port uint16 `json:"port"`
|
||||||
Listen *Address `json:"listen"`
|
Listen *Address `json:"listen"`
|
||||||
Protocol string `json:"protocol"`
|
Protocol string `json:"protocol"`
|
||||||
StreamSetting *StreamConfig `json:"streamSettings"`
|
StreamSetting *StreamConfig `json:"streamSettings"`
|
||||||
Settings json.RawMessage `json:"settings"`
|
Settings json.RawMessage `json:"settings"`
|
||||||
Tag string `json:"tag"`
|
Tag string `json:"tag"`
|
||||||
|
DomainOverride *StringList `json:"domainOverride"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *InboundConnectionConfig) Build() (*proxyman.InboundHandlerConfig, error) {
|
func (v *InboundConnectionConfig) Build() (*proxyman.InboundHandlerConfig, error) {
|
||||||
@ -59,6 +75,13 @@ func (v *InboundConnectionConfig) Build() (*proxyman.InboundHandlerConfig, error
|
|||||||
}
|
}
|
||||||
receiverConfig.StreamSettings = ts
|
receiverConfig.StreamSettings = ts
|
||||||
}
|
}
|
||||||
|
if v.DomainOverride != nil {
|
||||||
|
kp, err := toProtocolList(*v.DomainOverride)
|
||||||
|
if err != nil {
|
||||||
|
return nil, newError("failed to parse inbound config").Base(err)
|
||||||
|
}
|
||||||
|
receiverConfig.DomainOverride = kp
|
||||||
|
}
|
||||||
|
|
||||||
jsonConfig, err := inboundConfigLoader.LoadWithID(v.Settings, v.Protocol)
|
jsonConfig, err := inboundConfigLoader.LoadWithID(v.Settings, v.Protocol)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -183,13 +206,14 @@ func (v *InboundDetourAllocationConfig) Build() (*proxyman.AllocationStrategy, e
|
|||||||
}
|
}
|
||||||
|
|
||||||
type InboundDetourConfig struct {
|
type InboundDetourConfig struct {
|
||||||
Protocol string `json:"protocol"`
|
Protocol string `json:"protocol"`
|
||||||
PortRange *PortRange `json:"port"`
|
PortRange *PortRange `json:"port"`
|
||||||
ListenOn *Address `json:"listen"`
|
ListenOn *Address `json:"listen"`
|
||||||
Settings json.RawMessage `json:"settings"`
|
Settings json.RawMessage `json:"settings"`
|
||||||
Tag string `json:"tag"`
|
Tag string `json:"tag"`
|
||||||
Allocation *InboundDetourAllocationConfig `json:"allocate"`
|
Allocation *InboundDetourAllocationConfig `json:"allocate"`
|
||||||
StreamSetting *StreamConfig `json:"streamSettings"`
|
StreamSetting *StreamConfig `json:"streamSettings"`
|
||||||
|
DomainOverride *StringList `json:"domainOverride"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *InboundDetourConfig) Build() (*proxyman.InboundHandlerConfig, error) {
|
func (v *InboundDetourConfig) Build() (*proxyman.InboundHandlerConfig, error) {
|
||||||
@ -220,6 +244,13 @@ func (v *InboundDetourConfig) Build() (*proxyman.InboundHandlerConfig, error) {
|
|||||||
}
|
}
|
||||||
receiverSettings.StreamSettings = ss
|
receiverSettings.StreamSettings = ss
|
||||||
}
|
}
|
||||||
|
if v.DomainOverride != nil {
|
||||||
|
kp, err := toProtocolList(*v.DomainOverride)
|
||||||
|
if err != nil {
|
||||||
|
return nil, newError("failed to parse inbound detour config").Base(err)
|
||||||
|
}
|
||||||
|
receiverSettings.DomainOverride = kp
|
||||||
|
}
|
||||||
|
|
||||||
rawConfig, err := inboundConfigLoader.LoadWithID(v.Settings, v.Protocol)
|
rawConfig, err := inboundConfigLoader.LoadWithID(v.Settings, v.Protocol)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user