Set a short timeout for dns

This commit is contained in:
Fangliding 2024-12-27 02:12:05 +08:00
parent 2782f13279
commit d0911cec88

View File

@ -114,7 +114,14 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn st
plcy := d.policy()
ctx, cancel := context.WithCancel(ctx)
timer := signal.CancelAfterInactivity(ctx, cancel, plcy.Timeouts.ConnectionIdle)
var timer *signal.ActivityTimer
// if dns req, set a short timeout value
if dest.Port == 53 {
timer = signal.CancelAfterInactivity(ctx, cancel, 10*time.Second)
} else {
timer = signal.CancelAfterInactivity(ctx, cancel, plcy.Timeouts.ConnectionIdle)
}
if inbound != nil {
inbound.Timer = timer