luci-app-mosdns/mosdns/patches/106-fixed-707.patch
2023-09-18 14:59:04 +08:00

152 lines
5.6 KiB
Diff

From edd39f198bc34ba443983a277e40e6f87ca38da6 Mon Sep 17 00:00:00 2001
From: Irine Sistiana <49315432+IrineSistiana@users.noreply.github.com>
Date: Mon, 18 Sep 2023 10:36:43 +0800
Subject: [PATCH 07/10] fixed #707
---
plugin/executable/cache/cache.go | 19 ++++++++++---------
plugin/executable/cache/dump.pb.go | 18 +++++++++---------
plugin/executable/cache/dump.proto | 2 +-
3 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/plugin/executable/cache/cache.go b/plugin/executable/cache/cache.go
index 4091b50..58162ee 100644
--- a/plugin/executable/cache/cache.go
+++ b/plugin/executable/cache/cache.go
@@ -24,6 +24,14 @@ import (
"encoding/binary"
"errors"
"fmt"
+ "io"
+ "net/http"
+ "os"
+ "strconv"
+ "sync"
+ "sync/atomic"
+ "time"
+
"github.com/IrineSistiana/mosdns/v5/coremain"
"github.com/IrineSistiana/mosdns/v5/pkg/cache"
"github.com/IrineSistiana/mosdns/v5/pkg/pool"
@@ -37,13 +45,6 @@ import (
"go.uber.org/zap"
"golang.org/x/sync/singleflight"
"google.golang.org/protobuf/proto"
- "io"
- "net/http"
- "os"
- "strconv"
- "sync"
- "sync/atomic"
- "time"
)
const (
@@ -60,7 +61,7 @@ const (
expiredMsgTtl = 5
minimumChangesToDump = 1024
- dumpHeader = "mosdns_cache_v1"
+ dumpHeader = "mosdns_cache_v2"
dumpBlockSize = 128
dumpMaximumBlockLength = 1 << 20 // 1M block. 8kb pre entry. Should be enough.
)
@@ -379,7 +380,7 @@ func (c *Cache) writeDump(w io.Writer) (int, error) {
return fmt.Errorf("failed to pack msg, %w", err)
}
e := &CachedEntry{
- Key: string(k),
+ Key: []byte(k),
CacheExpirationTime: cacheExpirationTime.Unix(),
MsgExpirationTime: v.expirationTime.Unix(),
Msg: msg,
diff --git a/plugin/executable/cache/dump.pb.go b/plugin/executable/cache/dump.pb.go
index ba40b95..58a7f15 100644
--- a/plugin/executable/cache/dump.pb.go
+++ b/plugin/executable/cache/dump.pb.go
@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
-// protoc-gen-go v1.28.1
-// protoc v3.21.7
+// protoc-gen-go v1.31.0
+// protoc v4.24.3
// source: plugin/executable/cache/dump.proto
package cache
@@ -25,7 +25,7 @@ type CachedEntry struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
- Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
+ Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
Msg []byte `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"`
CacheExpirationTime int64 `protobuf:"varint,3,opt,name=cache_expiration_time,json=cacheExpirationTime,proto3" json:"cache_expiration_time,omitempty"`
MsgExpirationTime int64 `protobuf:"varint,4,opt,name=msg_expiration_time,json=msgExpirationTime,proto3" json:"msg_expiration_time,omitempty"`
@@ -64,11 +64,11 @@ func (*CachedEntry) Descriptor() ([]byte, []int) {
return file_plugin_executable_cache_dump_proto_rawDescGZIP(), []int{0}
}
-func (x *CachedEntry) GetKey() string {
+func (x *CachedEntry) GetKey() []byte {
if x != nil {
return x.Key
}
- return ""
+ return nil
}
func (x *CachedEntry) GetMsg() []byte {
@@ -153,7 +153,7 @@ var file_plugin_executable_cache_dump_proto_rawDesc = []byte{
0x62, 0x6c, 0x65, 0x2f, 0x63, 0x61, 0x63, 0x68, 0x65, 0x2f, 0x64, 0x75, 0x6d, 0x70, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x63, 0x61, 0x63, 0x68, 0x65, 0x22, 0xbd, 0x01, 0x0a, 0x0b,
0x43, 0x61, 0x63, 0x68, 0x65, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b,
- 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x10, 0x0a,
+ 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x10, 0x0a,
0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x12,
0x32, 0x0a, 0x15, 0x63, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x13,
@@ -185,7 +185,7 @@ func file_plugin_executable_cache_dump_proto_rawDescGZIP() []byte {
}
var file_plugin_executable_cache_dump_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
-var file_plugin_executable_cache_dump_proto_goTypes = []any{
+var file_plugin_executable_cache_dump_proto_goTypes = []interface{}{
(*CachedEntry)(nil), // 0: cache.CachedEntry
(*CacheDumpBlock)(nil), // 1: cache.CacheDumpBlock
}
@@ -204,7 +204,7 @@ func file_plugin_executable_cache_dump_proto_init() {
return
}
if !protoimpl.UnsafeEnabled {
- file_plugin_executable_cache_dump_proto_msgTypes[0].Exporter = func(v any, i int) any {
+ file_plugin_executable_cache_dump_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CachedEntry); i {
case 0:
return &v.state
@@ -216,7 +216,7 @@ func file_plugin_executable_cache_dump_proto_init() {
return nil
}
}
- file_plugin_executable_cache_dump_proto_msgTypes[1].Exporter = func(v any, i int) any {
+ file_plugin_executable_cache_dump_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CacheDumpBlock); i {
case 0:
return &v.state
diff --git a/plugin/executable/cache/dump.proto b/plugin/executable/cache/dump.proto
index 756e034..93f1106 100644
--- a/plugin/executable/cache/dump.proto
+++ b/plugin/executable/cache/dump.proto
@@ -5,7 +5,7 @@ package cache;
option go_package = "plugin/executable/cache";
message CachedEntry {
- string key = 1;
+ bytes key = 1;
bytes msg = 2;
int64 cache_expiration_time = 3;
int64 msg_expiration_time = 4;
--
2.34.8