mirror of https://github.com/fatedier/frp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
530 B
24 lines
530 B
8 years ago
|
package socks5
|
||
|
|
||
|
import (
|
||
|
"net"
|
||
|
|
||
|
"golang.org/x/net/context"
|
||
|
)
|
||
|
|
||
|
// NameResolver is used to implement custom name resolution
|
||
|
type NameResolver interface {
|
||
|
Resolve(ctx context.Context, name string) (context.Context, net.IP, error)
|
||
|
}
|
||
|
|
||
|
// DNSResolver uses the system DNS to resolve host names
|
||
|
type DNSResolver struct{}
|
||
|
|
||
|
func (d DNSResolver) Resolve(ctx context.Context, name string) (context.Context, net.IP, error) {
|
||
|
addr, err := net.ResolveIPAddr("ip", name)
|
||
|
if err != nil {
|
||
|
return ctx, nil, err
|
||
|
}
|
||
|
return ctx, addr.IP, err
|
||
|
}
|