mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-10-30 03:55:13 +08:00
update 2026-09-24 16:56:26
This commit is contained in:
1 parent
b31a5c3878
commit
e4cee331e9
6885 files changed
+3240523
No files matched your search
@@ -0,0 +1,44 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
#
|
||||
# Copyright (C) 2021 ImmortalWrt.org
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=mosdns
|
||||
PKG_VERSION:=5.3.4
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/IrineSistiana/mosdns/tar.gz/v$(PKG_VERSION)?
|
||||
PKG_HASH:=0302a685db2a6c3c09af7bf4ff0dffd24f1e583383a47f064564f5270033671b
|
||||
|
||||
PKG_LICENSE:=GPL-3.0
|
||||
PKG_LICENSE_FILE:=LICENSE
|
||||
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
|
||||
|
||||
PKG_BUILD_DEPENDS:=golang/host
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_USE_MIPS16:=0
|
||||
PKG_BUILD_FLAGS:=no-mips16
|
||||
|
||||
GO_PKG:=github.com/IrineSistiana/mosdns
|
||||
GO_PKG_LDFLAGS_X:=main.version=v$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
|
||||
|
||||
define Package/mosdns
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=IP Addresses and Names
|
||||
TITLE:=A plug-in DNS forwarder/splitter
|
||||
URL:=https://github.com/IrineSistiana/mosdns
|
||||
DEPENDS:=$(GO_ARCH_DEPENDS) +ca-bundle
|
||||
endef
|
||||
|
||||
define Package/mosdns/install
|
||||
$(call GoPackage/Package/Install/Bin,$(1))
|
||||
endef
|
||||
|
||||
$(eval $(call GoBinPackage,mosdns))
|
||||
$(eval $(call BuildPackage,mosdns))
|
||||
@@ -0,0 +1,19 @@
|
||||
From 0b86b89629f32e7c8b859239aa1a4814f256053c Mon Sep 17 00:00:00 2001
|
||||
From: sbwml <admin@cooluc.com>
|
||||
Date: Thu, 28 Sep 2023 16:42:54 +0800
|
||||
Subject: [PATCH 3/5] add response for bad request in ServeHTTP handler
|
||||
|
||||
---
|
||||
pkg/server/http_handler.go | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
--- a/pkg/server/http_handler.go
|
||||
+++ b/pkg/server/http_handler.go
|
||||
@@ -93,6 +93,7 @@ func (h *HttpHandler) ServeHTTP(w http.R
|
||||
if err != nil {
|
||||
h.warnErr(req, "invalid request", err)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
+ w.Write([]byte("Bad Request"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
From e34dca717e78d24a84b98c2b5d371c4253b7e260 Mon Sep 17 00:00:00 2001
|
||||
From: sbwml <admin@cooluc.com>
|
||||
Date: Wed, 20 Sep 2023 14:51:19 +0800
|
||||
Subject: [PATCH 4/5] black_hole: apply Fisher-Yates shuffle algorithm to
|
||||
randomize IP order
|
||||
|
||||
---
|
||||
plugin/executable/black_hole/black_hole.go | 15 +++++++++++++++
|
||||
1 file changed, 15 insertions(+)
|
||||
|
||||
--- a/plugin/executable/black_hole/black_hole.go
|
||||
+++ b/plugin/executable/black_hole/black_hole.go
|
||||
@@ -27,6 +27,8 @@ import (
|
||||
"github.com/miekg/dns"
|
||||
"net/netip"
|
||||
"strings"
|
||||
+ "math/rand"
|
||||
+ "sync"
|
||||
)
|
||||
|
||||
const PluginType = "black_hole"
|
||||
@@ -40,6 +42,7 @@ var _ sequence.Executable = (*BlackHole)
|
||||
type BlackHole struct {
|
||||
ipv4 []netip.Addr
|
||||
ipv6 []netip.Addr
|
||||
+ shuffleMutex sync.Mutex
|
||||
}
|
||||
|
||||
// QuickSetup format: [ipv4|ipv6] ...
|
||||
@@ -65,9 +68,21 @@ func NewBlackHole(ips []string) (*BlackH
|
||||
return b, nil
|
||||
}
|
||||
|
||||
+func (b *BlackHole) shuffleIPs() {
|
||||
+ b.shuffleMutex.Lock()
|
||||
+ defer b.shuffleMutex.Unlock()
|
||||
+ rand.Shuffle(len(b.ipv4), func(i, j int) {
|
||||
+ b.ipv4[i], b.ipv4[j] = b.ipv4[j], b.ipv4[i]
|
||||
+ })
|
||||
+ rand.Shuffle(len(b.ipv6), func(i, j int) {
|
||||
+ b.ipv6[i], b.ipv6[j] = b.ipv6[j], b.ipv6[i]
|
||||
+ })
|
||||
+}
|
||||
+
|
||||
// Exec implements sequence.Executable. It set a response with given ips if
|
||||
// query has corresponding qtypes.
|
||||
func (b *BlackHole) Exec(_ context.Context, qCtx *query_context.Context) error {
|
||||
+ b.shuffleIPs()
|
||||
if r := b.Response(qCtx.Q()); r != nil {
|
||||
qCtx.SetResponse(r)
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
From 2dc08749e2de8f19ef869e7f89c9979edbbc71ff Mon Sep 17 00:00:00 2001
|
||||
From: sbwml <admin@cooluc.com>
|
||||
Date: Wed, 20 Sep 2023 21:05:18 +0800
|
||||
Subject: [PATCH 5/5] format logtime
|
||||
|
||||
---
|
||||
mlog/logger.go | 18 ++++++++++++++----
|
||||
1 file changed, 14 insertions(+), 4 deletions(-)
|
||||
|
||||
--- a/mlog/logger.go
|
||||
+++ b/mlog/logger.go
|
||||
@@ -21,9 +21,11 @@ package mlog
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
+ "os"
|
||||
+ "time"
|
||||
+
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
- "os"
|
||||
)
|
||||
|
||||
type LogConfig struct {
|
||||
@@ -64,10 +66,18 @@ func NewLogger(lc LogConfig) (*zap.Logge
|
||||
out = stderr
|
||||
}
|
||||
|
||||
- if lc.Production {
|
||||
- return zap.New(zapcore.NewCore(zapcore.NewJSONEncoder(zap.NewProductionEncoderConfig()), out, lvl)), nil
|
||||
+ encoderConfig := zap.NewDevelopmentEncoderConfig()
|
||||
+ encoderConfig.EncodeTime = func(t time.Time, enc zapcore.PrimitiveArrayEncoder) {
|
||||
+ enc.AppendString(t.Format("2006-01-02 15:04:05"))
|
||||
}
|
||||
- return zap.New(zapcore.NewCore(zapcore.NewConsoleEncoder(zap.NewDevelopmentEncoderConfig()), out, lvl)), nil
|
||||
+
|
||||
+ core := zapcore.NewCore(
|
||||
+ zapcore.NewConsoleEncoder(encoderConfig),
|
||||
+ out,
|
||||
+ lvl,
|
||||
+ )
|
||||
+
|
||||
+ return zap.New(core), nil
|
||||
}
|
||||
|
||||
// L is a global logger.
|
||||
Reference in new issue
Block a user