mirror of
https://github.com/xvzc/SpoofDPI.git
synced 2024-12-22 22:36:53 +00:00
29 lines
487 B
Go
29 lines
487 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
)
|
|
|
|
type SystemResolver struct {
|
|
*net.Resolver
|
|
}
|
|
|
|
func NewSystemClient() *SystemResolver {
|
|
return &SystemResolver{
|
|
&net.Resolver{PreferGo: true},
|
|
}
|
|
}
|
|
|
|
func (r *SystemResolver) String() string {
|
|
return "system client"
|
|
}
|
|
|
|
func (r *SystemResolver) Resolve(ctx context.Context, host string, qTypes []uint16) ([]net.IPAddr, error) {
|
|
addrs, err := r.LookupIPAddr(ctx, host)
|
|
if err != nil {
|
|
return []net.IPAddr{}, err
|
|
}
|
|
return addrs, nil
|
|
}
|