adapter

package
v0.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close(v any) error

func SaveLogContext

func SaveLogContext(ctx context.Context, logContext LogContext) context.Context

func Start

func Start(v any) error

Types

type APIHandler

type APIHandler interface {
	APIHandler() chi.Router
}

type APILogContext

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

func NewAPILogContext

func NewAPILogContext() *APILogContext

func (*APILogContext) Color

func (c *APILogContext) Color() aurora.Color

func (*APILogContext) Duration

func (c *APILogContext) Duration() time.Duration

func (*APILogContext) ID

func (c *APILogContext) ID() uint32

type Closer

type Closer interface {
	Close() error
}

type Core

type Core interface {
	Closer
	Run() error
	GetListener(tag string) Listener
	GetListeners() []Listener
	GetUpstream(tag string) Upstream
	GetUpstreams() []Upstream
	GetWorkflow(tag string) Workflow
	GetWorkflows() []Workflow
	GetPluginMatcher(tag string) PluginMatcher
	GetPluginMatchers() []PluginMatcher
	GetPluginExecutor(tag string) PluginExecutor
	GetPluginExecutors() []PluginExecutor
	GetTimeFunc() func() time.Time
}

type DNSContext

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

func NewDNSContext

func NewDNSContext(ctx context.Context, listener string, clientIP netip.Addr, req *dns.Msg) *DNSContext

func (*DNSContext) ClientIP

func (c *DNSContext) ClientIP() netip.Addr

func (*DNSContext) Clone

func (c *DNSContext) Clone() *DNSContext

func (*DNSContext) Color

func (c *DNSContext) Color() aurora.Color

func (*DNSContext) Context

func (c *DNSContext) Context() context.Context

func (*DNSContext) Duration

func (c *DNSContext) Duration() time.Duration

func (*DNSContext) FlushColor

func (c *DNSContext) FlushColor()

func (*DNSContext) ID

func (c *DNSContext) ID() uint32

func (*DNSContext) InitTime

func (c *DNSContext) InitTime() time.Time

func (*DNSContext) Listener

func (c *DNSContext) Listener() string

func (*DNSContext) Mark

func (c *DNSContext) Mark() uint64

func (*DNSContext) Metadata

func (c *DNSContext) Metadata() map[string]string

func (*DNSContext) ReqMsg

func (c *DNSContext) ReqMsg() *dns.Msg

func (*DNSContext) RespMsg

func (c *DNSContext) RespMsg() *dns.Msg

func (*DNSContext) RespUpstreamTag

func (c *DNSContext) RespUpstreamTag() string

func (*DNSContext) SetID

func (c *DNSContext) SetID(id uint32)

func (*DNSContext) SetMark

func (c *DNSContext) SetMark(mark uint64)

func (*DNSContext) SetRespMsg

func (c *DNSContext) SetRespMsg(resp *dns.Msg)

func (*DNSContext) SetRespUpstreamTag

func (c *DNSContext) SetRespUpstreamTag(tag string)

type Listener

type Listener interface {
	Tag() string
	Type() string
	Handle(ctx context.Context, req *dns.Msg, clientAddr netip.AddrPort) *dns.Msg
}

type LogContext

type LogContext interface {
	ID() uint32
	Color() aurora.Color
	Duration() time.Duration
}

func LoadLogContext

func LoadLogContext(ctx context.Context) LogContext

type PluginExecutor

type PluginExecutor interface {
	Tag() string
	Type() string
	LoadRunningArgs(ctx context.Context, args any) (uint16, error)
	Exec(ctx context.Context, dnsCtx *DNSContext, argsID uint16) (ReturnMode, error)
}

type PluginMatcher

type PluginMatcher interface {
	Tag() string
	Type() string
	LoadRunningArgs(ctx context.Context, args any) (uint16, error)
	Match(ctx context.Context, dnsCtx *DNSContext, argsID uint16) (bool, error)
}

type ReturnMode

type ReturnMode int
const (
	ReturnModeUnknown ReturnMode = iota
	ReturnModeContinue
	ReturnModeReturnAll
	ReturnModeReturnOnce
)

func (ReturnMode) String

func (r ReturnMode) String() string

type Starter

type Starter interface {
	Start() error
}

type Upstream

type Upstream interface {
	Tag() string
	Type() string
	Dependencies() []string
	Exchange(ctx context.Context, req *dns.Msg) (*dns.Msg, error)
	StatisticalData() map[string]any
}

type Workflow

type Workflow interface {
	Tag() string
	Check() error
	Exec(ctx context.Context, dnsCtx *DNSContext) (ReturnMode, error)
}

Jump to

Keyboard shortcuts

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