mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-01-06 01:05:35 -05:00
Merge branch 'master' of github.com:v2ray/v2ray-core into domainsocket
This commit is contained in:
@@ -21,18 +21,13 @@ type DokodemoDoor struct {
|
||||
config *Config
|
||||
address net.Address
|
||||
port net.Port
|
||||
v *core.Instance
|
||||
}
|
||||
|
||||
func New(ctx context.Context, config *Config) (*DokodemoDoor, error) {
|
||||
if config.NetworkList == nil || config.NetworkList.Size() == 0 {
|
||||
return nil, newError("no network specified")
|
||||
}
|
||||
v := core.FromContext(ctx)
|
||||
if v == nil {
|
||||
return nil, newError("V is not in context.")
|
||||
}
|
||||
|
||||
v := core.MustFromContext(ctx)
|
||||
d := &DokodemoDoor{
|
||||
config: config,
|
||||
address: config.GetPredefinedAddress(),
|
||||
@@ -57,7 +52,7 @@ func (d *DokodemoDoor) policy() core.Policy {
|
||||
}
|
||||
|
||||
func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn internet.Connection, dispatcher core.Dispatcher) error {
|
||||
newError("processing connection from: ", conn.RemoteAddr()).AtDebug().WriteToLog()
|
||||
newError("processing connection from: ", conn.RemoteAddr()).AtDebug().WithContext(ctx).WriteToLog()
|
||||
dest := net.Destination{
|
||||
Network: network,
|
||||
Address: d.address,
|
||||
@@ -82,6 +77,7 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in
|
||||
|
||||
requestDone := signal.ExecuteAsync(func() error {
|
||||
defer inboundRay.InboundInput().Close()
|
||||
defer timer.SetTimeout(d.policy().Timeouts.DownlinkOnly)
|
||||
|
||||
chunkReader := buf.NewReader(conn)
|
||||
|
||||
@@ -89,12 +85,12 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in
|
||||
return newError("failed to transport request").Base(err)
|
||||
}
|
||||
|
||||
timer.SetTimeout(d.policy().Timeouts.DownlinkOnly)
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
responseDone := signal.ExecuteAsync(func() error {
|
||||
defer timer.SetTimeout(d.policy().Timeouts.UplinkOnly)
|
||||
|
||||
var writer buf.Writer
|
||||
if network == net.Network_TCP {
|
||||
writer = buf.NewWriter(conn)
|
||||
@@ -116,8 +112,6 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in
|
||||
return newError("failed to transport response").Base(err)
|
||||
}
|
||||
|
||||
timer.SetTimeout(d.policy().Timeouts.UplinkOnly)
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user