mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-10-08 08:40:01 +00:00
https://github.com/XTLS/Xray-core/pull/7090#issuecomment-5989883544 https://github.com/XTLS/Xray-core/pull/7090#issuecomment-5988755551 https://github.com/XTLS/Xray-core/pull/7089#issuecomment-5987266008
27 lines
476 B
Go
27 lines
476 B
Go
package xdns
|
|
|
|
import (
|
|
"errors"
|
|
"net"
|
|
|
|
"github.com/xtls/xray-core/transport/internet/finalmask"
|
|
)
|
|
|
|
type Resolver interface {
|
|
Addr() *net.UDPAddr
|
|
Read(p []byte) (int, error)
|
|
Send(p []byte)
|
|
Close()
|
|
}
|
|
|
|
func NewResolver(config *ResolverProto, dialer *finalmask.Dialer) (Resolver, error) {
|
|
switch config.Type {
|
|
case "tcp":
|
|
return NewTCPResolver(config, dialer)
|
|
case "udp":
|
|
return NewUDPResolver(config, dialer)
|
|
default:
|
|
return nil, errors.New("unknown type")
|
|
}
|
|
}
|