smpptest

package
v0.0.0-...-5333dff Latest Latest
Warning

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

Go to latest
Published: May 5, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package smpptest provides an SMPP test server.

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultUser     = "client"
	DefaultPasswd   = "secret"
	DefaultSystemID = "smpptest"
)

Default settings.

Functions

func EchoHandler

func EchoHandler(cli Conn, m pdu.Body)

EchoHandler is the default Server HandlerFunc, and echoes back any PDUs received.

Types

type Conn

type Conn interface {
	// Write serializes the given PDU and writes to the connection.
	Write(p pdu.Body) error

	// Close terminates the connection.
	Close() error

	// RemoteAddr returns the peer address.
	RemoteAddr() net.Addr
}

Conn implements a server side connection.

type HandlerFunc

type HandlerFunc func(c Conn, m pdu.Body)

HandlerFunc is the signature of a function passed to Server instances, that is called when client PDU messages arrive.

type Server

type Server struct {
	User    string
	Passwd  string
	TLS     *tls.Config
	Handler HandlerFunc
	// contains filtered or unexported fields
}

Server is an SMPP server for testing purposes. By default it authenticate clients with the configured credentials, and echoes any other PDUs back to the client.

func NewServer

func NewServer() *Server

NewServer creates and initializes a new Server. Callers are supposed to call Close on that server later.

func NewUnstartedServer

func NewUnstartedServer() *Server

NewUnstartedServer creates a new Server with default settings, and does not start it. Callers are supposed to call Start and Close later.

func (*Server) Addr

func (srv *Server) Addr() string

Addr returns the local address of the server, or an empty string if the server hasn't been started yet.

func (*Server) BroadcastMessage

func (srv *Server) BroadcastMessage(p pdu.Body)

BroadcastMessage broadcasts a test PDU to the all bound clients

func (*Server) Close

func (srv *Server) Close()

Close stops the server, causing the accept loop to break out.

func (*Server) Serve

func (srv *Server) Serve()

Serve accepts new clients and handle them by authenticating the first PDU, expected to be a Bind PDU, then echoing all other PDUs.

func (*Server) Start

func (srv *Server) Start()

Start starts the server.

Jump to

Keyboard shortcuts

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