ppp

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ppp is a minimal PPP peer for the VPNs that carry PPP (L2TP): LCP (RFC 1661), IPCP with DNS (RFC 1332, RFC 1877) and the login the server asks for: MS-CHAPv2 (RFC 2759, with the server's proof checked) and, only when the VPN allows the weak logins, CHAP-MD5 (RFC 1994) or none, which prove nothing about the server, and PAP (RFC 1334), which sends the password itself. Compression, encryption (MPPE) and IPv6 are never negotiated.

Index

Constants

View Source
const (
	LCP    = 0xc021
	PAP    = 0xc023
	CHAP   = 0xc223
	IPCP   = 0x8021
	IPV6CP = 0x8057
	CCP    = 0x80fd
	IPv4   = 0x0021
	IPv6   = 0x0057
)

Protocol numbers.

Variables

View Source
var ErrTimeout = quiet

ErrTimeout: the server stopped answering while the link came up.

View Source
var ErrWeakLogin = errors.New("the VPN server only offers a PPP login that does not prove it is the server (PAP, which hands it your password itself, CHAP-MD5, or none), so anyone who knows the pre-shared key could pretend to be the server; komando uses such a login only when it is allowed for this VPN")

ErrWeakLogin: the server insists on a login that does not prove it is the server, and the VPN does not allow one (Peer.AllowPAP). The caller names the per-VPN setting that does.

Functions

This section is empty.

Types

type AuthError

type AuthError struct{ Msg string }

AuthError is a login the server refused.

func (*AuthError) Error

func (e *AuthError) Error() string

type MSCHAPv2

type MSCHAPv2 struct {
	PeerChallenge [16]byte
	NTResponse    [24]byte
	// contains filtered or unexported fields
}

MSCHAPv2 is one MS-CHAPv2 answer.

func NewMSCHAPv2

func NewMSCHAPv2(authChallenge []byte, user, password string, peerChallenge [16]byte) (*MSCHAPv2, error)

NewMSCHAPv2 answers an authenticator challenge (16 bytes) with a random peer challenge.

func (*MSCHAPv2) MSK

func (m *MSCHAPv2) MSK() []byte

MSK is the EAP-MSCHAPv2 master session key (RFC 3079 keys, the server's receive key first), used for the IKEv2 AUTH payload.

func (*MSCHAPv2) VerifySuccess

func (m *MSCHAPv2) VerifySuccess(msg []byte) error

VerifySuccess checks the server's success message ("S=<40 hex> M=...").

type Peer

type Peer struct {

	// Log, when set, notes the steps of the link (no secrets).
	Log func(format string, args ...any)
	// AllowPAP lets the server choose a weak login: PAP, which sends the
	// password itself (inside the VPN's encryption, but to whoever answers
	// as the server), CHAP-MD5 or none, which prove nothing about the
	// server. Off, komando asks for MS-CHAPv2 instead and, when the server
	// insists, fails with ErrWeakLogin.
	AllowPAP bool
	// contains filtered or unexported fields
}

Peer is one PPP link. Send writes a PPP frame (protocol, information).

func New

func New(send func(uint16, []byte) error, user, password string) *Peer

New makes a peer that logs in as user (when the server asks).

func (*Peer) Handle

func (p *Peer) Handle(proto uint16, b []byte) error

Handle processes one received control frame. It returns an error when the link cannot go on (the server ended it or refused the login).

func (*Peer) Result

func (p *Peer) Result() (netip.Addr, []netip.Addr, int)

Result is the address and DNS servers the server gave.

func (*Peer) Start

func (p *Peer) Start() error

Start sends the first LCP request and sends requests again every three seconds until they are answered (RFC 1661 restart timer).

func (*Peer) Terminate

func (p *Peer) Terminate()

Terminate tells the server the link ends.

func (*Peer) Wait

func (p *Peer) Wait(timeout time.Duration) error

Wait blocks until IPCP is up, the login failed or the time is over.

Jump to

Keyboard shortcuts

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