mirror of
https://github.com/kenzok8/small.git
synced 2025-01-05 10:36:40 +08:00
update 2024-12-18 00:17:34
This commit is contained in:
parent
f806b58433
commit
ce1a0749e4
@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=mosdns
|
||||
PKG_VERSION:=5.3.3
|
||||
PKG_RELEASE:=2
|
||||
PKG_RELEASE:=3
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/IrineSistiana/mosdns/tar.gz/v$(PKG_VERSION)?
|
||||
|
@ -1,12 +1,12 @@
|
||||
From 348bc3f68c676de929e74accc75e62d01ea999be Mon Sep 17 00:00:00 2001
|
||||
From: Henry-ZHR <henry-zhr@qq.com>
|
||||
Date: Mon, 16 Sep 2024 10:59:42 +0800
|
||||
Subject: [PATCH] forward: avoid picking same upstream
|
||||
From f5d190ab1542b96688353eeb3d3d5c46fbad8b7c Mon Sep 17 00:00:00 2001
|
||||
From: Irine Sistiana <49315432+IrineSistiana@users.noreply.github.com>
|
||||
Date: Wed, 11 Dec 2024 20:49:42 +0800
|
||||
Subject: [PATCH 1/2] forward: avoid picking same upstream if concurrent > 2
|
||||
|
||||
---
|
||||
plugin/executable/forward/forward.go | 7 ++++++-
|
||||
plugin/executable/forward/forward.go | 4 +++-
|
||||
plugin/executable/forward/utils.go | 5 -----
|
||||
2 files changed, 6 insertions(+), 6 deletions(-)
|
||||
2 files changed, 3 insertions(+), 6 deletions(-)
|
||||
|
||||
--- a/plugin/executable/forward/forward.go
|
||||
+++ b/plugin/executable/forward/forward.go
|
||||
@ -14,28 +14,18 @@ Subject: [PATCH] forward: avoid picking same upstream
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
+ "math/rand"
|
||||
+ "math/rand/v2"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -251,6 +252,9 @@ func (f *Forward) exchange(ctx context.C
|
||||
if concurrent > maxConcurrentQueries {
|
||||
concurrent = maxConcurrentQueries
|
||||
}
|
||||
+ if concurrent > len(us) {
|
||||
+ concurrent = len(us)
|
||||
+ }
|
||||
|
||||
type res struct {
|
||||
r *dns.Msg
|
||||
@@ -261,8 +265,9 @@ func (f *Forward) exchange(ctx context.C
|
||||
@@ -261,8 +262,9 @@ func (f *Forward) exchange(ctx context.C
|
||||
done := make(chan struct{})
|
||||
defer close(done)
|
||||
|
||||
+ p := rand.Perm(len(us))
|
||||
+ r := rand.IntN(len(us))
|
||||
for i := 0; i < concurrent; i++ {
|
||||
- u := randPick(us)
|
||||
+ u := us[p[i]]
|
||||
+ u := us[(r+i)%len(us)]
|
||||
qc := copyPayload(queryPayload)
|
||||
go func(uqid uint32, question dns.Question) {
|
||||
defer pool.ReleaseBuf(qc)
|
@ -0,0 +1,36 @@
|
||||
From f20baf28be3e18cef0a4695d25db202dbc124300 Mon Sep 17 00:00:00 2001
|
||||
From: Irine Sistiana <49315432+IrineSistiana@users.noreply.github.com>
|
||||
Date: Wed, 11 Dec 2024 20:51:12 +0800
|
||||
Subject: [PATCH 2/2] upstream: resend udp package every 1s
|
||||
|
||||
---
|
||||
pkg/upstream/transport/conn_traditional.go | 15 +++++++++++++++
|
||||
1 file changed, 15 insertions(+)
|
||||
|
||||
--- a/pkg/upstream/transport/conn_traditional.go
|
||||
+++ b/pkg/upstream/transport/conn_traditional.go
|
||||
@@ -124,9 +124,24 @@ func (dc *TraditionalDnsConn) exchange(c
|
||||
dc.c.SetReadDeadline(time.Now().Add(waitingReplyTimeout))
|
||||
}
|
||||
|
||||
+ var resend <-chan time.Time
|
||||
+ if !dc.isTcp {
|
||||
+ ticker := time.NewTicker(time.Second)
|
||||
+ resend = ticker.C
|
||||
+ defer ticker.Stop()
|
||||
+ }
|
||||
+
|
||||
+wait:
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil, context.Cause(ctx)
|
||||
+ case <-resend:
|
||||
+ err := dc.writeQuery(q, assignedQid)
|
||||
+ if err != nil {
|
||||
+ dc.CloseWithErr(fmt.Errorf("write err, %w", err))
|
||||
+ return nil, err
|
||||
+ }
|
||||
+ goto wait
|
||||
case r := <-respChan:
|
||||
orgId := binary.BigEndian.Uint16(q)
|
||||
binary.BigEndian.PutUint16(*r, orgId)
|
Loading…
Reference in New Issue
Block a user