socks5

package
v0.0.0-...-c8733ce Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionContinue = RuleAction(0)
	ActionAllow    = RuleAction(1)
	ActionBlock    = RuleAction(2)
)

Variables

View Source
var ErrInvalidPort = errors.New("port has to be 0-65535")

Functions

func CreateSocks5Handler

func CreateSocks5Handler(addr string, transportParams url.Values) (proxy.ConnHandlerFunc, error)

func ParseAddrSpec

func ParseAddrSpec(host string, port string) (*socks5.AddrSpec, error)

func ParseConfig

func ParseConfig(params url.Values) (*socks5.Config, error)

func ParseCredentials

func ParseCredentials(params url.Values) ([]socks5.Authenticator, socks5.CredentialStore, error)

func ParsePort

func ParsePort(port string) (int, error)

func ParseRewrites

func ParseRewrites(filePath string) (socks5.AddressRewriter, error)

func ParseRuleset

func ParseRuleset(filePath string, defaultAction RuleAction) (socks5.RuleSet, error)

Types

type FQDNRewriter

type FQDNRewriter struct {
	WildcardPattern string
	PortMatcher     PortMatcherFunc
	Target          *socks5.AddrSpec
}

func (*FQDNRewriter) Rewrite

func (r *FQDNRewriter) Rewrite(addrSpec *socks5.AddrSpec) (*socks5.AddrSpec, bool)

type FQDNRule

type FQDNRule struct {
	WildcardPattern string
	PortMatcher     PortMatcherFunc
	Action          RuleAction
}

func (*FQDNRule) Match

func (r *FQDNRule) Match(addrSpec *socks5.AddrSpec) (RuleAction, bool)

type IPRangeRewriter

type IPRangeRewriter struct {
	AddrRanges  iprange.Ranges
	PortMatcher PortMatcherFunc
	Target      *socks5.AddrSpec
}

func (*IPRangeRewriter) Rewrite

func (r *IPRangeRewriter) Rewrite(addrSpec *socks5.AddrSpec) (*socks5.AddrSpec, bool)

type IPRangeRule

type IPRangeRule struct {
	AddrRanges  iprange.Ranges
	PortMatcher PortMatcherFunc
	Action      RuleAction
}

func (*IPRangeRule) Match

func (r *IPRangeRule) Match(addrSpec *socks5.AddrSpec) (RuleAction, bool)

type PortMatcherFunc

type PortMatcherFunc func(port int) bool

func CreatePortMatcher

func CreatePortMatcher(portsDef string) (PortMatcherFunc, error)

type RewriteRule

type RewriteRule interface {
	Rewrite(addrSpec *socks5.AddrSpec) (*socks5.AddrSpec, bool)
}

func ParseRewriteLine

func ParseRewriteLine(line string) (RewriteRule, error)

type Rewriter

type Rewriter struct {
	Rules []RewriteRule
}

func (*Rewriter) Rewrite

func (r *Rewriter) Rewrite(ctx context.Context, request *socks5.Request) (context.Context, *socks5.AddrSpec)

type Rule

type Rule interface {
	Match(addrSpec *socks5.AddrSpec) (RuleAction, bool)
}

func ParseRuleLine

func ParseRuleLine(line string) (Rule, error)

type RuleAction

type RuleAction int

func ParseAction

func ParseAction(input string) (RuleAction, error)

type Ruleset

type Ruleset struct {
	Rules         []Rule
	DefaultAction RuleAction
}

func (*Ruleset) Allow

func (r *Ruleset) Allow(ctx context.Context, req *socks5.Request) (context.Context, bool)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL