refine app settings in v2ray config

This commit is contained in:
Darien Raymond 2016-10-16 16:04:30 +02:00
parent e33b7df34c
commit e866ff24a4
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
6 changed files with 129 additions and 91 deletions

View File

@ -7,6 +7,7 @@ import (
"v2ray.com/core/app"
"v2ray.com/core/app/dispatcher"
"v2ray.com/core/common/loader"
"v2ray.com/core/common/log"
v2net "v2ray.com/core/common/net"
@ -111,3 +112,18 @@ func (this *CacheServer) Get(domain string) []net.IP {
log.Debug("DNS: Returning nil for domain ", domain)
return nil
}
type CacheServerFactory struct{}
func (this CacheServerFactory) Create(space app.Space, config interface{}) (app.Application, error) {
server := NewCacheServer(space, config.(*Config))
return server, nil
}
func (this CacheServerFactory) AppId() app.ID {
return APP_ID
}
func init() {
app.RegisterApplicationFactory(loader.GetType(new(Config)), CacheServerFactory{})
}

View File

@ -5,6 +5,7 @@ import (
"v2ray.com/core/app"
"v2ray.com/core/app/dns"
"v2ray.com/core/common/loader"
"v2ray.com/core/common/log"
v2net "v2ray.com/core/common/net"
)
@ -107,3 +108,18 @@ func (this *Router) TakeDetour(dest v2net.Destination) (string, error) {
}
return tag, err
}
type RouterFactory struct{}
func (RouterFactory) Create(space app.Space, config interface{}) (app.Application, error) {
router := NewRouter(config.(*Config), space)
return router, nil
}
func (RouterFactory) AppId() app.ID {
return APP_ID
}
func init() {
app.RegisterApplicationFactory(loader.GetType(new(Config)), RouterFactory{})
}

View File

