1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-01 23:15:21 -05:00

Parse config just once

This commit is contained in:
V2Ray
2015-09-22 18:11:55 +02:00
parent 338300248c
commit ec83281d18
4 changed files with 25 additions and 6 deletions

View File

@@ -64,7 +64,8 @@ type InboundConnectionHandler interface {
}
type OutboundConnectionHandlerFactory interface {
Create(VP *Point, config []byte, firstPacket v2net.Packet) (OutboundConnectionHandler, error)
Initialize(config []byte) error
Create(VP *Point, firstPacket v2net.Packet) (OutboundConnectionHandler, error)
}
type OutboundConnectionHandler interface {
@@ -77,6 +78,9 @@ func (vp *Point) Start() error {
if vp.port <= 0 {
return log.Error("Invalid port %d", vp.port)
}
vp.ochFactory.Initialize(vp.ochConfig)
inboundConnectionHandler, err := vp.ichFactory.Create(vp, vp.ichConfig)
if err != nil {
return err
@@ -88,7 +92,7 @@ func (vp *Point) Start() error {
func (p *Point) DispatchToOutbound(packet v2net.Packet) InboundRay {
ray := NewRay()
// TODO: handle error
och, _ := p.ochFactory.Create(p, p.ochConfig, packet)
och, _ := p.ochFactory.Create(p, packet)
_ = och.Start(ray)
return ray
}