rtrlib

package
v0.14.8 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PROTOCOL_VERSION_0 = 0
	PROTOCOL_VERSION_1 = 1

	PDU_ID_SERIAL_NOTIFY  = 0
	PDU_ID_SERIAL_QUERY   = 1
	PDU_ID_RESET_QUERY    = 2
	PDU_ID_CACHE_RESPONSE = 3
	PDU_ID_IPV4_PREFIX    = 4
	PDU_ID_IPV6_PREFIX    = 6
	PDU_ID_END_OF_DATA    = 7
	PDU_ID_CACHE_RESET    = 8
	PDU_ID_ROUTER_KEY     = 9
	PDU_ID_ERROR_REPORT   = 10

	FLAG_ADDED   = 1
	FLAG_REMOVED = 0

	PDU_ERROR_CORRUPTDATA     = 0
	PDU_ERROR_INTERNALERR     = 1
	PDU_ERROR_NODATA          = 2
	PDU_ERROR_INVALIDREQUEST  = 3
	PDU_ERROR_BADPROTOVERSION = 4
	PDU_ERROR_BADPDUTYPE      = 5
	PDU_ERROR_WITHDRAWUNKNOWN = 6
	PDU_ERROR_DUPANNOUNCE     = 7

	TYPE_UNKNOWN = iota
	TYPE_PLAIN
	TYPE_TLS
	TYPE_SSH
)

Variables

This section is empty.

Functions

func ComputeDiff

func ComputeDiff(newRoas []ROA, prevRoas []ROA) ([]ROA, []ROA, []ROA)

func ConvertROAListToMap added in v0.14.8

func ConvertROAListToMap(roas []ROA) map[string]ROA

func GenerateSessionId

func GenerateSessionId() uint16

func IsCorrectPDUVersion

func IsCorrectPDUVersion(pdu PDU, version uint8) bool

func TypeToString

func TypeToString(t uint8) string

Types

type Client

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

func ClientFromConn

func ClientFromConn(tcpconn net.Conn, handler RTRServerEventHandler, simpleHandler RTREventHandler) *Client

func ClientFromConnSSH added in v0.14.8

func ClientFromConnSSH(tcpconn net.Conn, channel ssh.Channel, handler RTRServerEventHandler, simpleHandler RTREventHandler) *Client

func (*Client) Disconnect

func (c *Client) Disconnect()

func (*Client) GetLocalAddress

func (c *Client) GetLocalAddress() net.Addr

func (*Client) GetRemoteAddress

func (c *Client) GetRemoteAddress() net.Addr

func (*Client) GetVersion

func (c *Client) GetVersion() uint8

func (*Client) Notify

func (c *Client) Notify(sessionId uint16, serialNumber uint32)

func (*Client) SendCacheReset

func (c *Client) SendCacheReset()

func (*Client) SendInternalError

func (c *Client) SendInternalError()

func (*Client) SendNoDataError

func (c *Client) SendNoDataError()

func (*Client) SendPDU

func (c *Client) SendPDU(pdu PDU)

func (*Client) SendROA

func (c *Client) SendROA(roa ROA)

func (*Client) SendROAs

func (c *Client) SendROAs(sessionId uint16, serialNumber uint32, roas []ROA)

func (*Client) SendRawPDU

func (c *Client) SendRawPDU(pdu PDU)

func (*Client) SendWrongVersionError

func (c *Client) SendWrongVersionError()

func (*Client) SetDisableVersionCheck

func (c *Client) SetDisableVersionCheck(disableCheck bool)

func (*Client) SetIntervals

func (c *Client) SetIntervals(refreshInterval uint32, retryInterval uint32, expireInterval uint32)

func (*Client) SetVersion

func (c *Client) SetVersion(newversion uint8)

func (*Client) Start

func (c *Client) Start()

func (*Client) String

func (c *Client) String() string

type ClientCallback added in v0.14.8

type ClientCallback func(net.Conn) error

type ClientConfiguration

type ClientConfiguration struct {
	ProtocolVersion uint8

	RefreshInterval uint32
	RetryInterval   uint32
	ExpireInterval  uint32

	Log Logger
}

type ClientSession

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

func NewClientSession

func NewClientSession(configuration ClientConfiguration, handler RTRClientSessionEventHandler) *ClientSession

func (*ClientSession) Disconnect

func (c *ClientSession) Disconnect()

func (*ClientSession) SendPDU

func (c *ClientSession) SendPDU(pdu PDU)

func (*ClientSession) SendRawPDU

func (c *ClientSession) SendRawPDU(pdu PDU)

func (*ClientSession) SendResetQuery

func (c *ClientSession) SendResetQuery()

func (*ClientSession) SendSerialQuery

func (c *ClientSession) SendSerialQuery(sessionid uint16, serial uint32)

func (*ClientSession) Start