@ -26,6 +26,19 @@ type Application interface {
}
type ApplicationInitializer func() error
type ApplicationFactory interface {
Create(space Space, config interface{}) (Application, error)
AppId() ID
}
var (
applicationFactoryCache map[string]ApplicationFactory
)
func RegisterApplicationFactory(name string, factory ApplicationFactory) error {
applicationFactoryCache[name] = factory
return nil
}
// A Space contains all apps that may be available in a V2Ray runtime.
// Caller must check the availability of an app by calling HasXXX before getting its instance.
@ -36,6 +49,7 @@ type Space interface {
HasApp(ID) bool
GetApp(ID) Application
BindApp(ID, Application)
BindFromConfig(name string, config interface{}) error
}
type spaceImpl struct {
@ -80,3 +94,16 @@ func (this *spaceImpl) GetApp(id ID) Application {
func (this *spaceImpl) BindApp(id ID, application Application) {
this.cache[id] = application
}
func (this *spaceImpl) BindFromConfig(name string, config interface{}) error {
factory, found := applicationFactoryCache[name]
if !found {
return errors.New("Space: app not registered: " + name)
}
app, err := factory.Create(this, config)
if err != nil {
return err
}
this.BindApp(factory.AppId(), app)
return nil
}

View File

@ -21,11 +21,9 @@ package core
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
import v2ray_core_app_router "v2ray.com/core/app/router"
import v2ray_core_app_dns "v2ray.com/core/app/dns"
import v2ray_core_common_loader "v2ray.com/core/common/loader"
import v2ray_core_common_net "v2ray.com/core/common/net"
import v2ray_core_common_net2 "v2ray.com/core/common/net"
import v2ray_core_common_net1 "v2ray.com/core/common/net"
import v2ray_core_common_log "v2ray.com/core/common/log"
import v2ray_core_transport_internet "v2ray.com/core/transport/internet"
import v2ray_core_transport "v2ray.com/core/transport"
@ -138,7 +136,7 @@ func (m *AllocationStrategy) GetRefresh() *AllocationStrategyRefresh {
type InboundConnectionConfig struct {
Settings *v2ray_core_common_loader.TypedSettings `protobuf:"bytes,1,opt,name=settings" json:"settings,omitempty"`
PortRange *v2ray_core_common_net.PortRange `protobuf:"bytes,2,opt,name=port_range,json=portRange" json:"port_range,omitempty"`
ListenOn *v2ray_core_common_net2.IPOrDomain `protobuf:"bytes,3,opt,name=listen_on,json=listenOn" json:"listen_on,omitempty"`
ListenOn *v2ray_core_common_net1.IPOrDomain `protobuf:"bytes,3,opt,name=listen_on,json=listenOn" json:"listen_on,omitempty"`
Tag string `protobuf:"bytes,4,opt,name=tag" json:"tag,omitempty"`
AllocationStrategy *AllocationStrategy `protobuf:"bytes,5,opt,name=allocation_strategy,json=allocationStrategy" json:"allocation_strategy,omitempty"`
StreamSettings *v2ray_core_transport_internet.StreamConfig `protobuf:"bytes,6,opt,name=stream_settings,json=streamSettings" json:"stream_settings,omitempty"`
@ -164,7 +162,7 @@ func (m *InboundConnectionConfig) GetPortRange() *v2ray_core_common_net.PortRang
return nil
}
func (m *InboundConnectionConfig) GetListenOn() *v2ray_core_common_net2.IPOrDomain {
func (m *InboundConnectionConfig) GetListenOn() *v2ray_core_common_net1.IPOrDomain {
if m != nil {
return m.ListenOn
}
@ -187,7 +185,7 @@ func (m *InboundConnectionConfig) GetStreamSettings() *v2ray_core_transport_inte
type OutboundConnectionConfig struct {
Settings *v2ray_core_common_loader.TypedSettings `protobuf:"bytes,1,opt,name=settings" json:"settings,omitempty"`
SendThrough *v2ray_core_common_net2.IPOrDomain `protobuf:"bytes,2,opt,name=send_through,json=sendThrough" json:"send_through,omitempty"`
SendThrough *v2ray_core_common_net1.IPOrDomain `protobuf:"bytes,2,opt,name=send_through,json=sendThrough" json:"send_through,omitempty"`
StreamSettings *v2ray_core_transport_internet.StreamConfig `protobuf:"bytes,3,opt,name=stream_settings,json=streamSettings" json:"stream_settings,omitempty"`
Tag string `protobuf:"bytes,4,opt,name=tag" json:"tag,omitempty"`
}
@ -204,7 +202,7 @@ func (m *OutboundConnectionConfig) GetSettings() *v2ray_core_common_loader.Typed
return nil
}
func (m *OutboundConnectionConfig) GetSendThrough() *v2ray_core_common_net2.IPOrDomain {
func (m *OutboundConnectionConfig) GetSendThrough() *v2ray_core_common_net1.IPOrDomain {
if m != nil {
return m.SendThrough
}
@ -219,12 +217,11 @@ func (m *OutboundConnectionConfig) GetStreamSettings() *v2ray_core_transport_int
}
type Config struct {
Inbound []*InboundConnectionConfig `protobuf:"bytes,1,rep,name=inbound" json:"inbound,omitempty"`
Outbound []*OutboundConnectionConfig `protobuf:"bytes,2,rep,name=outbound" json:"outbound,omitempty"`
Log *v2ray_core_common_log.Config `protobuf:"bytes,3,opt,name=log" json:"log,omitempty"`
Router *v2ray_core_app_router.Config `protobuf:"bytes,4,opt,name=router" json:"router,omitempty"`
Dns *v2ray_core_app_dns.Config `protobuf:"bytes,5,opt,name=dns" json:"dns,omitempty"`
Transport *v2ray_core_transport.Config `protobuf:"bytes,6,opt,name=transport" json:"transport,omitempty"`
Inbound []*InboundConnectionConfig `protobuf:"bytes,1,rep,name=inbound" json:"inbound,omitempty"`
Outbound []*OutboundConnectionConfig `protobuf:"bytes,2,rep,name=outbound" json:"outbound,omitempty"`
Log *v2ray_core_common_log.Config `protobuf:"bytes,3,opt,name=log" json:"log,omitempty"`
App []*v2ray_core_common_loader.TypedSettings `protobuf:"bytes,4,rep,name=app" json:"app,omitempty"`
Transport *v2ray_core_transport.Config `protobuf:"bytes,5,opt,name=transport" json:"transport,omitempty"`
}
func (m *Config) Reset() { *m = Config{} }
@ -253,16 +250,9 @@ func (m *Config) GetLog() *v2ray_core_common_log.Config {
return nil
}
func (m *Config) GetRouter() *v2ray_core_app_router.Config {
func (m *Config) GetApp() []*v2ray_core_common_loader.TypedSettings {
if m != nil {
return m.Router
}
return nil
}
func (m *Config) GetDns() *v2ray_core_app_dns.Config {
if m != nil {
return m.Dns
return m.App
}
return nil
}
@ -288,52 +278,49 @@ func init() {
func init() { proto.RegisterFile("v2ray.com/core/config.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 737 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xb4, 0x95, 0xdf, 0x6e, 0xdb, 0x36,
0x14, 0xc6, 0x23, 0xdb, 0x71, 0xec, 0xe3, 0x2c, 0x33, 0xb8, 0x61, 0xd3, 0xb2, 0x65, 0xf0, 0x9c,
0x7f, 0x5e, 0x1b, 0x48, 0xa8, 0x8b, 0xa0, 0x45, 0x81, 0x36, 0x4d, 0x9c, 0x16, 0x48, 0x0b, 0xd4,
0x06, 0x9d, 0xab, 0xde, 0x18, 0x8c, 0xc4, 0x28, 0x02, 0x24, 0x52, 0x20, 0xe9, 0xa4, 0x7e, 0x84,
0x5e, 0xf4, 0xe5, 0x7a, 0xdb, 0x97, 0x29, 0x28,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
0x4a, 0x74, 0x0c, 0xe5, 0xec, 0x57, 0x92, 0x9e, 0x68, 0x8e, 0x21, 0x49, 0xe2, 0x64, 0xb3, 0x63,
0xc6, 0x88, 0xd1, 0x11, 0x14, 0x7d, 0x26, 0x4d, 0x53, 0x6f, 0xcf, 0x33, 0x3e, 0x93, 0xf9, 0x22,
0x3e, 0x93, 0xe8, 0x19, 0x54, 0x73, 0x9b, 0x4d, 0xef, 0xfe, 0xb3, 0x3c, 0x03, 0x43, 0x4d, 0xe4,
0x0f, 0x0e, 0x60, 0x33, 0x7b, 0xf9, 0x9a, 0x8b, 0x98, 0x28, 0xfd, 0x81, 0xe9, 0xe9, 0x2f, 0xfa,
0xd5, 0xf0, 0xba, 0xbe, 0x86, 0x2a, 0x50, 0x7a, 0xd3, 0xef, 0xbe, 0xab, 0x5b, 0x67, 0xbb, 0xb0,
0xe5, 0xf1, 0x78, 0xaa, 0xea, 0x59, 0x2d, 0xe3, 0x52, 0xf5, 0xfb, 0x92, 0x7e, 0x75, 0x55, 0x4e,
0x7f, 0x06, 0x8f, 0xbf, 0x06, 0x00, 0x00, 0xff, 0xff, 0x4c, 0xd4, 0x2c, 0xd9, 0x7b, 0x07, 0x00,
0x00,
// 697 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xb4, 0x94, 0xdd, 0x6e, 0xd3, 0x3e,
0x18, 0xc6, 0x97, 0xb6, 0xeb, 0xda, 0xb7, 0xfb, 0xef, 0x5f, 0x19, 0x04, 0x61, 0x30, 0x54, 0xba,
0xaf, 0xf2, 0xa1, 0x54, 0x14, 0x21, 0x3e, 0x24, 0x18, 0x5b, 0x07, 0xd2, 0x40, 0xa2, 0x95, 0xbb,
0x23, 0x4e, 0x2a, 0x2f, 0xf5, 0xb2, 0x48, 0x89, 0x1d, 0x39, 0xee, 0x46, 0x2f, 0x81, 0x03, 0x2e,
0x86, 0x5b, 0xe1, 0x8a, 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6a, 0x9e,
0x69, 0xef, 0x7b, 0x8b, 0x9d, 0x35, 0x0b, 0xce, 0xe4, 0x8f, 0x76, 0x60, 0x35, 0xf9, 0xf9, 0x81,
0x8b, 0x90, 0x48, 0xf5, 0x6c, 0xf4, 0xd5, 0x3b, 0x7d, 0x32, 0x3e, 0xad, 0x2f, 0xa1, 0x0a, 0x94,
0x3e, 0x0e, 0x7a, 0x9f, 0xeb, 0xd6, 0xc1, 0x26, 0xac, 0xb9, 0x3c, 0xcc, 0x54, 0x3d, 0xa8, 0x25,
0x9c, 0x56, 0x7f, 0x29, 0xa9, 0x5f, 0x27, 0x65, 0xfd, 0xc4, 0x3f, 0xfb, 0x15, 0x00, 0x00, 0xff,
0xff, 0x1c, 0xfa, 0xca, 0xe6, 0x04, 0x07, 0x00, 0x00,
}

View File

@ -5,8 +5,6 @@ option go_package = "core";
option java_package = "com.v2ray.core";
option java_outer_classname = "ConfigProto";
import "v2ray.com/core/app/router/config.proto";
import "v2ray.com/core/app/dns/config.proto";
import "v2ray.com/core/common/loader/type.proto";
import "v2ray.com/core/common/net/port.proto";
import "v2ray.com/core/common/net/address.proto";
@ -70,7 +68,6 @@ message Config {
repeated InboundConnectionConfig inbound = 1;
repeated OutboundConnectionConfig outbound = 2;
v2ray.core.common.log.Config log = 3;
v2ray.core.app.router.Config router = 4;
v2ray.core.app.dns.Config dns = 5;
v2ray.core.transport.Config transport = 6;
repeated v2ray.core.common.loader.TypedSettings app = 4;
v2ray.core.transport.Config transport = 5;
}

View File

@ -4,9 +4,7 @@ import (
"v2ray.com/core/app"
"v2ray.com/core/app/dispatcher"
dispatchers "v2ray.com/core/app/dispatcher/impl"
"v2ray.com/core/app/dns"
"v2ray.com/core/app/proxyman"
"v2ray.com/core/app/router"
"v2ray.com/core/common"
"v2ray.com/core/common/log"
"v2ray.com/core/proxy"
@ -21,8 +19,7 @@ type Point struct {
outboundHandlers []proxy.OutboundHandler
taggedOutboundHandlers map[string]proxy.OutboundHandler
router *router.Router
space app.Space
space app.Space
}
// NewPoint returns a new Point server based on given configuration.
@ -38,23 +35,21 @@ func NewPoint(pConfig *Config) (*Point, error) {
return nil, err
}
vpoint.space = app.NewSpace()
space := app.NewSpace()
vpoint.space = space
vpoint.space.BindApp(proxyman.APP_ID_INBOUND_MANAGER, vpoint)
outboundHandlerManager := proxyman.NewDefaultOutboundHandlerManager()
vpoint.space.BindApp(proxyman.APP_ID_OUTBOUND_MANAGER, outboundHandlerManager)
dnsConfig := pConfig.Dns
if dnsConfig != nil {
dnsServer := dns.NewCacheServer(vpoint.space, dnsConfig)
vpoint.space.BindApp(dns.APP_ID, dnsServer)
}
routerConfig := pConfig.Router
if routerConfig != nil {
r := router.NewRouter(routerConfig, vpoint.space)
vpoint.space.BindApp(router.APP_ID, r)
vpoint.router = r
for _, app := range pConfig.App {
settings, err := app.GetInstance()
if err != nil {
return nil, err
}
if err := space.BindFromConfig(app.Type, settings); err != nil {
return nil, err
}
}
vpoint.space.BindApp(dispatcher.APP_ID, dispatchers.NewDefaultDispatcher(vpoint.space))