2015-12-11 06:01:20 -05:00
|
|
|
package controller
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/v2ray/v2ray-core/app"
|
|
|
|
"github.com/v2ray/v2ray-core/app/internal"
|
|
|
|
)
|
|
|
|
|
|
|
|
// A SpaceController is supposed to be used by a shell to create Spaces. It should not be used
|
|
|
|
// directly by proxies.
|
|
|
|
type SpaceController struct {
|
|
|
|
packetDispatcher internal.PacketDispatcherWithContext
|
|
|
|
dnsCache internal.DnsCacheWithContext
|
2015-12-11 09:56:10 -05:00
|
|
|
pubsub internal.PubsubWithContext
|
2015-12-11 06:01:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func New() *SpaceController {
|
|
|
|
return new(SpaceController)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *SpaceController) Bind(object interface{}) {
|
|
|
|
if packetDispatcher, ok := object.(internal.PacketDispatcherWithContext); ok {
|
|
|
|
this.packetDispatcher = packetDispatcher
|
|
|
|
}
|
|
|
|
|
|
|
|
if dnsCache, ok := object.(internal.DnsCacheWithContext); ok {
|
|
|
|
this.dnsCache = dnsCache
|
|
|
|
}
|
2015-12-11 09:56:10 -05:00
|
|
|
|
|
|
|
if pubsub, ok := object.(internal.PubsubWithContext); ok {
|
|
|
|
this.pubsub = pubsub
|
|
|
|
}
|
2015-12-11 06:01:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *SpaceController) ForContext(tag string) app.Space {
|
2015-12-11 09:56:10 -05:00
|
|
|
return internal.NewSpace(tag, this.packetDispatcher, this.dnsCache, this.pubsub)
|
2015-12-11 06:01:20 -05:00
|
|
|
}
|