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,6 +30,21 @@ 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"`
|
||||||
@ -37,6 +52,7 @@ type InboundConnectionConfig struct {
|
|||||||
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 {
|
||||||
@ -190,6 +213,7 @@ type InboundDetourConfig struct {
|
|||||||
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