mirror of
https://github.com/cmz0228/hysteria-dev.git
synced 2025-06-08 13:29:53 +00:00
feat: custom resolver
This commit is contained in:
parent
b68af5cbe2
commit
c09edb6e53
@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"io"
|
||||
@ -27,6 +28,16 @@ import (
|
||||
|
||||
func client(config *clientConfig) {
|
||||
logrus.WithField("config", config.String()).Info("Client configuration loaded")
|
||||
// Resolver
|
||||
if len(config.Resolver) > 0 {
|
||||
net.DefaultResolver = &net.Resolver{
|
||||
PreferGo: true,
|
||||
Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
|
||||
d := net.Dialer{}
|
||||
return d.DialContext(ctx, "udp", config.Resolver)
|
||||
},
|
||||
}
|
||||
}
|
||||
// TLS
|
||||
tlsConfig := &tls.Config{
|
||||
ServerName: config.ServerName,
|
||||
|
@ -48,6 +48,7 @@ type serverConfig struct {
|
||||
MaxConnClient int `json:"max_conn_client"`
|
||||
DisableMTUDiscovery bool `json:"disable_mtu_discovery"`
|
||||
IPv6Only bool `json:"ipv6_only"`
|
||||
Resolver string `json:"resolver"`
|
||||
}
|
||||
|
||||
func (c *serverConfig) Check() error {
|
||||
@ -146,6 +147,7 @@ type clientConfig struct {
|
||||
ReceiveWindowConn uint64 `json:"recv_window_conn"`
|
||||
ReceiveWindow uint64 `json:"recv_window"`
|
||||
DisableMTUDiscovery bool `json:"disable_mtu_discovery"`
|
||||
Resolver string `json:"resolver"`
|
||||
}
|
||||
|
||||
func (c *clientConfig) Check() error {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/lucas-clemente/quic-go/congestion"
|
||||
@ -22,6 +23,16 @@ import (
|
||||
|
||||
func server(config *serverConfig) {
|
||||
logrus.WithField("config", config.String()).Info("Server configuration loaded")
|
||||
// Resolver
|
||||
if len(config.Resolver) > 0 {
|
||||
net.DefaultResolver = &net.Resolver{
|
||||
PreferGo: true,
|
||||
Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
|
||||
d := net.Dialer{}
|
||||
return d.DialContext(ctx, "udp", config.Resolver)
|
||||
},
|
||||
}
|
||||
}
|
||||
// Load TLS config
|
||||
var tlsConfig *tls.Config
|
||||
if len(config.ACME.Domains) > 0 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user