protocol

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Code

type Code uint8
const (
	CodeRequest  Code = 1
	CodeResponse Code = 2
	CodeSuccess  Code = 3
	CodeFailure  Code = 4
)

type Context

type Context interface {
	Packet() *radius.Request
	RootPayload() Payload
	State() string

	ProtocolSettings() interface{}

	GetProtocolState(p Type) interface{}
	SetProtocolState(p Type, s interface{})
	IsProtocolStart(p Type) bool

	// SessionValue / SetSessionValue access the session-scoped store shared by
	// every protocol handled under the same RADIUS State (see State.SessionData).
	SessionValue(key string) any
	SetSessionValue(key string, value any)

	ResponseModifier
	AddResponseModifier(func(r, q *radius.Packet) error)

	HandleInnerEAP(Payload, StateManager) (Payload, error)
	Inner(Payload, Type) Context
	EndInnerProtocol(Status)

	Log() Logger
}

type Inner

type Inner interface {
	HasInner() Payload
}

type Logger

type Logger interface {
	Debug(msg string, args ...interface{})
	Info(msg string, args ...interface{})
	Warn(msg string, args ...interface{})
	Error(msg string, args ...interface{})
	With(args ...interface{}) Logger
}

type Payload

type Payload interface {
	Decode(raw []byte) error
	Encode() ([]byte, error)
	Handle(ctx Context) Payload
	Type() Type
	Offerable() bool
	String() string
}

type ProtocolConstructor

type ProtocolConstructor func() Payload

type ResponseModifier

type ResponseModifier interface {
	ModifyRADIUSResponse(r *radius.Packet, q *radius.Packet) error
}

type Settings

type Settings struct {
	Protocols        []ProtocolConstructor
	ProtocolPriority []Type
	ProtocolSettings map[Type]interface{}
	Logger           Logger
}

type State

type State struct {
	Protocols        []ProtocolConstructor
	ProtocolIndex    int
	ProtocolPriority []Type
	// TypeState holds each method's per-session state. It is shared by every
	// protocol handled under the same RADIUS State and is accessed both by the
	// request handler and by the background TLS handshake goroutine (via the
	// VerifyConnection / HandshakeSuccessful callbacks), so it must only be
	// touched through ProtocolState/SetProtocolState/IsProtocolStart, which guard
	// it with typeMu.
	TypeState map[Type]any

	// SessionData is a free-form, session-scoped store shared across every
	// protocol (outer and inner) handled under the same RADIUS State. Consumers
	// use Context.SessionValue/SetSessionValue to stash request-spanning data
	// (resolved identity, certificates, OTP progress, response attributes)
	// without maintaining a parallel, separately-locked map. Access it only
	// through SessionValue/SetSessionValue, which guard it with sessionMu so it
	// is safe to use from callbacks that run on the background TLS handshake
	// goroutine (e.g. VerifyConnection, HandshakeSuccessful).
	SessionData map[string]any
	// contains filtered or unexported fields
}

func BlankState

func BlankState(settings Settings) *State

func (*State) GetNextProtocol

func (st *State) GetNextProtocol() (Type, error)

func (*State) IsProtocolStart added in v0.2.1

func (st *State) IsProtocolStart(t Type) bool

IsProtocolStart reports whether a method has no stored state yet. Safe for concurrent use.

func (*State) ProtocolState added in v0.2.1

func (st *State) ProtocolState(t Type) any

ProtocolState returns the stored state for a method type (nil if none). Safe for concurrent use.

func (*State) SessionValue added in v0.2.0

func (st *State) SessionValue(key string) any

SessionValue returns the session-scoped value for key, or nil if absent.

func (*State) SetProtocolState added in v0.2.1

func (st *State) SetProtocolState(t Type, v any)

SetProtocolState stores the state for a method type, lazily allocating the backing map. Safe for concurrent use.

func (*State) SetSessionValue added in v0.2.0

func (st *State) SetSessionValue(key string, value any)

SetSessionValue stores a session-scoped value, lazily allocating the backing map. It is safe for concurrent use.

type StateManager

type StateManager interface {
	GetEAPSettings() Settings
	GetEAPState(string) *State
	SetEAPState(string, *State)
}

type Status

type Status int
const (
	StatusUnknown Status = iota
	StatusSuccess
	StatusError
	StatusNextProtocol
)

type Type

type Type uint8

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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