mirror of
https://github.com/nadoo/glider.git
synced 2025-02-24 01:45:39 +08:00
dns: allow to resolve domain which in a reject rule
This commit is contained in:
parent
2e44d79db8
commit
4ece9ece25
@ -171,6 +171,7 @@ Available Schemes:
|
|||||||
unix: unix domain socket
|
unix: unix domain socket
|
||||||
kcp: kcp protocol
|
kcp: kcp protocol
|
||||||
simple-obfs: simple-obfs protocol
|
simple-obfs: simple-obfs protocol
|
||||||
|
reject: a virtual proxy which just reject connections
|
||||||
|
|
||||||
Available schemes for different modes:
|
Available schemes for different modes:
|
||||||
listen: mixed ss socks5 http redir redir6 tcptun udptun uottun tls unix kcp
|
listen: mixed ss socks5 http redir redir6 tcptun udptun uottun tls unix kcp
|
||||||
|
1
conf.go
1
conf.go
@ -123,6 +123,7 @@ func usage() {
|
|||||||
fmt.Fprintf(os.Stderr, " unix: unix domain socket\n")
|
fmt.Fprintf(os.Stderr, " unix: unix domain socket\n")
|
||||||
fmt.Fprintf(os.Stderr, " kcp: kcp protocol\n")
|
fmt.Fprintf(os.Stderr, " kcp: kcp protocol\n")
|
||||||
fmt.Fprintf(os.Stderr, " simple-obfs: simple-obfs protocol\n")
|
fmt.Fprintf(os.Stderr, " simple-obfs: simple-obfs protocol\n")
|
||||||
|
fmt.Fprintf(os.Stderr, " reject: a virtual proxy which just reject connections\n")
|
||||||
fmt.Fprintf(os.Stderr, "\n")
|
fmt.Fprintf(os.Stderr, "\n")
|
||||||
|
|
||||||
fmt.Fprintf(os.Stderr, "Available schemes for different modes:\n")
|
fmt.Fprintf(os.Stderr, "Available schemes for different modes:\n")
|
||||||
|
@ -129,11 +129,13 @@ func (c *Client) exchange(qname string, reqBytes []byte, preferTCP bool) (server
|
|||||||
dialer := c.dialer.NextDialer(qname + ":53")
|
dialer := c.dialer.NextDialer(qname + ":53")
|
||||||
|
|
||||||
// if we are resolving the dialer's domain, then use Direct to avoid denpency loop
|
// if we are resolving the dialer's domain, then use Direct to avoid denpency loop
|
||||||
if strings.Contains(dialer.Addr(), qname) {
|
// TODO: dialer.Addr() == "reject", tricky
|
||||||
|
if strings.Contains(dialer.Addr(), qname) || dialer.Addr() == "REJECT" {
|
||||||
dialer = proxy.Default
|
dialer = proxy.Default
|
||||||
}
|
}
|
||||||
|
|
||||||
// If client uses udp and no forwarders specified, use udp
|
// If client uses udp and no forwarders specified, use udp
|
||||||
|
// TODO: dialer.Addr() == "DIRECT", tricky
|
||||||
if !preferTCP && !c.config.AlwaysTCP && dialer.Addr() == "DIRECT" {
|
if !preferTCP && !c.config.AlwaysTCP && dialer.Addr() == "DIRECT" {
|
||||||
network = "udp"
|
network = "udp"
|
||||||
}
|
}
|
||||||
|
@ -26,15 +26,15 @@ func NewRejectDialer(s string, dialer proxy.Dialer) (proxy.Dialer, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Addr returns forwarder's address.
|
// Addr returns forwarder's address.
|
||||||
func (s *Reject) Addr() string { return "reject" }
|
func (s *Reject) Addr() string { return "REJECT" }
|
||||||
|
|
||||||
// NextDialer returns the next dialer.
|
// NextDialer returns the next dialer.
|
||||||
func (s *Reject) NextDialer(dstAddr string) proxy.Dialer { return s }
|
func (s *Reject) NextDialer(dstAddr string) proxy.Dialer { return s }
|
||||||
|
|
||||||
// Dial connects to the address addr on the network net via the proxy.
|
// Dial connects to the address addr on the network net via the proxy.
|
||||||
func (s *Reject) Dial(network, addr string) (net.Conn, error) { return nil, errors.New("reject") }
|
func (s *Reject) Dial(network, addr string) (net.Conn, error) { return nil, errors.New("REJECT") }
|
||||||
|
|
||||||
// DialUDP connects to the given address via the proxy.
|
// DialUDP connects to the given address via the proxy.
|
||||||
func (s *Reject) DialUDP(network, addr string) (net.PacketConn, net.Addr, error) {
|
func (s *Reject) DialUDP(network, addr string) (net.PacketConn, net.Addr, error) {
|
||||||
return nil, nil, errors.New("reject")
|
return nil, nil, errors.New("REJECT")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user