func (c *ClientSession) Start(addr string, connType int, configTLS *tls.Config, configSSH *ssh.ClientConfig) error

func (*ClientSession) StartPlain added in v0.14.8

func (c *ClientSession) StartPlain(addr string) error

func (*ClientSession) StartRW added in v0.14.8

func (c *ClientSession) StartRW(rd io.Reader, wr io.Writer) error

func (*ClientSession) StartSSH added in v0.14.8

func (c *ClientSession) StartSSH(addr string, config *ssh.ClientConfig) error

func (*ClientSession) StartTLS added in v0.14.8

func (c *ClientSession) StartTLS(addr string, config *tls.Config) error

func (*ClientSession) StartWithConn

func (c *ClientSession) StartWithConn(tcpconn net.Conn) error

func (*ClientSession) StartWithSSH added in v0.14.8

func (c *ClientSession) StartWithSSH(tcpconn *net.TCPConn, session *ssh.Session) error

type DefaultRTREventHandler

type DefaultRTREventHandler struct {
	Log Logger
	// contains filtered or unexported fields
}

func (*DefaultRTREventHandler) RequestCache

func (e *DefaultRTREventHandler) RequestCache(c *Client)

func (*DefaultRTREventHandler) RequestNewVersion

func (e *DefaultRTREventHandler) RequestNewVersion(c *Client, sessionId uint16, serialNumber uint32)

func (*DefaultRTREventHandler) SetROAManager

func (e *DefaultRTREventHandler) SetROAManager(m ROAManager)

type Logger

type Logger interface {
	Debugf(string, ...interface{})
	Printf(string, ...interface{})
	Warnf(string, ...interface{})
	Errorf(string, ...interface{})
	Infof(string, ...interface{})
}

type PDU

type PDU interface {
	Bytes() []byte
	Write(io.Writer)
	String() string
	SetVersion(uint8)
	GetVersion() uint8
	GetType() uint8
}

func Decode

func Decode(rdr io.Reader) (PDU, error)

func DecodeBytes

func DecodeBytes(b []byte) (PDU, error)

type PDUCacheReset

type PDUCacheReset struct {
	Version uint8
}

func (*PDUCacheReset) Bytes

func (pdu *PDUCacheReset) Bytes() []byte

func (*PDUCacheReset) GetType

func (pdu *PDUCacheReset) GetType() uint8

func (*PDUCacheReset) GetVersion

func (pdu *PDUCacheReset) GetVersion() uint8

func (*PDUCacheReset) SetVersion

func (pdu *PDUCacheReset) SetVersion(version uint8)

func (*PDUCacheReset) String

func (pdu *PDUCacheReset) String() string

func (*PDUCacheReset) Write

func (pdu *PDUCacheReset) Write(wr io.Writer)

type PDUCacheResponse

type PDUCacheResponse struct {
	Version   uint8
	SessionId uint16
}

func (*PDUCacheResponse) Bytes

func (pdu *PDUCacheResponse) Bytes() []byte

func (*PDUCacheResponse) GetType

func (pdu *PDUCacheResponse) GetType() uint8

func (*PDUCacheResponse) GetVersion

func (pdu *PDUCacheResponse) GetVersion() uint8

func (*PDUCacheResponse) SetVersion

func (pdu *PDUCacheResponse) SetVersion(version uint8)

func (*PDUCacheResponse) String

func (pdu *PDUCacheResponse) String() string

func (*PDUCacheResponse) Write

func (pdu *PDUCacheResponse) Write(wr io.Writer)

type PDUEndOfData

type PDUEndOfData struct {
	Version      uint8
	SessionId    uint16
	SerialNumber uint32

	RefreshInterval uint32
	RetryInterval   uint32
	ExpireInterval  uint32
}

func (*PDUEndOfData) Bytes

func (pdu *PDUEndOfData) Bytes() []byte

func (*PDUEndOfData) GetType

func (pdu *PDUEndOfData) GetType() uint8

func (*PDUEndOfData) GetVersion

func (pdu *PDUEndOfData) GetVersion() uint8

func (*PDUEndOfData) SetVersion

func (pdu *PDUEndOfData) SetVersion(version uint8)

func (*PDUEndOfData) String

func (pdu *PDUEndOfData) String() string

func (*PDUEndOfData) Write

func (pdu *PDUEndOfData) Write(wr io.Writer)

type PDUErrorReport

type PDUErrorReport struct {
	Version   uint8
	ErrorCode uint16
	PDUCopy   []byte
	ErrorMsg  string
}

func (*PDUErrorReport) Bytes

func (pdu *PDUErrorReport) Bytes() []byte

func (*PDUErrorReport) GetType

func (pdu *PDUErrorReport) GetType() uint8

func (*PDUErrorReport) GetVersion

func (pdu *PDUErrorReport) GetVersion() uint8

func (*PDUErrorReport) SetVersion

func (pdu *PDUErrorReport) SetVersion(version uint8)

func (*PDUErrorReport) String

func (pdu *PDUErrorReport) String() string

func (*PDUErrorReport) Write

func (pdu *PDUErrorReport) Write(wr io.Writer)

type PDUIPv4Prefix

type PDUIPv4Prefix struct {
	Version uint8
	Prefix  net.IPNet
	MaxLen  uint8
	ASN     uint32
	Flags   uint8
}

func (*PDUIPv4Prefix) Bytes

func (pdu *PDUIPv4Prefix) Bytes() []byte

func (*PDUIPv4Prefix) GetType

func (pdu *PDUIPv4Prefix) GetType() uint8

func (*PDUIPv4Prefix) GetVersion

func (pdu *PDUIPv4Prefix) GetVersion() uint8

func (*PDUIPv4Prefix) SetVersion

func (pdu *PDUIPv4Prefix) SetVersion(version uint8)

func (*PDUIPv4Prefix) String

func (pdu *PDUIPv4Prefix) String() string

func (*PDUIPv4Prefix) Write

func (pdu *PDUIPv4Prefix) Write(wr io.Writer)

type PDUIPv6Prefix

type PDUIPv6Prefix struct {
	Version uint8
	Prefix  net.IPNet
	MaxLen  uint8
	ASN     uint32
	Flags   uint8
}

func (*PDUIPv6Prefix) Bytes

func (pdu *PDUIPv6Prefix) Bytes() []byte

func (*PDUIPv6Prefix) GetType

func (pdu *PDUIPv6Prefix) GetType() uint8

func (*PDUIPv6Prefix) GetVersion

func (pdu *PDUIPv6Prefix) GetVersion() uint8

func (*PDUIPv6Prefix) SetVersion

func (pdu *PDUIPv6Prefix) SetVersion(version uint8)

func (*PDUIPv6Prefix) String

func (pdu *PDUIPv6Prefix) String() string

func (*PDUIPv6Prefix) Write

func (pdu *PDUIPv6Prefix) Write(wr io.Writer)

type PDUResetQuery

type PDUResetQuery struct {
	Version uint8
}

func (*PDUResetQuery) Bytes

func (pdu *PDUResetQuery) Bytes() []byte

func (*PDUResetQuery) GetType

func (pdu *PDUResetQuery) GetType() uint8

func (*PDUResetQuery) GetVersion

func (pdu *PDUResetQuery) GetVersion() uint8

func (*PDUResetQuery) SetVersion

func (pdu *PDUResetQuery) SetVersion(version uint8)

func (*PDUResetQuery) String

func (pdu *PDUResetQuery) String() string

func (*PDUResetQuery) Write

func (pdu *PDUResetQuery) Write(wr io.Writer)

type PDURouterKey

type PDURouterKey struct {
	Version              uint8
	Flags                uint8
	SubjectKeyIdentifier [20]byte
	ASN                  uint32
	SubjectPublicKeyInfo uint32
}

func (*PDURouterKey) Bytes

func (pdu *PDURouterKey) Bytes() []byte

func (*PDURouterKey) GetType

func (pdu *PDURouterKey) GetType() uint8

func (*PDURouterKey) GetVersion

func (pdu *PDURouterKey) GetVersion() uint8

func (*PDURouterKey) SetVersion

func (pdu *PDURouterKey) SetVersion(version uint8)

func (*PDURouterKey) String

func (pdu *PDURouterKey) String() string

func (*PDURouterKey) Write

func (pdu *PDURouterKey) Write(wr io.Writer)

type PDUSerialNotify

type PDUSerialNotify struct {
	Version      uint8
	SessionId    uint16
	SerialNumber uint32
}

func (*PDUSerialNotify) Bytes

func (pdu *PDUSerialNotify) Bytes() []byte

func (*PDUSerialNotify) GetType

func (pdu *PDUSerialNotify) GetType() uint8

func (*PDUSerialNotify) GetVersion

func (pdu *PDUSerialNotify) GetVersion() uint8

func (*PDUSerialNotify) SetVersion

func (pdu *PDUSerialNotify) SetVersion(version uint8)

func (*PDUSerialNotify) String

func (pdu *PDUSerialNotify) String() string

func (*PDUSerialNotify) Write

func (pdu *PDUSerialNotify) Write(wr io.Writer)

type PDUSerialQuery

type PDUSerialQuery struct {
	Version      uint8
	SessionId    uint16
	SerialNumber uint32
}

func (*PDUSerialQuery) Bytes

func (pdu *PDUSerialQuery) Bytes() []byte

func (*PDUSerialQuery) GetType

func (pdu *PDUSerialQuery) GetType() uint8

func (*PDUSerialQuery) GetVersion

func (pdu *PDUSerialQuery) GetVersion() uint8

func (*PDUSerialQuery) SetVersion

func (pdu *PDUSerialQuery) SetVersion(version uint8)

func (*PDUSerialQuery) String

func (pdu *PDUSerialQuery) String() string

func (*PDUSerialQuery) Write

func (pdu *PDUSerialQuery) Write(wr io.Writer)

type ROA

type ROA struct {
	Prefix net.IPNet
	MaxLen uint8
	ASN    uint32
	Flags  uint8
}

func ApplyDiff

func ApplyDiff(diff []ROA, prevRoas []ROA) []ROA

func (ROA) Copy

func (r1 ROA) Copy() ROA

func (ROA) Equals

func (r1 ROA) Equals(r2 ROA) bool

func (ROA) HashKey added in v0.14.8

func (roa ROA) HashKey() string

func (ROA) String

func (r ROA) String() string

type ROAManager

type ROAManager interface {
	GetCurrentSerial(uint16) (uint32, bool)
	GetSessionId(*Client) (uint16, error)
	GetCurrentROAs() ([]ROA, bool)
	GetROAsSerialDiff(uint32) ([]ROA, bool)
}

type RTRClientSessionEventHandler

type RTRClientSessionEventHandler interface {
	//RequestCache(*ClientSession)
	HandlePDU(*ClientSession, PDU)
	ClientConnected(*ClientSession)
	ClientDisconnected(*ClientSession)
}

type RTREventHandler

type RTREventHandler interface {
	RequestCache(*Client)
	RequestNewVersion(*Client, uint16, uint32)
}

type RTRServerEventHandler

type RTRServerEventHandler interface {
	ClientConnected(*Client)
	ClientDisconnected(*Client)
	HandlePDU(*Client, PDU)
}

type Server

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

func NewServer

func NewServer(configuration ServerConfiguration, handler RTRServerEventHandler, simpleHandler RTREventHandler) *Server

func (*Server) AddROAs

func (s *Server) AddROAs(roas []ROA)

func (*Server) AddROAsDiff

func (s *Server) AddROAsDiff(diff []ROA)

func (*Server) ClientConnected

func (s *Server) ClientConnected(c *Client)

func (*Server) ClientDisconnected

func (s *Server) ClientDisconnected(c *Client)

func (*Server) GenerateSerial

func (s *Server) GenerateSerial() uint32

func (*Server) GetClientList

func (s *Server) GetClientList() []*Client

func (*Server) GetCurrentROAs

func (s *Server) GetCurrentROAs() ([]ROA, bool)

func (*Server) GetCurrentSerial

func (s *Server) GetCurrentSerial(sessId uint16) (uint32, bool)

func (*Server) GetMaxConnections

func (s *Server) GetMaxConnections() int

func (*Server) GetROAsSerialDiff

func (s *Server) GetROAsSerialDiff(serial uint32) ([]ROA, bool)

func (*Server) GetSessionId

func (s *Server) GetSessionId(c *Client) (uint16, error)

func (*Server) HandlePDU

func (s *Server) HandlePDU(c *Client, pdu PDU)

func (*Server) NotifyClients

func (s *Server) NotifyClients(serialNumber uint32)

func (*Server) NotifyClientsLatest

func (s *Server) NotifyClientsLatest()

func (*Server) RequestCache

func (s *Server) RequestCache(c *Client)

func (*Server) RequestNewVersion

func (s *Server) RequestNewVersion(c *Client, sessionId uint16, serial uint32)

func (*Server) SendPDU

func (s *Server) SendPDU(pdu PDU)

func (*Server) SetBaseVersion

func (s *Server) SetBaseVersion(version uint8)

func (*Server) SetManualSerial added in v0.14.8

func (s *Server) SetManualSerial(v bool)

func (*Server) SetMaxConnections

func (s *Server) SetMaxConnections(maxconn int)

func (*Server) SetSerial added in v0.14.8

func (s *Server) SetSerial(serial uint32)

This function sets the serial. Function must be called before the ROAs data is added.

func (*Server) SetSessionId

func (s *Server) SetSessionId(sessId uint16)

func (*Server) SetVersionEnforced

func (s *Server) SetVersionEnforced(adapt bool)

func (*Server) Start

func (s *Server) Start(bind string) error

func (*Server) StartSSH added in v0.14.8

func (s *Server) StartSSH(bind string, config *ssh.ServerConfig) error

func (*Server) StartTLS

func (s *Server) StartTLS(bind string, config *tls.Config) error

type ServerConfiguration

type ServerConfiguration struct {
	MaxConn         int
	ProtocolVersion uint8
	EnforceVersion  bool
	KeepDifference  int

	SessId int

	RefreshInterval uint32
	RetryInterval   uint32
	ExpireInterval  uint32

	Log        Logger
	LogVerbose bool
}

Jump to

Keyboard shortcuts

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