client

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package client provides ready-to-use RADIUS clients built on top of the transport and protocol packages.

The protocol.Client is transport-agnostic; callers must inject a transport that satisfies protocol.Transport (transport.UDPClient and transport.TCPClient both do). This package removes that wiring burden with two constructors:

  • NewUDPClient dials a UDP socket to a server and wraps a protocol.Client around it. Retransmission is enabled by default (RFC 2865 §2.5).
  • NewTCPClient dials a single TCP connection to a server and wraps a protocol.Client around it. Retransmission is disabled by default (RFC 6613 §2.6.1).

Both constructors accept functional options for timeout, retransmission policy, logging, and per-protocol-family secret selection.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Network selects "udp" / "udp4" / "udp6" for UDP clients, or
	// "tcp" / "tcp4" / "tcp6" for TCP clients. Defaults to "udp4" or
	// "tcp4" respectively when empty.
	Network string

	// Timeout is the default per-exchange deadline applied to every
	// Authenticate / Account / SendCoA / SendDisconnect call when the
	// caller does not supply its own context deadline. Zero disables
	// the default deadline (calls block until the server replies or the
	// retransmission policy is exhausted).
	Timeout time.Duration

	// Retransmit governs UDP retransmission. When zero a default policy
	// of 3 attempts with 2s/16s backoff is used. Ignored for TCP clients
	// (always single-attempt per RFC 6613 §2.6.1).
	Retransmit protocol.RetransmitPolicy

	// Logger injected into the underlying protocol.Client. nil falls
	// back to log.Default (NopLogger unless the application called
	// log.SetDefault).
	Logger radiuslog.Logger
}

Config controls the behavior of a constructed Client. Zero values fall back to sensible defaults documented per-field.

type TCPClient

type TCPClient struct {
	*protocol.Client
	// contains filtered or unexported fields
}

TCPClient is a protocol.Client configured to exchange packets with a single RADIUS server over TCP (RFC 6613).

func NewTCPClient

func NewTCPClient(server *net.TCPAddr, secret []byte, cfg Config) (*TCPClient, error)

NewTCPClient dials a TCP connection to server and returns a Client ready for Authenticate / Account / SendCoA / SendDisconnect calls.

Per RFC 6613 §2.6.1 no retransmission is performed on a TCP connection; the Config.Retransmit field is ignored and the client uses a single-attempt policy.

func (*TCPClient) Close

func (c *TCPClient) Close() error

Close releases the underlying TCP connection.

func (*TCPClient) Transport

func (c *TCPClient) Transport() *transport.TCPClient

Transport returns the underlying TCP transport.

type UDPClient

type UDPClient struct {
	*protocol.Client
	// contains filtered or unexported fields
}

UDPClient is a protocol.Client configured to exchange packets with a single RADIUS server over UDP. The underlying transport.UDPClient is exposed via Transport for advanced callers that need to send raw bytes.

func NewUDPClient

func NewUDPClient(server *net.UDPAddr, secret []byte, cfg Config) (*UDPClient, error)

NewUDPClient dials a UDP socket to server and returns a Client ready for Authenticate / Account / SendCoA / SendDisconnect calls.

secret is the RADIUS shared secret used for authenticator computation and User-Password encryption. It MUST NOT be empty.

func (*UDPClient) Close

func (c *UDPClient) Close() error

Close releases the underlying UDP socket.

func (*UDPClient) Transport

func (c *UDPClient) Transport() *transport.UDPClient

Transport returns the underlying UDP transport.

Jump to

Keyboard shortcuts

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