jnos

package
v1.8.8 Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: BSD-3-Clause Imports: 6 Imported by: 5

Documentation

Overview

Package jnos provides a library for interacting with a JNOS BBS. To use it, first create a Transport that will handle the physical communication. This repository contains two Transport implementations: jnos/kpc3plus and jnos/telnet. Others can be implemented elsewhere as long as they honor the Transport interface in this package.

Once you have an open Transport, pass it to this package's Connect method to create a Conn. Then you can call the Conn methods corresponding to JNOS BBS commands. Call Close on the Conn when finished.

Index

Constants

This section is empty.

Variables

View Source
var ErrDisconnected = errors.New("disconnected")

ErrDisconnected is returned when the connection disconnects unexpectedly.

View Source
var ErrTimeout = errors.New("read timeout expired")

ErrTimeout is returned when a read times out.

Functions

This section is empty.

Types

type Conn

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

Conn is live connection to a JNOS BBS.

func Connect

func Connect(t Transport) (c *Conn, err error)

Connect connects to the JNOS BBS over the supplied open Transport.

func (*Conn) Close

func (c *Conn) Close() (err error)

Close disconnects from the BBS and closes the underlying Transport connection.

func (*Conn) IdentEvery

func (c *Conn) IdentEvery(interval time.Duration, ident string)

IdentEvery causes the JNOS handler to send a comment with an identification every so often. This can be used to send an FCC call sign if we're connected over the air with a tactical call and we're connected for longer than 10 minutes.

func (*Conn) Kill

func (c *Conn) Kill(msgnums ...int) (err error)

Kill kills one or more messages.

func (*Conn) List

func (c *Conn) List(to string) (ml *MessageList, err error)

List returns the list of messages. If "to" is set, only messages sent to addresses containing that string are returned.

func (*Conn) Read

func (c *Conn) Read(msgnum int) (msg string, err error)

Read reads a single message given its number. It returns nil if there is no such message.

func (*Conn) Send

func (c *Conn) Send(subject, body string, to ...string) (err error)

Send sends a private message. Note that the "to" addresses must be bare addresses without any display name or angle brackets.

func (*Conn) SetArea

func (c *Conn) SetArea(area string) error

SetArea switches to the specified message area.

type MessageInfo

type MessageInfo struct {
	// Number is the message number.  It is stable only during the BBS
	// connection.
	Number int
	// Deleted indicates that the message has been Killed and will be
	// deleted when the connection is closed.
	Deleted bool
	// Held indicates whether the message has been held.
	Held bool
	// Read indicates whether the message has been read.
	Read bool
	// ToPrefix is a truncated copy of the To: line of the message.
	ToPrefix string
	// FromPrefix is a truncated copy of the From: line of the message.
	FromPrefix string
	// Date is a partial date of the message.  It can be matched with the
	// "Jan 02" format string for time.Parse.
	Date string
	// Size is the size of the message in bytes.
	Size int
	// SubjectPrefix is a truncated copy of the message subject.
	SubjectPrefix string
}

MessageInfo contains the details of a single message in a MessageList.

type MessageList

type MessageList struct {
	Area     string
	Count    int
	CountNew int
	Messages []*MessageInfo
}

MessageList contains a message list, retrieved with the List call.

type Transport

type Transport interface {
	// ReadUntil reads data from the BBS until the specified string is seen,
	// or a timeout occurs.  It returns the data that was read (even if it
	// returns an error).  It returns ErrDisconnected if the connection to
	// the BBS was lost, ErrTimeout if the read timed out before the
	// specified string was found, and any other error if something else
	// goes wrong.
	ReadUntil(string) (string, error)
	// ReadUntilT reads data from the BBS until the specified string is
	// seen, or the specified timeout occurs.  It returns the data that was
	// read (even if it returns an error).  It returns ErrDisconnected if
	// the connection to the BBS was lost, ErrTimeout if the read timed out
	// before the specified string was found, and any other error if
	// something else goes wrong.
	ReadUntilT(string, time.Duration) (string, error)
	// Send sends a string to the BBS.  It returns ErrDisconnected if the
	// connection to the BBS was lost, and any other error if something else
	// goes wrong.
	Send(string) error
	// Close closes the connection to the BBS.
	Close() error
	// UseVerboseReads returns whether it's appropriate to use verbose reads
	// when communicating over this transport.
	UseVerboseReads() bool
}

Transport is the interface that transport layers passed to Connect must satisfy. All of the transport layers in the subpackages of this library honor this interface.

Directories

Path Synopsis
cmd
jnosargs
Package jnosargs contains the command-line processing to get JNOS transport details.
Package jnosargs contains the command-line processing to get JNOS transport details.
jnoslist
jnoslist lists all messages held in the specified mailbox.
jnoslist lists all messages held in the specified mailbox.
Package kpc3plus provides a transport layer for communicating with a JNOS BBS over RF, by way of a serial connection to a Kantronics KPC 3 Plus TNC.
Package kpc3plus provides a transport layer for communicating with a JNOS BBS over RF, by way of a serial connection to a Kantronics KPC 3 Plus TNC.
Package simulator provides a rudimentary simulation of a JNOS BBS, which can be used for testing JNOS-based services without connecting to a real BBS.
Package simulator provides a rudimentary simulation of a JNOS BBS, which can be used for testing JNOS-based services without connecting to a real BBS.
Package telnet provides a transport layer for communicating with a JNOS BBS over a network.
Package telnet provides a transport layer for communicating with a JNOS BBS over a network.

Jump to

Keyboard shortcuts

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