packet

package
v0.0.0-...-b45fbc0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MSG_BODY_PARSE_BODY       = 1
	MSG_BODY_PARSE_UUE        = 2
	MSG_BODY_PARSE_ROUTE_INFO = 3
)
View Source
const (
	SOH = "\x01"
	CR  = "\x0D"
)
View Source
const (
	AREA_KLUDGE = "AREA:"
)
View Source
const (
	//	CR = "\x0D"
	LF = "\x0A"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaryReader

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

func NewBinaryReader

func NewBinaryReader(reader io.Reader) *BinaryReader

func (*BinaryReader) Offset

func (self *BinaryReader) Offset() int64

func (*BinaryReader) ReadBytes

func (self *BinaryReader) ReadBytes(size int) ([]byte, error)

func (*BinaryReader) ReadINT16

func (self *BinaryReader) ReadINT16() (int16, error)

func (*BinaryReader) ReadINT32

func (self *BinaryReader) ReadINT32() (int32, error)

func (*BinaryReader) ReadUINT16

func (self *BinaryReader) ReadUINT16() (uint16, error)

func (*BinaryReader) ReadUINT32

func (self *BinaryReader) ReadUINT32() (uint32, error)

func (*BinaryReader) ReadUINT8

func (self *BinaryReader) ReadUINT8() (uint8, error)

func (*BinaryReader) ReadUntil

func (self *BinaryReader) ReadUntil(ch byte) ([]byte, error)

func (*BinaryReader) ReadZString

func (self *BinaryReader) ReadZString() ([]byte, error)

type BinaryWriter

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

func NewBinaryWriter

func NewBinaryWriter(writer io.Writer) (*BinaryWriter, error)

func (*BinaryWriter) Close

func (self *BinaryWriter) Close()

func (*BinaryWriter) Offset

func (self *BinaryWriter) Offset() int64

func (*BinaryWriter) WriteBytes

func (self *BinaryWriter) WriteBytes(msg []byte) error

func (*BinaryWriter) WriteINT32

func (self *BinaryWriter) WriteINT32(value int32) error

func (*BinaryWriter) WriteUINT16

func (self *BinaryWriter) WriteUINT16(value uint16) error

func (*BinaryWriter) WriteUINT32

func (self *BinaryWriter) WriteUINT32(value uint32) error

func (*BinaryWriter) WriteUINT8

func (self *BinaryWriter) WriteUINT8(value uint8) error

func (*BinaryWriter) WriteZString

func (self *BinaryWriter) WriteZString(msg []byte) error

func (*BinaryWriter) WriteZStringWithLimit

func (self *BinaryWriter) WriteZStringWithLimit(msg []byte, maxSize int) error

type Kludge

type Kludge struct {
	Name  string
	Value string
	Raw   []byte
}

func NewKludge

func NewKludge() *Kludge

func (*Kludge) Set

func (self *Kludge) Set(raw []byte)

type KludgeState

type KludgeState int8
const (
	KludgeStateName  KludgeState = 1
	KludgeStateValue KludgeState = 2
)

type Message

type Message struct {
	Area     string
	From     string
	FromAddr string
	To       string
	ToAddr   string
	Subject  string
	Content  string
	UnixTime int64 /* Unit time stampe */
	Time     *time.Time
}

func NewMessage

func NewMessage() *Message

func (*Message) SetTime

func (self *Message) SetTime(msgTime *time.Time) error

type MessageBody

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

func NewMessageBody

func NewMessageBody() *MessageBody

func (*MessageBody) AddAttach

func (self *MessageBody) AddAttach(attach MessageBodyAttach)

func (*MessageBody) AddKludge

func (self *MessageBody) AddKludge(k Kludge)

func (*MessageBody) AddLine

func (self *MessageBody) AddLine(line []byte)

func (MessageBody) Bytes

func (self MessageBody) Bytes() []byte

func (MessageBody) GetArea

func (self MessageBody) GetArea() string

func (MessageBody) GetAttachments

func (self MessageBody) GetAttachments() []MessageBodyAttach

func (MessageBody) GetContent

func (self MessageBody) GetContent() []byte

func (*MessageBody) GetKludges

func (self *MessageBody) GetKludges() []Kludge

func (MessageBody) GetOrigin

func (self MessageBody) GetOrigin() []byte

func (MessageBody) GetPacket

func (self MessageBody) GetPacket() []byte

func (MessageBody) IsArea

func (self MessageBody) IsArea() bool

func (*MessageBody) SetArea

func (self *MessageBody) SetArea(area string)

func (*MessageBody) SetContent

func (self *MessageBody) SetContent(content []byte)

func (*MessageBody) SetOrigin

func (self *MessageBody) SetOrigin(origin []byte)

func (*MessageBody) SetPacket

func (self *MessageBody) SetPacket(packet []byte)

type MessageBodyAttach

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

func NewMessageBodyAttach

func NewMessageBodyAttach() *MessageBodyAttach

func (*MessageBodyAttach) GetData

func (self *MessageBodyAttach) GetData() []byte

func (*MessageBodyAttach) GetName

func (self *MessageBodyAttach) GetName() string

func (*MessageBodyAttach) Len

func (self *MessageBodyAttach) Len() int

func (*MessageBodyAttach) Read

func (self *MessageBodyAttach) Read() ([]byte, error)

func (*MessageBodyAttach) SetData

func (self *MessageBodyAttach) SetData(data []byte)

func (*MessageBodyAttach) SetName

func (self *MessageBodyAttach) SetName(name string)

func (*MessageBodyAttach) SetPermission

func (self *MessageBodyAttach) SetPermission(permission string)

func (*MessageBodyAttach) Write

func (self *MessageBodyAttach) Write(row []byte) error

type MessageBodyParser

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

func NewMessageBodyParser

func NewMessageBodyParser() *MessageBodyParser

func (MessageBodyParser) Parse

func (self MessageBodyParser) Parse(content []byte) (*MessageBody, error)

func (*MessageBodyParser) SetDecodeAttachment

func (self *MessageBodyParser) SetDecodeAttachment(yesno bool)

type MsgAttr

type MsgAttr uint16
const (
	MsgAttrPrivate MsgAttr = 1 << 0
	MsgAttrCrash   MsgAttr = 1 << 1
	//	MsgAttrRecd                  MsgAttr   = 1 << 2
	//	MsgAttrSent                  MsgAttr   = 1 << 3
	MsgAttrFileAttached MsgAttr = 1 << 4
)

type NetAddr

type NetAddr struct {
	Zone  uint16
	Net   uint16
	Node  uint16
	Point uint16
}

func NewNetAddr

func NewNetAddr() *NetAddr

func (*NetAddr) SetAddr

func (self *NetAddr) SetAddr(addr string) error

func (NetAddr) String

func (self NetAddr) String() string

type PackedMessage

type PackedMessage struct {
	OrigAddr     NetAddr
	DestAddr     NetAddr
	Attributes   uint16
	Time         *fidotime.FidoDate
	ToUserName   []byte
	FromUserName []byte
	Subject      []byte
	Text         []byte
}

func NewPackedMessage

func NewPackedMessage() *PackedMessage

func (*PackedMessage) SetAttribute

func (self *PackedMessage) SetAttribute(attr MsgAttr)

func (*PackedMessage) SetFromUserName

func (self *PackedMessage) SetFromUserName(FromUserName []byte) error

func (*PackedMessage) SetSubject

func (self *PackedMessage) SetSubject(s []byte) error

func (*PackedMessage) SetText

func (self *PackedMessage) SetText(Text []byte)

func (*PackedMessage) SetTime

func (self *PackedMessage) SetTime(t *fidotime.FidoDate) error

func (*PackedMessage) SetToUserName

func (self *PackedMessage) SetToUserName(ToUserName []byte) error

type PacketHeader

type PacketHeader struct {

	/* Origination */
	OrigZone  uint16
	OrigNet   uint16
	OrigNode  uint16
	OrigPoint uint16

	/* Destination */
	DestZone  uint16
	DestNet   uint16
	DestNode  uint16
	DestPoint uint16

	/* Date and time */
	Year  uint16
	Month uint16
	Day   uint16

	Hour   uint16
	Minute uint16
	Second uint16

	/* Password */
	PktPassword []byte
}

func NewPacketHeader

func NewPacketHeader() *PacketHeader

func (PacketHeader) GetDate

func (self PacketHeader) GetDate() time.Time

func (*PacketHeader) SetDate

func (self *PacketHeader) SetDate(newDate time.Time)

func (*PacketHeader) SetDestAddr

func (self *PacketHeader) SetDestAddr(addr string)

func (*PacketHeader) SetOrigAddr

func (self *PacketHeader) SetOrigAddr(addr string)

func (*PacketHeader) SetPassword

func (self *PacketHeader) SetPassword(password string)

type PacketReader

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

func NewPacketReader

func NewPacketReader(stream io.Reader) *PacketReader

func (*PacketReader) ReadPackedMessage

func (self *PacketReader) ReadPackedMessage() (*PackedMessage, error)

func (*PacketReader) ReadPacketHeader

func (self *PacketReader) ReadPacketHeader() (*PacketHeader, error)

type PacketWriter

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

func NewPacketWriter

func NewPacketWriter(stream io.Writer) (*PacketWriter, error)

func (*PacketWriter) WritePackedMessage

func (self *PacketWriter) WritePackedMessage(packedMessage *PackedMessage) error

func (*PacketWriter) WritePacketEnd

func (self *PacketWriter) WritePacketEnd() error

func (*PacketWriter) WritePacketHeader

func (self *PacketWriter) WritePacketHeader(pktHeader *PacketHeader) error

Jump to

Keyboard shortcuts

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