Feature: add reject proxy

This commit is contained in:
xjasonlyu
2021-07-15 19:54:56 +08:00
parent 67cc84d1d0
commit 842920c39b
3 changed files with 37 additions and 0 deletions

32
proxy/reject.go Normal file
View File

@@ -0,0 +1,32 @@
package proxy
import (
"context"
"errors"
"net"
M "github.com/xjasonlyu/tun2socks/constant"
"github.com/xjasonlyu/tun2socks/proxy/proto"
)
var _ Proxy = (*Reject)(nil)
type Reject struct {
*Base
}
func NewReject() *Reject {
return &Reject{
Base: &Base{
proto: proto.Reject,
},
}
}
func (r *Reject) DialContext(context.Context, *M.Metadata) (net.Conn, error) {
return nil, errors.New("TCP rejected")
}
func (r *Reject) DialUDP(*M.Metadata) (net.PacketConn, error) {
return nil, errors.New("UDP rejected")
}