dispatcher

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2022 License: MPL-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package dispather implement the rate limiter and the onlie device counter

Package rule is to control the audit rule behaviors

Index

Constants

This section is empty.

Variables

View Source
var File_app_mydispatcher_config_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Config

type Config struct {
	Settings *SessionConfig `protobuf:"bytes,1,opt,name=settings,proto3" json:"settings,omitempty"`
	// contains filtered or unexported fields
}

func (*Config) Descriptor deprecated

func (*Config) Descriptor() ([]byte, []int)

Deprecated: Use Config.ProtoReflect.Descriptor instead.

func (*Config) GetSettings

func (x *Config) GetSettings() *SessionConfig

func (*Config) ProtoMessage

func (*Config) ProtoMessage()

func (*Config) ProtoReflect

func (x *Config) ProtoReflect() protoreflect.Message

func (*Config) Reset

func (x *Config) Reset()

func (*Config) String

func (x *Config) String() string

type DNSThenOthersSniffResult

type DNSThenOthersSniffResult struct {
	// contains filtered or unexported fields
}

func (DNSThenOthersSniffResult) Domain

func (f DNSThenOthersSniffResult) Domain() string

func (DNSThenOthersSniffResult) IsProtoSubsetOf

func (f DNSThenOthersSniffResult) IsProtoSubsetOf(protocolName string) bool

func (DNSThenOthersSniffResult) Protocol

func (DNSThenOthersSniffResult) Protocol() string

type DefaultDispatcher

type DefaultDispatcher struct {
	Limiter     *Limiter
	RuleManager *Rule
	// contains filtered or unexported fields
}

DefaultDispatcher is a default implementation of Dispatcher.

func (*DefaultDispatcher) Close

func (*DefaultDispatcher) Close() error

Close implements common.Closable.

func (*DefaultDispatcher) Dispatch

func (d *DefaultDispatcher) Dispatch(ctx context.Context, destination net.Destination) (*transport.Link, error)

Dispatch implements routing.Dispatcher.

func (d *DefaultDispatcher) DispatchLink(ctx context.Context, destination net.Destination, outbound *transport.Link) error

DispatchLink implements routing.Dispatcher.

func (*DefaultDispatcher) Init

func (d *DefaultDispatcher) Init(config *Config, om outbound.Manager, router routing.Router, pm policy.Manager, sm stats.Manager, dns dns.Client) error

Init initializes DefaultDispatcher.

func (*DefaultDispatcher) Start

func (*DefaultDispatcher) Start() error

Start implements common.Runnable.

func (*DefaultDispatcher) Type

func (*DefaultDispatcher) Type() interface{}

Type implements common.HasType.

type InboundInfo

type InboundInfo struct {
	Tag            string
	NodeSpeedLimit uint64
	UserInfo       *sync.Map // Key: Uid value: UserInfo
	BucketHub      *sync.Map // key: Uid, value: *ratelimit.Bucket
	UserOnlineIP   *sync.Map // Key: Uid Value: *sync.Map: Key: IP, Value: bool
}

type Limiter

type Limiter struct {
	InboundInfo *sync.Map // Key: Tag, Value: *InboundInfo
}

func NewLimiter

func NewLimiter() *Limiter

func (*Limiter) AddInboundLimiter

func (l *Limiter) AddInboundLimiter(tag string, nodeInfo *panel.NodeInfo, userList []panel.UserInfo) error

func (*Limiter) ClearOnlineUserIP

func (l *Limiter) ClearOnlineUserIP(tag string)

func (*Limiter) DeleteInboundLimiter

func (l *Limiter) DeleteInboundLimiter(tag string) error

func (*Limiter) GetOnlineUserIp

func (l *Limiter) GetOnlineUserIp(tag string) ([]UserIp, error)

func (*Limiter) GetUserBucket

func (l *Limiter) GetUserBucket(tag string, email string, ip string) (limiter *ratelimit.Bucket, SpeedLimit bool, Reject bool)

