v2ray-core/app/space.go

37 lines
690 B
Go
Raw Normal View History

2015-12-05 21:55:45 +00:00
package app
type Space struct {
packetDispatcher PacketDispatcher
2015-12-06 10:00:10 +00:00
dnsCache DnsCache
2015-12-05 21:55:45 +00:00
}
func NewSpace() *Space {
return new(Space)
}
2015-12-06 10:00:10 +00:00
func (this *Space) Bind(object interface{}) {
if packetDispatcher, ok := object.(PacketDispatcher); ok {
this.packetDispatcher = packetDispatcher
}
if dnsCache, ok := object.(DnsCache); ok {
this.dnsCache = dnsCache
}
}
2015-12-05 21:55:45 +00:00
func (this *Space) HasPacketDispatcher() bool {
return this.packetDispatcher != nil
}
func (this *Space) PacketDispatcher() PacketDispatcher {
return this.packetDispatcher
}
2015-12-06 10:00:10 +00:00
func (this *Space) HasDnsCache() bool {
return this.dnsCache != nil
}
func (this *Space) DnsCache() DnsCache {
return this.dnsCache
2015-12-05 21:55:45 +00:00
}