mirror of
https://github.com/xvzc/SpoofDPI.git
synced 2025-01-03 04:50:11 +00:00
fix: make doh truly singleton
This commit is contained in:
parent
c93ddd67e0
commit
e9de332163
@ -8,6 +8,7 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
@ -20,8 +21,10 @@ type DoHClient struct {
|
||||
}
|
||||
|
||||
var client *DoHClient
|
||||
var clientOnce sync.Once
|
||||
|
||||
func GetDoHClient(upstream string) *DoHClient {
|
||||
clientOnce.Do(func() {
|
||||
if client == nil {
|
||||
if !strings.HasPrefix(upstream, "https://") {
|
||||
upstream = "https://" + upstream
|
||||
@ -49,6 +52,7 @@ func GetDoHClient(upstream string) *DoHClient {
|
||||
c: c,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return client
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user