mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-17 18:06:15 -05:00
outbound config
This commit is contained in:
parent
be4cfdf61c
commit
39939b00f0
13
config.go
13
config.go
@ -1,6 +1,7 @@
|
|||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"v2ray.com/core/common"
|
||||||
"v2ray.com/core/proxy/registry"
|
"v2ray.com/core/proxy/registry"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -26,5 +27,15 @@ func (this *InboundConnectionConfig) GetAllocationStrategyValue() *AllocationStr
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *InboundConnectionConfig) GetTypedSettings() (interface{}, error) {
|
func (this *InboundConnectionConfig) GetTypedSettings() (interface{}, error) {
|
||||||
return registry.MarshalInboundConfig(this.Protocol, this.Settings)
|
if this.GetSettings() == nil {
|
||||||
|
return nil, common.ErrBadConfiguration
|
||||||
|
}
|
||||||
|
return this.GetSettings().GetInstance()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *OutboundConnectionConfig) GetTypedSettings() (interface{}, error) {
|
||||||
|
if this.GetSettings() == nil {
|
||||||
|
return nil, common.ErrBadConfiguration
|
||||||
|
}
|
||||||
|
return this.GetSettings().GetInstance()
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,11 @@ func NewInboundDetourHandlerDynamic(space app.Space, config *InboundConnectionCo
|
|||||||
handler.ichs = make([]proxy.InboundHandler, config.GetAllocationStrategyValue().Concurrency.GetValue())
|
handler.ichs = make([]proxy.InboundHandler, config.GetAllocationStrategyValue().Concurrency.GetValue())
|
||||||
|
|
||||||
// To test configuration
|
// To test configuration
|
||||||
ich, err := proxyregistry.CreateInboundHandler(config.Protocol, space, config.Settings, &proxy.InboundHandlerMeta{
|
ichConfig, err := config.GetTypedSettings()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
ich, err := proxyregistry.CreateInboundHandler(config.Protocol, space, ichConfig, &proxy.InboundHandlerMeta{
|
||||||
Address: config.ListenOn.AsAddress(),
|
Address: config.ListenOn.AsAddress(),
|
||||||
Port: 0,
|
Port: 0,
|
||||||
Tag: config.Tag,
|
Tag: config.Tag,
|
||||||
|
6
v2ray.go
6
v2ray.go
@ -92,8 +92,12 @@ func NewPoint(pConfig *Config) (*Point, error) {
|
|||||||
vpoint.outboundHandlers = make([]proxy.OutboundHandler, 8)
|
vpoint.outboundHandlers = make([]proxy.OutboundHandler, 8)
|
||||||
vpoint.taggedOutboundHandlers = make(map[string]proxy.OutboundHandler)
|
vpoint.taggedOutboundHandlers = make(map[string]proxy.OutboundHandler)
|
||||||
for idx, outbound := range pConfig.Outbound {
|
for idx, outbound := range pConfig.Outbound {
|
||||||
|
outboundSettings, err := outbound.GetTypedSettings()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
outboundHandler, err := proxyregistry.CreateOutboundHandler(
|
outboundHandler, err := proxyregistry.CreateOutboundHandler(
|
||||||
outbound.Protocol, vpoint.space, outbound.Settings, &proxy.OutboundHandlerMeta{
|
outbound.Protocol, vpoint.space, outboundSettings, &proxy.OutboundHandlerMeta{
|
||||||
Tag: outbound.Tag,
|
Tag: outbound.Tag,
|
||||||
Address: outbound.SendThrough.AsAddress(),
|
Address: outbound.SendThrough.AsAddress(),
|
||||||
StreamSettings: outbound.StreamSettings,
|
StreamSettings: outbound.StreamSettings,
|
||||||
|
Loading…
Reference in New Issue
Block a user