func (*Limiter) RateWriter

func (l *Limiter) RateWriter(writer buf.Writer, limiter *ratelimit.Bucket) buf.Writer

func (*Limiter) UpdateInboundLimiter

func (l *Limiter) UpdateInboundLimiter(tag string, nodeInfo *panel.NodeInfo, updatedUserList []panel.UserInfo) error

func (*Limiter) UpdateOnlineUserIP

func (l *Limiter) UpdateOnlineUserIP(tag string, userIpList []UserIp)

type Rule

type Rule struct {
	InboundRule         *sync.Map // Key: Tag, Value: []api.DetectRule
	InboundProtocolRule *sync.Map // Key: Tag, Value: []string
	InboundDetectResult *sync.Map // key: Tag, Value: mapset.NewSet []api.DetectResult
}

func NewRule

func NewRule() *Rule

func (*Rule) Detect

func (r *Rule) Detect(tag string, destination string, email string) (reject bool)

func (*Rule) GetDetectResult

func (r *Rule) GetDetectResult(tag string) ([]panel.DetectResult, error)

func (*Rule) ProtocolDetect

func (r *Rule) ProtocolDetect(tag string, protocol string) bool

func (*Rule) UpdateProtocolRule

func (r *Rule) UpdateProtocolRule(tag string, ruleList []string) error

func (*Rule) UpdateRule

func (r *Rule) UpdateRule(tag string, newRuleList []panel.DetectRule) error

type SessionConfig

type SessionConfig struct {
	// contains filtered or unexported fields
}

func (*SessionConfig) Descriptor deprecated

func (*SessionConfig) Descriptor() ([]byte, []int)

Deprecated: Use SessionConfig.ProtoReflect.Descriptor instead.

func (*SessionConfig) ProtoMessage

func (*SessionConfig) ProtoMessage()

func (*SessionConfig) ProtoReflect

func (x *SessionConfig) ProtoReflect() protoreflect.Message

func (*SessionConfig) Reset

func (x *SessionConfig) Reset()

func (*SessionConfig) String

func (x *SessionConfig) String() string

type SizeStatWriter

type SizeStatWriter struct {
	Counter stats.Counter
	Writer  buf.Writer
}

func (*SizeStatWriter) Close

func (w *SizeStatWriter) Close() error

func (*SizeStatWriter) Interrupt

func (w *SizeStatWriter) Interrupt()

func (*SizeStatWriter) WriteMultiBuffer

func (w *SizeStatWriter) WriteMultiBuffer(mb buf.MultiBuffer) error

type SniffResult

type SniffResult interface {
	Protocol() string
	Domain() string
}

func CompositeResult

func CompositeResult(domainResult SniffResult, protocolResult SniffResult) SniffResult

type Sniffer

type Sniffer struct {
	// contains filtered or unexported fields
}

func NewSniffer

func NewSniffer(ctx context.Context) *Sniffer

func (*Sniffer) Sniff

func (s *Sniffer) Sniff(c context.Context, payload []byte) (SniffResult, error)

func (*Sniffer) SniffMetadata

func (s *Sniffer) SniffMetadata(c context.Context) (SniffResult, error)

type SnifferIsProtoSubsetOf

type SnifferIsProtoSubsetOf interface {
	IsProtoSubsetOf(protocolName string) bool
}

type SnifferResultComposite

type SnifferResultComposite interface {
	ProtocolForDomainResult() string
}

type UserInfo

type UserInfo struct {
	UID         int
	SpeedLimit  uint64
	DeviceLimit int
}

type UserIp

type UserIp struct {
	Uid int      `json:"Uid"`
	IPs []string `json:"Ips"`
}

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) WriteMultiBuffer

func (w *Writer) WriteMultiBuffer(mb buf.MultiBuffer) error

Jump to

Keyboard shortcuts

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