1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-11-23 12:02:58 -05:00

introduce app.Space

This commit is contained in:
v2ray
2015-12-05 22:55:45 +01:00
parent db7d48e48f
commit 15e6e6d80c
11 changed files with 68 additions and 39 deletions

View File

@@ -14,16 +14,16 @@ import (
)
type DokodemoDoor struct {
config *json.DokodemoConfig
accepting bool
address v2net.Address
dispatcher app.PacketDispatcher
config *json.DokodemoConfig
accepting bool
address v2net.Address
space *app.Space
}
func NewDokodemoDoor(dispatcher app.PacketDispatcher, config *json.DokodemoConfig) *DokodemoDoor {
func NewDokodemoDoor(space *app.Space, config *json.DokodemoConfig) *DokodemoDoor {
d := &DokodemoDoor{
config: config,
dispatcher: dispatcher,
config: config,
space: space,
}
ip := net.ParseIP(config.Host)
if ip != nil {
@@ -79,7 +79,7 @@ func (this *DokodemoDoor) handleUDPPackets(udpConn *net.UDPConn) {
}
packet := v2net.NewPacket(v2net.NewUDPDestination(this.address), buffer, false)
ray := this.dispatcher.DispatchToOutbound(packet)
ray := this.space.PacketDispatcher().DispatchToOutbound(packet)
close(ray.InboundInput())
for payload := range ray.InboundOutput() {
@@ -120,7 +120,7 @@ func (this *DokodemoDoor) HandleTCPConnection(conn *net.TCPConn) {
defer conn.Close()
packet := v2net.NewPacket(v2net.NewTCPDestination(this.address), nil, true)
ray := this.dispatcher.DispatchToOutbound(packet)
ray := this.space.PacketDispatcher().DispatchToOutbound(packet)
var inputFinish, outputFinish sync.Mutex
inputFinish.Lock()