添加重启endpoint
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
"223.6.6.6:53"
|
"223.6.6.6:53"
|
||||||
],
|
],
|
||||||
"timeout": 5000,
|
"timeout": 5000,
|
||||||
"statsFile": "./data/stats.json",
|
"statsFile": "data/stats.json",
|
||||||
"saveInterval": 300
|
"saveInterval": 300
|
||||||
},
|
},
|
||||||
"http": {
|
"http": {
|
||||||
|
|||||||
-10607
File diff suppressed because it is too large
Load Diff
-82585
File diff suppressed because it is too large
Load Diff
-53291
File diff suppressed because it is too large
Load Diff
-1176
File diff suppressed because it is too large
Load Diff
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"blockedDomainsCount": {},
|
|
||||||
"resolvedDomainsCount": {},
|
|
||||||
"lastSaved": "2025-11-27T18:23:48.562056138+08:00"
|
|
||||||
}
|
|
||||||
-3129
File diff suppressed because it is too large
Load Diff
BIN
Binary file not shown.
@@ -137,6 +137,22 @@ func NewServer(config *config.DNSConfig, shieldConfig *config.ShieldConfig, shie
|
|||||||
|
|
||||||
// Start 启动DNS服务器
|
// Start 启动DNS服务器
|
||||||
func (s *Server) Start() error {
|
func (s *Server) Start() error {
|
||||||
|
// 重新初始化上下文和取消函数
|
||||||
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
s.ctx = ctx
|
||||||
|
s.cancel = cancel
|
||||||
|
|
||||||
|
// 重新初始化saveDone通道
|
||||||
|
s.saveDone = make(chan struct{})
|
||||||
|
|
||||||
|
// 重置stopped标志
|
||||||
|
s.stoppedMutex.Lock()
|
||||||
|
s.stopped = false
|
||||||
|
s.stoppedMutex.Unlock()
|
||||||
|
|
||||||
|
// 更新服务器启动时间
|
||||||
|
s.startTime = time.Now()
|
||||||
|
|
||||||
s.server = &dns.Server{
|
s.server = &dns.Server{
|
||||||
Addr: fmt.Sprintf(":%d", s.config.Port),
|
Addr: fmt.Sprintf(":%d", s.config.Port),
|
||||||
Net: "udp",
|
Net: "udp",
|
||||||
@@ -178,6 +194,16 @@ func (s *Server) Start() error {
|
|||||||
|
|
||||||
// Stop 停止DNS服务器
|
// Stop 停止DNS服务器
|
||||||
func (s *Server) Stop() {
|
func (s *Server) Stop() {
|
||||||
|
// 检查服务器是否已经停止
|
||||||
|
s.stoppedMutex.Lock()
|
||||||
|
if s.stopped {
|
||||||
|
s.stoppedMutex.Unlock()
|
||||||
|
return // 服务器已经停止,直接返回
|
||||||
|
}
|
||||||
|
// 标记服务器为已停止状态
|
||||||
|
s.stopped = true
|
||||||
|
s.stoppedMutex.Unlock()
|
||||||
|
|
||||||
// 发送停止信号给保存协程
|
// 发送停止信号给保存协程
|
||||||
close(s.saveDone)
|
close(s.saveDone)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
# DNS Server Hosts File
|
|
||||||
# Generated by DNS Server
|
|
||||||
|
|
||||||
::1 localhost
|
|
||||||
ad.qq.com 127.0.0.1
|
|
||||||
ad.qq.com 0.0.0.0
|
|
||||||
-52202
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user