mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-06 01:07:03 +08:00
Feature: add reject proxy
This commit is contained in:
@@ -48,6 +48,8 @@ func parseProxy(s string) (proxy.Proxy, error) {
|
||||
switch protocol {
|
||||
case proto.Direct.String():
|
||||
return proxy.NewDirect(), nil
|
||||
case proto.Reject.String():
|
||||
return proxy.NewReject(), nil
|
||||
case proto.Socks5.String():
|
||||
return proxy.NewSocks5(parseSocks(u))
|
||||
case proto.Shadowsocks.String():
|
||||
|
@@ -4,6 +4,7 @@ import "fmt"
|
||||
|
||||
const (
|
||||
Direct Proto = iota
|
||||
Reject
|
||||
Shadowsocks
|
||||
Socks5
|
||||
)
|
||||
@@ -14,6 +15,8 @@ func (proto Proto) String() string {
|
||||
switch proto {
|
||||
case Direct:
|
||||
return "direct"
|
||||
case Reject:
|
||||
return "reject"
|
||||
case Shadowsocks:
|
||||
return "ss"
|
||||
case Socks5:
|
||||
|
32
proxy/reject.go
Normal file
32
proxy/reject.go
Normal 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")
|
||||
}
|
Reference in New Issue
Block a user