mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
reject: add a virtual proxy reject
This commit is contained in:
1 parent
f9a21f5951
commit
2e44d79db8
11 files changed
+54
-12
No files matched your search
@@ -0,0 +1,40 @@
|
||||
// Package reject implements a virtual proxy which always reject requests.
|
||||
package reject
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
|
||||
"github.com/nadoo/glider/proxy"
|
||||
)
|
||||
|
||||
// A Reject represents the base struct of a reject proxy.
|
||||
type Reject struct{}
|
||||
|
||||
func init() {
|
||||
proxy.RegisterDialer("reject", NewRejectDialer)
|
||||
}
|
||||
|
||||
// NewReject returns a reject proxy, reject://
|
||||
func NewReject(s string, dialer proxy.Dialer) (*Reject, error) {
|
||||
return &Reject{}, nil
|
||||
}
|
||||
|
||||
// NewRejectDialer returns a reject proxy dialer.
|
||||
func NewRejectDialer(s string, dialer proxy.Dialer) (proxy.Dialer, error) {
|
||||
return NewReject(s, dialer)
|
||||
}
|
||||
|
||||
// Addr returns forwarder's address.
|
||||
func (s *Reject) Addr() string { return "reject" }
|
||||
|
||||
// NextDialer returns the next dialer.
|
||||
func (s *Reject) NextDialer(dstAddr string) proxy.Dialer { return s }
|
||||
|
||||
// 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") }
|
||||
|
||||
// DialUDP connects to the given address via the proxy.
|
||||
func (s *Reject) DialUDP(network, addr string) (net.PacketConn, net.Addr, error) {
|
||||
return nil, nil, errors.New("reject")
|
||||
}
|
||||
Reference in new issue
Block a user