mosdns: update to 3.0.0

This commit is contained in:
Tianling Shen 2022-01-07 06:21:47 +00:00 committed by Beginner-Go
parent 526b252a6c
commit 3e55445e8f
4 changed files with 86 additions and 2 deletions

View File

@ -5,12 +5,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=mosdns
PKG_VERSION:=2.2.2
PKG_VERSION:=3.0.0
PKG_RELEASE:=$(AUTORELEASE)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/IrineSistiana/mosdns/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=ff1c2c22dc9fa258309ef533ff007c7140d2f08fae69a923a39781458f906bd4
PKG_HASH:=f9e0ff34e4ae0345f0887c47840128f850d7400c6d407242d3848a6462547e58
PKG_LICENSE:=GPL-3.0
PKG_LICENSE_FILE:=LICENSE

View File

@ -0,0 +1,30 @@
From 0565ec359eb16b7cf10dcab9dd8e5be221ed9539 Mon Sep 17 00:00:00 2001
From: IrineSistiana <49315432+IrineSistiana@users.noreply.github.com>
Date: Thu, 6 Jan 2022 16:50:46 +0800
Subject: [PATCH] redis_cache: fixed cache could store a key with zero ttl
---
dispatcher/pkg/cache/redis_cache/redis_cache.go | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
--- a/dispatcher/pkg/cache/redis_cache/redis_cache.go
+++ b/dispatcher/pkg/cache/redis_cache/redis_cache.go
@@ -61,14 +61,16 @@ func (r *RedisCache) Get(ctx context.Con
}
func (r *RedisCache) Store(ctx context.Context, key string, v []byte, storedTime, expirationTime time.Time) error {
- if time.Now().After(expirationTime) {
+ now := time.Now()
+ ttl := expirationTime.Sub(now)
+ if ttl <= 0 { // For redis, zero ttl means the key has no expiration time.
return nil
}
data := packRedisData(storedTime, expirationTime, v)
defer pool.ReleaseBuf(data)
- return r.client.Set(ctx, key, data, expirationTime.Sub(time.Now())).Err()
+ return r.client.Set(ctx, key, data, ttl).Err()
}
// Close closes the redis client.

View File

@ -0,0 +1,27 @@
From 653c7a03222d9135a6f9bfbeff3aaddc300762b4 Mon Sep 17 00:00:00 2001
From: IrineSistiana <49315432+IrineSistiana@users.noreply.github.com>
Date: Thu, 6 Jan 2022 19:59:33 +0800
Subject: [PATCH] fixed #240
---
dispatcher/plugin/executable/forward/forward.go | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
--- a/dispatcher/plugin/executable/forward/forward.go
+++ b/dispatcher/plugin/executable/forward/forward.go
@@ -158,8 +158,13 @@ func (f *forwardPlugin) Exec(ctx context
func (f *forwardPlugin) exec(ctx context.Context, qCtx *handler.Context) error {
var r *dns.Msg
var err error
- if f.fastIPHandler != nil {
- r, _, err = f.fastIPHandler.ExchangeFastest(qCtx.Q().Copy(), f.upstreams)
+ q := qCtx.Q()
+ if f.fastIPHandler != nil && len(q.Question) == 1 {
+ // Only call ExchangeFastest if the query has one question.
+ // ExchangeFastest will use the first question name as host name.
+ // It won't check questions range. So it will it panic if len(q.Question) == 0.
+ // Ref: https://github.com/IrineSistiana/mosdns/issues/240
+ r, _, err = f.fastIPHandler.ExchangeFastest(q.Copy(), f.upstreams)
} else {
r, err = f.bu.ExchangeParallel(ctx, qCtx)
}

View File

@ -0,0 +1,27 @@
From 189e1c810fcdda95fee732fb37ba73e08055989f Mon Sep 17 00:00:00 2001
From: IrineSistiana <49315432+IrineSistiana@users.noreply.github.com>
Date: Thu, 6 Jan 2022 23:07:28 +0800
Subject: [PATCH] fixed nil pointer in 653c7a03222d9135a6f9bfbeff3aaddc300762b4
#240
---
dispatcher/plugin/executable/forward/forward.go | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
--- a/dispatcher/plugin/executable/forward/forward.go
+++ b/dispatcher/plugin/executable/forward/forward.go
@@ -116,12 +116,11 @@ func newForwarder(bp *handler.BP, args *
})
}
+ f.bu = bundled_upstream.NewBundledUpstream(bu, bp.L())
+
if args.FastestIP {
f.fastIPHandler = fastip.NewFastestAddr()
- } else {
- f.bu = bundled_upstream.NewBundledUpstream(bu, bp.L())
}
-
return f, nil
}