Skip to content

Commit

Permalink
Use separate smart dialer config
Browse files Browse the repository at this point in the history
  • Loading branch information
myleshorton committed Jan 9, 2025
1 parent 2c08c61 commit a20e0f4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
21 changes: 7 additions & 14 deletions kindling.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package kindling
import (
"context"
"crypto/x509"
"embed"
"log/slog"
"net"
"net/http"
Expand Down Expand Up @@ -112,6 +113,9 @@ func newSmartRoundTripper(domains ...string) http.RoundTripper {
}
}

//go:embed smart_dialer_config.json
var embedFS embed.FS

func newSmartDialer(domains ...string) transport.StreamDialer {
finder := &smart.StrategyFinder{
TestTimeout: 5 * time.Second,
Expand All @@ -120,21 +124,10 @@ func newSmartDialer(domains ...string) transport.StreamDialer {
PacketDialer: &transport.UDPDialer{},
}

configBytes := []byte(`
{
"dns": [
{"system": {}},
{"https": {"name": "8.8.8.8"}},
{"https": {"name": "9.9.9.9"}}
],
"tls": [
"",
"split:2",
"tlsfrag:1"
]
configBytes, err := embedFS.ReadFile("smart_dialer_config.json")
if err != nil {
slog.Error("Failed to read smart dialer config", "error", err)
}
`)

dialer, err := finder.NewDialer(context.Background(), domains, configBytes)
if err != nil {
slog.Error("Failed to create smart dialer", "error", err)
Expand Down
15 changes: 15 additions & 0 deletions smart_dialer_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"dns": [
{"system": {}},
{"https": {"name": "cloudflare-dns.com.", "address": "cloudflare.net."}},
{"https": {"name": "doh.dns.sb", "address": "cloudflare.net:443"}, "//": "DNS.SB"},
{"https": {"name": "223.5.5.5"}}
],
"tls": [
"",
"split:1",
"split:2",
"tlsfrag:1",
"disorder:1"
]
}

0 comments on commit a20e0f4

Please sign in to comment.