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 {
|
switch protocol {
|
||||||
case proto.Direct.String():
|
case proto.Direct.String():
|
||||||
return proxy.NewDirect(), nil
|
return proxy.NewDirect(), nil
|
||||||
|
case proto.Reject.String():
|
||||||
|
return proxy.NewReject(), nil
|
||||||
case proto.Socks5.String():
|
case proto.Socks5.String():
|
||||||
return proxy.NewSocks5(parseSocks(u))
|
return proxy.NewSocks5(parseSocks(u))
|
||||||
case proto.Shadowsocks.String():
|
case proto.Shadowsocks.String():
|
||||||
|
@@ -4,6 +4,7 @@ import "fmt"
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
Direct Proto = iota
|
Direct Proto = iota
|
||||||
|
Reject
|
||||||
Shadowsocks
|
Shadowsocks
|
||||||
Socks5
|
Socks5
|
||||||
)
|
)
|
||||||
@@ -14,6 +15,8 @@ func (proto Proto) String() string {
|
|||||||
switch proto {
|
switch proto {
|
||||||
case Direct:
|
case Direct:
|
||||||
return "direct"
|
return "direct"
|
||||||
|
case Reject:
|
||||||
|
return "reject"
|
||||||
case Shadowsocks:
|
case Shadowsocks:
|
||||||
return "ss"
|
return "ss"
|
||||||
case Socks5:
|
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