2015-12-11 06:01:20 -05:00
|
|
|
package internal
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/v2ray/v2ray-core/app"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Space struct {
|
|
|
|
packetDispatcher PacketDispatcherWithContext
|
|
|
|
dnsCache DnsCacheWithContext
|
2015-12-11 09:56:10 -05:00
|
|
|
pubsub PubsubWithContext
|
2015-12-11 06:01:20 -05:00
|
|
|
tag string
|
|
|
|
}
|
|
|
|
|
2015-12-11 09:56:10 -05:00
|
|
|
func NewSpace(tag string, packetDispatcher PacketDispatcherWithContext, dnsCache DnsCacheWithContext, pubsub PubsubWithContext) *Space {
|
2015-12-11 06:01:20 -05:00
|
|
|
return &Space{
|
|
|
|
tag: tag,
|
|
|
|
packetDispatcher: packetDispatcher,
|
|
|
|
dnsCache: dnsCache,
|
2015-12-11 09:56:10 -05:00
|
|
|
pubsub: pubsub,
|
2015-12-11 06:01:20 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *Space) HasPacketDispatcher() bool {
|
|
|
|
return this.packetDispatcher != nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *Space) PacketDispatcher() app.PacketDispatcher {
|
|
|
|
return &contextedPacketDispatcher{
|
|
|
|
packetDispatcher: this.packetDispatcher,
|
|
|
|
context: &contextImpl{
|
|
|
|
callerTag: this.tag,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *Space) HasDnsCache() bool {
|
|
|
|
return this.dnsCache != nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *Space) DnsCache() app.DnsCache {
|
|
|
|
return &contextedDnsCache{
|
|
|
|
dnsCache: this.dnsCache,
|
|
|
|
context: &contextImpl{
|
|
|
|
callerTag: this.tag,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2015-12-11 09:56:10 -05:00
|
|
|
|
|
|
|
func (this *Space) HasPubsub() bool {
|
|
|
|
return this.pubsub != nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *Space) Pubsub() app.Pubsub {
|
|
|
|
return &contextedPubsub{
|
|
|
|
pubsub: this.pubsub,
|
|
|
|
context: &contextImpl{
|
|
|
|
callerTag: this.tag,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|