state

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2025 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PrivateExchange is the ID of the exchange that hosts non-public created
	// by users.
	PrivateExchange uint16 = 4
	// PublicExchange is the ID of the exchange that hosts public chat rooms
	// created by the server operator exclusively.
	PublicExchange uint16 = 5
)

Variables

View Source
var (
	ErrChatRoomNotFound = errors.New("chat room not found")
	ErrDupChatRoom      = errors.New("chat room already exists")
)

ErrChatRoomNotFound indicates that a chat room lookup failed.

View Source
var (
	// ErrDupUser indicates that a user already exists.
	ErrDupUser = errors.New("user already exists")
	// ErrNoUser indicates that a user does not exist.
	ErrNoUser = errors.New("user does not exist")
	// ErrNoEmail indicates that a user has not set an email address.
	ErrNoEmailAddress = errors.New("user has no email address")
)
View Source
var (
	ErrAIMHandleInvalidFormat = errors.New("screen name must start with a letter, cannot end with a space, and must contain only letters, numbers, and spaces")
	ErrAIMHandleLength        = errors.New("screen name must be between 3 and 16 characters")
	ErrPasswordInvalid        = errors.New("invalid password length")
	ErrICQUINInvalidFormat    = errors.New("uin must be a number in the range 10000-2147483646")
)
View Source
var (
	ErrKeywordCategoryExists   = errors.New("keyword category already exists")
	ErrKeywordCategoryNotFound = errors.New("keyword category not found")
	ErrKeywordExists           = errors.New("keyword already exists")
	ErrKeywordInUse            = errors.New("can't delete keyword that is associated with a user")
	ErrKeywordNotFound         = errors.New("keyword not found")
)

Functions

This section is empty.

Types

type AIMNameAndAddr added in v0.12.0

type AIMNameAndAddr struct {
	// FirstName is the user's first name.
	FirstName string
	// LastName is the user's last name.
	LastName string
	// MiddleName is the user's middle name.
	MiddleName string
	// MaidenName is the user's maiden name.
	MaidenName string
	// Country is the user's country of residence.
	Country string
	// State is the user's state or region of residence.
	State string
	// City is the user's city of residence.
	City string
	// NickName is the user's chosen nickname.
	NickName string
	// ZIPCode is the user's postal or ZIP code.
	ZIPCode string
	// Address is the user's street address.
	Address string
}

AIMNameAndAddr holds name and address AIM directory information.

type Category added in v0.12.0

type Category struct {
	// ID is the category ID
	ID uint8
	// Name is the category name
	Name string `oscar:"len_prefix=uint16"`
}

Category represents an AIM directory category.

type ChatRoom

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

ChatRoom represents of a chat room.

func NewChatRoom

func NewChatRoom(name string, creator IdentScreenName, exchange uint16) ChatRoom

NewChatRoom creates a new ChatRoom instance.

func (ChatRoom) Cookie

func (c ChatRoom) Cookie() string

Cookie returns the chat room unique identifier.

func (ChatRoom) CreateTime

func (c ChatRoom) CreateTime() time.Time

CreateTime returns when the chat room was inserted in the database.

func (ChatRoom) Creator added in v0.8.0

func (c ChatRoom) Creator() IdentScreenName

Creator returns the screen name of the user who created the chat room.

func (ChatRoom) DetailLevel

func (c ChatRoom) DetailLevel() uint8

DetailLevel returns the detail level of the chat room (whatever that means).

func (ChatRoom) Exchange

func (c ChatRoom) Exchange() uint16

Exchange returns which exchange the chat room belongs to.

func (ChatRoom) InstanceNumber

func (c ChatRoom) InstanceNumber() uint16

InstanceNumber returns which instance chatroom exists in. Overflow chat rooms do not exist yet, so all chats happen in the same instance.

func (ChatRoom) Name

func (c ChatRoom) Name() string

Name returns the chat room name.

func (ChatRoom) TLVList

func (c ChatRoom) TLVList() []wire.TLV

TLVList returns a TLV list of chat room metadata.

func (ChatRoom) URL added in v0.8.0

func (c ChatRoom) URL() *url.URL

URL creates a URL that can be used to join a chat room.

type DisplayScreenName added in v0.7.0

type DisplayScreenName string

DisplayScreenName type represents the screen name in the user-defined format. This includes the original casing and spacing as defined by the user.

func (DisplayScreenName) IdentScreenName added in v0.7.0

func (s DisplayScreenName) IdentScreenName() IdentScreenName

IdentScreenName converts the DisplayScreenName to an IdentScreenName by applying the normalization process defined in NewIdentScreenName.

func (DisplayScreenName) IsUIN added in v0.10.0

func (s DisplayScreenName) IsUIN() bool

IsUIN indicates whether the screen name is an ICQ UIN.

func (DisplayScreenName) String added in v0.7.0

func (s DisplayScreenName) String() string

String returns the original display string of the screen name, preserving the user-defined casing and spaces.

func (DisplayScreenName) ValidateAIMHandle added in v0.10.0

func (s DisplayScreenName) ValidateAIMHandle() error

ValidateAIMHandle returns an error if the instance is not a valid AIM screen name. Possible errors:

  • ErrAIMHandleLength: if the screen name has less than 3 non-space characters or more than 16 characters (including spaces).
  • ErrAIMHandleInvalidFormat: if the screen name does not start with a letter, ends with a space, or contains invalid characters

func (DisplayScreenName) ValidateUIN added in v0.10.0

func (s DisplayScreenName) ValidateUIN() error

ValidateUIN returns an error if the instance is not a valid ICQ UIN. Possible errors:

  • ErrICQUINInvalidFormat: if the UIN is not a number or is not in the valid range

type HMACCookieBaker added in v0.7.0

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

func NewHMACCookieBaker added in v0.7.0

func NewHMACCookieBaker() (HMACCookieBaker, error)

func (HMACCookieBaker) Crack added in v0.7.0

func (c HMACCookieBaker) Crack(data []byte) ([]byte, error)

func (HMACCookieBaker) Issue added in v0.7.0

func (c HMACCookieBaker) Issue(data []byte) ([]byte, error)

type ICQAffiliations added in v0.10.0

type ICQAffiliations struct {
	// PastCode1 is the code representing the user's first past affiliation.
	PastCode1 uint16
	// PastKeyword1 is the keyword associated with the user's first past affiliation.
	PastKeyword1 string
	// PastCode2 is the code representing the user's second past affiliation.
	PastCode2 uint16
	// PastKeyword2 is the keyword associated with the user's second past affiliation.
	PastKeyword2 string
	// PastCode3 is the code representing the user's third past affiliation.
	PastCode3 uint16
	// PastKeyword3 is the keyword associated with the user's third past affiliation.
	PastKeyword3 string
	// CurrentCode1 is the code representing the user's current first affiliation.
	CurrentCode1 uint16
	// CurrentKeyword1 is the keyword associated with the user's current first affiliation.
	CurrentKeyword1 string
	// CurrentCode2 is the code representing the user's current second affiliation.
	CurrentCode2 uint16
	// CurrentKeyword2 is the keyword associated with the user's current second affiliation.
	CurrentKeyword2 string
	// CurrentCode3 is the code representing the user's current third affiliation.
	CurrentCode3 uint16
	// CurrentKeyword3 is the keyword associated with the user's current third affiliation.
	CurrentKeyword3 string
}

ICQAffiliations contains information about the user's affiliations, both past and present.

type ICQBasicInfo added in v0.10.0

type ICQBasicInfo struct {
	// Address is the user's residential address.
	Address string
	// CellPhone is the user's mobile phone number.
	CellPhone string
	// City is the city where the user resides.
	City string
	// CountryCode is the code representing the user's country of residence.
	CountryCode uint16
	// EmailAddress is the user's primary email address.
	EmailAddress string
	// Fax is the user's fax number.
	Fax string
	// FirstName is the user's first name.
	FirstName string
	// GMTOffset is the user's time zone offset from GMT.
	GMTOffset uint8
	// LastName is the user's last name.
	LastName string
	// Nickname is the user's nickname or preferred name.
	Nickname string
	// Phone is the user's landline phone number.
	Phone string
	// PublishEmail indicates whether the user's email address is public.
	PublishEmail bool
	// State is the state or region where the user resides.
	State string
	// ZIPCode is the user's postal code.
	ZIPCode string
}

ICQBasicInfo holds basic information about an ICQ user, including their name, contact details, and location.

type ICQInterests added in v0.10.0

type ICQInterests struct {
	// Code1 is the code representing the user's first interest.
	Code1 uint16
	// Keyword1 is the keyword associated with the user's first interest.
	Keyword1 string
	// Code2 is the code representing the user's second interest.
	Code2 uint16
	// Keyword2 is the keyword associated with the user's second interest.
	Keyword2 string
	// Code3 is the code representing the user's third interest.
	Code3 uint16
	// Keyword3 is the keyword associated with the user's third interest.
	Keyword3 string
	// Code4 is the code representing the user's fourth interest.
	Code4 uint16
	// Keyword4 is the keyword associated with the user's fourth interest.
	Keyword4 string
}

ICQInterests holds information about the user's interests, categorized by interest code and associated keyword.

type ICQMoreInfo added in v0.10.0

type ICQMoreInfo struct {
	// Gender is the user's gender, represented by a code.
	Gender uint16
	// HomePageAddr is the URL of the user's personal homepage.
	HomePageAddr string
	// BirthYear is the user's birth year.
	BirthYear uint16
	// BirthMonth is the user's birth month.
	BirthMonth uint8
	// BirthDay is the user's birth day.
	BirthDay uint8
	// Lang1 is the code for the user's primary language.
	Lang1 uint8
	// Lang2 is the code for the user's secondary language.
	Lang2 uint8
	// Lang3 is the code for the user's tertiary language.
	Lang3 uint8
}

ICQMoreInfo contains additional information about the user, such as demographic and language preferences.

type ICQPermissions added in v0.10.0

type ICQPermissions struct {
	// AuthRequired indicates where users must ask this permission to add them
	// to their contact list.
	AuthRequired bool
}

ICQPermissions specifies the privacy settings of an ICQ user.

type ICQUserNotes added in v0.10.0

type ICQUserNotes struct {
	// Notes are the personal notes or additional information the user has
	// entered in their profile.
	Notes string
}

ICQUserNotes contains personal notes or additional information added by the user.

type ICQWorkInfo added in v0.10.0

type ICQWorkInfo struct {
	// Address is the address of the user's workplace.
	Address string
	// City is the city where the user's workplace is located.
	City string
	// Company is the name of the user's employer or company.
	Company string
	// CountryCode is the code representing the country where the user's
	// workplace is located.
	CountryCode uint16
	// Department is the name of the department within the user's company.
	Department string
	// Fax is the fax number for the user's workplace.
	Fax string
	// OccupationCode is the code representing the user's occupation.
	OccupationCode uint16
	// Phone is the phone number for the user's workplace.
	Phone string
	// Position is the user's job title or position within the company.
	Position string
	// State is the state or region where the user's workplace is located.
	State string
	// WebPage is the URL of the user's company's website.
	WebPage string
	// ZIPCode is the postal code for the user's workplace.
	ZIPCode string
}

ICQWorkInfo contains information about the user's professional life, including their workplace and job title.

type IdentScreenName added in v0.7.0

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

IdentScreenName struct stores the normalized version of a user's screen name. This format is used for uniformity in storage and comparison by removing spaces and converting all characters to lowercase.

func NewIdentScreenName added in v0.7.0

func NewIdentScreenName(screenName string) IdentScreenName

NewIdentScreenName creates a new IdentScreenName.

func (IdentScreenName) String added in v0.7.0

func (i IdentScreenName) String() string

String returns the string representation of the IdentScreenName.

func (IdentScreenName) UIN added in v0.10.0

func (i IdentScreenName) UIN() uint32

UIN returns a numeric UIN representation of the IdentScreenName.

type InMemoryChatSessionManager added in v0.8.0

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

InMemoryChatSessionManager manages chat sessions for multiple chat rooms stored in memory. It provides thread-safe operations to add, remove, and manipulate sessions as well as relay messages to participants.

func NewInMemoryChatSessionManager added in v0.8.0

func NewInMemoryChatSessionManager(logger *slog.Logger) *InMemoryChatSessionManager

NewInMemoryChatSessionManager creates a new instance of InMemoryChatSessionManager.

func (*InMemoryChatSessionManager) AddSession added in v0.8.0

func (s *InMemoryChatSessionManager) AddSession(ctx context.Context, chatCookie string, screenName DisplayScreenName) (*Session, error)

AddSession adds a user to a chat room. If screenName already exists, the old session is replaced by a new one.

func (*InMemoryChatSessionManager) AllSessions added in v0.8.0

func (s *InMemoryChatSessionManager) AllSessions(cookie string) []*Session

AllSessions returns all chat room participants. Returns ErrChatRoomNotFound if the room does not exist.

func (*InMemoryChatSessionManager) RelayToAllExcept added in v0.8.0

func (s *InMemoryChatSessionManager) RelayToAllExcept(ctx context.Context, cookie string, except IdentScreenName, msg wire.SNACMessage)

RelayToAllExcept sends a message to all chat room participants except for the participant with a particular screen name. Returns ErrChatRoomNotFound if the room does not exist for cookie.

func (*InMemoryChatSessionManager) RelayToScreenName added in v0.8.0

func (s *InMemoryChatSessionManager) RelayToScreenName(ctx context.Context, cookie string, recipient IdentScreenName, msg wire.SNACMessage)

RelayToScreenName sends a message to a chat room user. Returns ErrChatRoomNotFound if the room does not exist for cookie.

func (*InMemoryChatSessionManager) RemoveSession added in v0.8.0

func (s *InMemoryChatSessionManager) RemoveSession(sess *Session)

RemoveSession removes a user session from a chat room. It panics if you attempt to remove the session twice.

func (*InMemoryChatSessionManager) RemoveUserFromAllChats added in v0.16.0

func (s *InMemoryChatSessionManager) RemoveUserFromAllChats(user IdentScreenName)

RemoveUserFromAllChats removes a user's session from all chat rooms.

type InMemorySessionManager

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

InMemorySessionManager handles the lifecycle of a user session and provides synchronized message relay between sessions in the session pool. An InMemorySessionManager is safe for concurrent use by multiple goroutines.

func NewInMemorySessionManager

func NewInMemorySessionManager(logger *slog.Logger) *InMemorySessionManager

NewInMemorySessionManager creates a new instance of InMemorySessionManager.

func (*InMemorySessionManager) AddSession

func (s *InMemorySessionManager) AddSession(ctx context.Context, screenName DisplayScreenName) (*Session, error)

func (*InMemorySessionManager) AllSessions

func (s *InMemorySessionManager) AllSessions() []*Session

AllSessions returns all sessions in the session pool.

func (*InMemorySessionManager) Empty

func (s *InMemorySessionManager) Empty() bool

Empty returns true if the session pool contains 0 sessions.

func (*InMemorySessionManager) RelayToAll

func (s *InMemorySessionManager) RelayToAll(ctx context.Context, msg wire.SNACMessage)

RelayToAll relays a message to all sessions in the session pool.

func (*InMemorySessionManager) RelayToScreenName

func (s *InMemorySessionManager) RelayToScreenName(ctx context.Context, screenName IdentScreenName, msg wire.SNACMessage)

RelayToScreenName relays a message to a session with a matching screen name.

func (*InMemorySessionManager) RelayToScreenNames

func (s *InMemorySessionManager) RelayToScreenNames(ctx context.Context, screenNames []IdentScreenName, msg wire.SNACMessage)

RelayToScreenNames relays a message to sessions with matching screenNames.

func (*InMemorySessionManager) RemoveSession

func (s *InMemorySessionManager) RemoveSession(sess *Session)

RemoveSession takes a session out of the session pool.

func (*InMemorySessionManager) RetrieveSession

func (s *InMemorySessionManager) RetrieveSession(screenName IdentScreenName) *Session

RetrieveSession finds a session with a matching sessionID. Returns nil if session is not found.

type Keyword added in v0.12.0

type Keyword struct {
	// ID is the keyword ID
	ID uint8
	// Name is the keyword name
	Name string `oscar:"len_prefix=uint16"`
}

Keyword represents an AIM directory keyword.

type OfflineMessage added in v0.10.0

type OfflineMessage struct {
	Sender    IdentScreenName
	Recipient IdentScreenName
	Message   wire.SNAC_0x04_0x06_ICBMChannelMsgToHost
	Sent      time.Time
}

type RateClassState added in v0.17.0

type RateClassState struct {
	// static rate limit configuration for this class
	wire.RateClass
	// CurrentLevel is the current exponential moving average for this rate
	// class.
	CurrentLevel int32
	// LastTime represents the last time a SNAC message was sent for this rate
	// class.
	LastTime time.Time
	// CurrentStatus is the last recorded rate limit status for this rate class.
	CurrentStatus wire.RateLimitStatus
	// Subscribed indicates whether the user wants to receive rate limit
	// parameter updates for this rate class.
	Subscribed bool
	// LimitedNow indicates whether the user is currently rate limited for this
	// rate class; the user is blocked from sending SNACs in this rate class
	// until the clear threshold is met.
	LimitedNow bool
}

RateClassState tracks the rate limiting state for a specific rate class within a user's session.

It embeds the static wire.RateClass configuration and maintains dynamic, per-session state used to evaluate rate limits in real time.

type Relationship added in v0.14.0

type Relationship struct {
	// User is the screen name of the user with whom you have a relationship.
	User IdentScreenName
	// BlocksYou indicates whether user blocks you. This is true when user has
	// the following permit/deny modes set:
	// 	- DenyAll
	// 	- PermitSome (and you are not on permit list)
	// 	- DenySome (and you are on deny list)
	// 	- PermitOnList (and you are not on their buddy list)
	BlocksYou bool
	// YouBlock indicates whether you block user. This is true when user has
	// the following permit/deny modes set:
	// 	- DenyAll
	// 	- PermitSome (and they are not on your permit list)
	// 	- DenySome (and they are on your deny list)
	// 	- PermitOnList (and they are not on your buddy list)
	YouBlock bool
	// IsOnTheirList indicates whether you are on user's buddy list.
	IsOnTheirList bool
	// IsOnYourList indicates whether this user is on your buddy list.
	IsOnYourList bool
}

Relationship represents the relationship between two users. Users A and B are related if:

  • A has user B on their buddy list, or vice versa
  • A has user B on their deny list, or vice versa
  • A has user B on their permit list, or vice versa

type SQLiteUserStore

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

SQLiteUserStore stores user feedbag (buddy list), profile, and authentication credentials information in a SQLite database.

func NewSQLiteUserStore

func NewSQLiteUserStore(dbFilePath string) (*SQLiteUserStore, error)

NewSQLiteUserStore creates a new instance of SQLiteUserStore. If the database does not already exist, a new one is created with the required schema.

func (SQLiteUserStore) AddBuddy added in v0.14.0

func (SQLiteUserStore) AllChatRooms added in v0.8.0

func (f SQLiteUserStore) AllChatRooms(ctx context.Context, exchange uint16) ([]ChatRoom, error)

func (SQLiteUserStore) AllRelationships added in v0.14.0

func (f SQLiteUserStore) AllRelationships(ctx context.Context, me IdentScreenName, filter []IdentScreenName) ([]Relationship, error)

AllRelationships retrieves the relationships between the specified user (`me`) and other users.

A relationship is defined by the Relationship type, which describes the nature of the connection between users.

This function only includes users who have activated their buddy list through a call to SQLiteUserStore.RegisterBuddyList. The results can be optionally filtered to include only specific users by providing their identifiers in the `filter` parameter.

func (SQLiteUserStore) AllUsers

func (f SQLiteUserStore) AllUsers(ctx context.Context) ([]User, error)

func (SQLiteUserStore) BuddyIcon added in v0.17.0

func (f SQLiteUserStore) BuddyIcon(ctx context.Context, md5 []byte) ([]byte, error)

func (SQLiteUserStore) BuddyIconMetadata added in v0.17.0

func (f SQLiteUserStore) BuddyIconMetadata(ctx context.Context, screenName IdentScreenName) (*wire.BARTID, error)

func (SQLiteUserStore) Categories added in v0.12.0

func (f SQLiteUserStore) Categories(ctx context.Context) ([]Category, error)

func (SQLiteUserStore) ChatRoomByCookie added in v0.8.0

func (f SQLiteUserStore) ChatRoomByCookie(ctx context.Context, chatCookie string) (ChatRoom, error)

func (SQLiteUserStore) ChatRoomByName added in v0.8.0

func (f SQLiteUserStore) ChatRoomByName(ctx context.Context, exchange uint16, name string) (ChatRoom, error)

func (SQLiteUserStore) ClearBuddyListRegistry added in v0.14.0

func (f SQLiteUserStore) ClearBuddyListRegistry(ctx context.Context) error

func (SQLiteUserStore) ConfirmStatus added in v0.17.0

func (f SQLiteUserStore) ConfirmStatus(ctx context.Context, screenName IdentScreenName) (bool, error)

func (SQLiteUserStore) CreateCategory added in v0.12.0

func (f SQLiteUserStore) CreateCategory(ctx context.Context, name string) (Category, error)

func (SQLiteUserStore) CreateChatRoom added in v0.8.0

func (f SQLiteUserStore) CreateChatRoom(ctx context.Context, chatRoom *ChatRoom) error

func (SQLiteUserStore) CreateKeyword added in v0.12.0

func (f SQLiteUserStore) CreateKeyword(ctx context.Context, name string, categoryID uint8) (Keyword, error)

func (SQLiteUserStore) DeleteCategory added in v0.12.0

func (f SQLiteUserStore) DeleteCategory(ctx context.Context, categoryID uint8) error

func (SQLiteUserStore) DeleteKeyword added in v0.12.0

func (f SQLiteUserStore) DeleteKeyword(ctx context.Context, id uint8) error

func (SQLiteUserStore) DeleteMessages added in v0.10.0

func (f SQLiteUserStore) DeleteMessages(ctx context.Context, recip IdentScreenName) error

func (SQLiteUserStore) DeleteUser added in v0.6.0

func (f SQLiteUserStore) DeleteUser(ctx context.Context, screenName IdentScreenName) error

func (SQLiteUserStore) DenyBuddy added in v0.14.0

func (SQLiteUserStore) EmailAddress added in v0.17.0

func (f SQLiteUserStore) EmailAddress(ctx context.Context, screenName IdentScreenName) (*mail.Address, error)

func (SQLiteUserStore) Feedbag

func (f SQLiteUserStore) Feedbag(ctx context.Context, screenName IdentScreenName) ([]wire.FeedbagItem, error)

func (SQLiteUserStore) FeedbagDelete

func (f SQLiteUserStore) FeedbagDelete(ctx context.Context, screenName IdentScreenName, items []wire.FeedbagItem) error

func (SQLiteUserStore) FeedbagLastModified

func (f SQLiteUserStore) FeedbagLastModified(ctx context.Context, screenName IdentScreenName) (time.Time, error)

func (SQLiteUserStore) FeedbagUpsert

func (f SQLiteUserStore) FeedbagUpsert(ctx context.Context, screenName IdentScreenName, items []wire.FeedbagItem) error

func (SQLiteUserStore) FindByAIMEmail added in v0.12.0

func (f SQLiteUserStore) FindByAIMEmail(ctx context.Context, email string) (User, error)

func (SQLiteUserStore) FindByAIMKeyword added in v0.12.0

func (f SQLiteUserStore) FindByAIMKeyword(ctx context.Context, keyword string) ([]User, error)

func (SQLiteUserStore) FindByAIMNameAndAddr added in v0.12.0

func (f SQLiteUserStore) FindByAIMNameAndAddr(ctx context.Context, info AIMNameAndAddr) ([]User, error)

func (SQLiteUserStore) FindByICQEmail added in v0.12.0

func (f SQLiteUserStore) FindByICQEmail(ctx context.Context, email string) (User, error)

func (SQLiteUserStore) FindByICQInterests added in v0.12.0

func (f SQLiteUserStore) FindByICQInterests(ctx context.Context, code uint16, keywords []string) ([]User, error)

func (SQLiteUserStore) FindByICQKeyword added in v0.12.0

func (f SQLiteUserStore) FindByICQKeyword(ctx context.Context, keyword string) ([]User, error)

func (SQLiteUserStore) FindByICQName added in v0.12.0

func (f SQLiteUserStore) FindByICQName(ctx context.Context, firstName, lastName, nickName string) ([]User, error)

func (SQLiteUserStore) FindByUIN added in v0.10.0

func (f SQLiteUserStore) FindByUIN(ctx context.Context, UIN uint32) (User, error)

func (SQLiteUserStore) InsertUser

func (f SQLiteUserStore) InsertUser(ctx context.Context, u User) error

func (SQLiteUserStore) InterestList added in v0.12.0

func (f SQLiteUserStore) InterestList(ctx context.Context) ([]wire.ODirKeywordListItem, error)

InterestList returns a list of keywords grouped by category used to render the AIM directory interests list. The list is made up of 3 types of elements:

Categories

ID: The category ID
Cookie: The category name
Type: [wire.ODirKeywordCategory]

Keywords

ID: The parent category ID
Cookie: The keyword name
Type: [wire.ODirKeyword]

Top-level Keywords

ID: 0 (does not have a parent category)
Cookie: The keyword name
Type: [wire.ODirKeyword]

Keywords are grouped contiguously by category and preceded by the category name. Top-level keywords appear by themselves. Categories and top-level keywords are sorted alphabetically. Keyword groups are sorted alphabetically.

Conceptually, the list looks like this:

> Animals (top-level keyword, id=0)
> Artificial Intelligence (keyword, id=3)
	> Cybersecurity (keyword, id=3)
> Music (category, id=1)
	> Jazz (keyword, id=1)
	> Rock (keyword, id=1)
> Sports (category, id=2)
	> Basketball (keyword, id=2)
	> Soccer (keyword, id=2)
	> Tennis (keyword, id=2)
> Technology (category, id=3)
> Zoology (top-level keyword, id=0)

func (SQLiteUserStore) KeywordsByCategory added in v0.12.0

func (f SQLiteUserStore) KeywordsByCategory(ctx context.Context, categoryID uint8) ([]Keyword, error)

func (SQLiteUserStore) PermitBuddy added in v0.14.0

func (f SQLiteUserStore) PermitBuddy(ctx context.Context, me IdentScreenName, them IdentScreenName) error

func (SQLiteUserStore) Profile

func (f SQLiteUserStore) Profile(ctx context.Context, screenName IdentScreenName) (string, error)

func (SQLiteUserStore) RegStatus added in v0.17.0

func (f SQLiteUserStore) RegStatus(ctx context.Context, screenName IdentScreenName) (uint16, error)

func (SQLiteUserStore) RegisterBuddyList added in v0.14.0

func (f SQLiteUserStore) RegisterBuddyList(ctx context.Context, user IdentScreenName) error

func (SQLiteUserStore) Relationship added in v0.14.0

Relationship retrieves the relationship between the specified user (`me`) and another user (`them`).

This method always returns a usable Relationship value. If the user specified by `them` does not exist, the returned Relationship will have default boolean values.

func (SQLiteUserStore) RemoveBuddy added in v0.14.0

func (f SQLiteUserStore) RemoveBuddy(ctx context.Context, me IdentScreenName, them IdentScreenName) error

func (SQLiteUserStore) RemoveDenyBuddy added in v0.14.0

func (f SQLiteUserStore) RemoveDenyBuddy(ctx context.Context, me IdentScreenName, them IdentScreenName) error

func (SQLiteUserStore) RemovePermitBuddy added in v0.14.0

func (f SQLiteUserStore) RemovePermitBuddy(ctx context.Context, me IdentScreenName, them IdentScreenName) error

func (SQLiteUserStore) RetrieveMessages added in v0.10.0

func (f SQLiteUserStore) RetrieveMessages(ctx context.Context, recip IdentScreenName) ([]OfflineMessage, error)

func (SQLiteUserStore) SaveMessage added in v0.10.0

func (f SQLiteUserStore) SaveMessage(ctx context.Context, offlineMessage OfflineMessage) error

func (SQLiteUserStore) SetAffiliations added in v0.10.0

func (f SQLiteUserStore) SetAffiliations(ctx context.Context, name IdentScreenName, data ICQAffiliations) error

func (SQLiteUserStore) SetBasicInfo added in v0.10.0

func (f SQLiteUserStore) SetBasicInfo(ctx context.Context, name IdentScreenName, data ICQBasicInfo) error

func (SQLiteUserStore) SetBotStatus added in v0.18.0

func (f SQLiteUserStore) SetBotStatus(ctx context.Context, isBot bool, screenName IdentScreenName) error

func (SQLiteUserStore) SetBuddyIcon added in v0.17.0

func (f SQLiteUserStore) SetBuddyIcon(ctx context.Context, md5 []byte, image []byte) error

func (SQLiteUserStore) SetDirectoryInfo added in v0.12.0

func (f SQLiteUserStore) SetDirectoryInfo(ctx context.Context, screenName IdentScreenName, info AIMNameAndAddr) error

func (SQLiteUserStore) SetInterests added in v0.10.0

func (f SQLiteUserStore) SetInterests(ctx context.Context, name IdentScreenName, data ICQInterests) error

func (SQLiteUserStore) SetKeywords added in v0.12.0

func (f SQLiteUserStore) SetKeywords(ctx context.Context, screenName IdentScreenName, keywords [5]string) error

func (SQLiteUserStore) SetMoreInfo added in v0.10.0

func (f SQLiteUserStore) SetMoreInfo(ctx context.Context, name IdentScreenName, data ICQMoreInfo) error

func (SQLiteUserStore) SetPDMode added in v0.14.0

func (f SQLiteUserStore) SetPDMode(ctx context.Context, me IdentScreenName, pdMode wire.FeedbagPDMode) error

func (SQLiteUserStore) SetProfile

func (f SQLiteUserStore) SetProfile(ctx context.Context, screenName IdentScreenName, body string) error

func (SQLiteUserStore) SetTOCConfig added in v0.15.0

func (f SQLiteUserStore) SetTOCConfig(ctx context.Context, user IdentScreenName, config string) error

func (SQLiteUserStore) SetUserNotes added in v0.10.0

func (f SQLiteUserStore) SetUserNotes(ctx context.Context, name IdentScreenName, data ICQUserNotes) error

func (SQLiteUserStore) SetUserPassword added in v0.3.0

func (f SQLiteUserStore) SetUserPassword(ctx context.Context, screenName IdentScreenName, newPassword string) error

func (SQLiteUserStore) SetWorkInfo added in v0.10.0

func (f SQLiteUserStore) SetWorkInfo(ctx context.Context, name IdentScreenName, data ICQWorkInfo) error

func (SQLiteUserStore) UnregisterBuddyList added in v0.14.0

func (f SQLiteUserStore) UnregisterBuddyList(ctx context.Context, user IdentScreenName) error

func (SQLiteUserStore) UpdateConfirmStatus added in v0.9.0

func (f SQLiteUserStore) UpdateConfirmStatus(ctx context.Context, screenName IdentScreenName, confirmStatus bool) error

func (SQLiteUserStore) UpdateDisplayScreenName added in v0.9.0

func (f SQLiteUserStore) UpdateDisplayScreenName(ctx context.Context, displayScreenName DisplayScreenName) error

func (SQLiteUserStore) UpdateEmailAddress added in v0.9.0

func (f SQLiteUserStore) UpdateEmailAddress(ctx context.Context, screenName IdentScreenName, emailAddress *mail.Address) error

func (SQLiteUserStore) UpdateRegStatus added in v0.9.0

func (f SQLiteUserStore) UpdateRegStatus(ctx context.Context, screenName IdentScreenName, regStatus uint16) error

func (SQLiteUserStore) UpdateSuspendedStatus added in v0.16.0

func (f SQLiteUserStore) UpdateSuspendedStatus(ctx context.Context, suspendedStatus uint16, screenName IdentScreenName) error

func (SQLiteUserStore) UseFeedbag added in v0.14.0

func (f SQLiteUserStore) UseFeedbag(ctx context.Context, screenName IdentScreenName) error

func (SQLiteUserStore) User

func (f SQLiteUserStore) User(ctx context.Context, screenName IdentScreenName) (*User, error)

type ServerCookie added in v0.19.0

type ServerCookie struct {
	Service    uint16
	ScreenName DisplayScreenName `oscar:"len_prefix=uint8"`
	ClientID   string            `oscar:"len_prefix=uint8"`
	ChatCookie string            `oscar:"len_prefix=uint8"`
}

ServerCookie represents a token containing client metadata passed to the BOS service upon connection.

type SessSendStatus

type SessSendStatus int

SessSendStatus is the result of sending a message to a user.

const (
	// SessSendOK indicates message was sent to recipient
	SessSendOK SessSendStatus = iota
	// SessSendClosed indicates send did not complete because session is closed
	SessSendClosed
	// SessQueueFull indicates send failed due to full queue -- client is likely
	// dead
	SessQueueFull
)

type Session

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

Session represents a user's current session. Unless stated otherwise, all methods may be safely accessed by multiple goroutines.

func NewSession

func NewSession() *Session

NewSession returns a new instance of Session. By default, the user may have up to 1000 pending messages before blocking.

func (*Session) AwayMessage

func (s *Session) AwayMessage() string

AwayMessage returns the user's away message.

func (*Session) Caps

func (s *Session) Caps() [][16]byte

Caps retrieves user capabilities.

func (*Session) ChatRoomCookie

func (s *Session) ChatRoomCookie() string

ChatRoomCookie gets the chatRoomCookie for the chat room the user is currently in.

func (*Session) ClearUserInfoFlag added in v0.9.0

func (s *Session) ClearUserInfoFlag(flag uint16) (flags uint16)

ClearUserInfoFlag clear a flag from and returns UserInfoBitmask

func (*Session) ClientID added in v0.13.0

func (s *Session) ClientID() string

ClientID retrieves the client ID.

func (*Session) Close

func (s *Session) Close()

Close shuts down the session's ability to relay messages. Once invoked, RelayMessage returns SessQueueFull and Closed returns a closed channel. It is not possible to re-open message relaying once closed. It is safe to call from multiple go routines.

func (*Session) Closed

func (s *Session) Closed() <-chan struct{}

Closed blocks until the session is closed.

func (*Session) DisplayScreenName added in v0.7.0

func (s *Session) DisplayScreenName() DisplayScreenName

DisplayScreenName returns the user's screen name.

func (*Session) EvaluateRateLimit added in v0.17.0

func (s *Session) EvaluateRateLimit(now time.Time, rateClassID wire.RateLimitClassID) wire.RateLimitStatus

EvaluateRateLimit checks and updates the session’s rate limit state for the given rate class ID. If the rate status reaches 'disconnect', the session is closed. Rate limits are not enforced if the user is a bot (has wire.OServiceUserFlagBot set in their user info bitmask).

func (*Session) FoodGroupVersions added in v0.17.0

func (s *Session) FoodGroupVersions() [wire.MDir + 1]uint16

FoodGroupVersions retrieves the client's supported food group versions.

func (*Session) IdentScreenName added in v0.7.0

func (s *Session) IdentScreenName() IdentScreenName

IdentScreenName returns the user's screen name.

func (*Session) Idle added in v0.11.0

func (s *Session) Idle() bool

Idle reports the user's idle state.

func (*Session) IdleTime added in v0.11.0

func (s *Session) IdleTime() time.Time

IdleTime reports when the user went idle

func (*Session) IncrementWarning

func (s *Session) IncrementWarning(incr uint16)

IncrementWarning increments the user's warning level. To decrease, pass a negative increment value.

func (*Session) Invisible

func (s *Session) Invisible() bool

Invisible returns true if the user is idle.

func (*Session) ObserveRateChanges added in v0.17.0

func (s *Session) ObserveRateChanges(now time.Time) (classDelta []RateClassState, stateDelta []RateClassState)

ObserveRateChanges updates rate limit states for all known classes and returns any classes and class states that have changed since the previous observation.

func (*Session) ReceiveMessage

func (s *Session) ReceiveMessage() chan wire.SNACMessage

ReceiveMessage returns a channel of messages relayed via this session. It may only be read by one consumer. The channel never closes; call this method in a select block along with Closed in order to detect session closure.

func (*Session) RelayMessage

func (s *Session) RelayMessage(msg wire.SNACMessage) SessSendStatus

RelayMessage receives a SNAC message from a user and passes it on asynchronously to the consumer of this session's messages. It returns SessSendStatus to indicate whether the message was successfully sent or not. This method is non-blocking.

func (*Session) RemoteAddr added in v0.16.0

func (s *Session) RemoteAddr() (remoteAddr *netip.AddrPort)

RemoteAddrs returns user's remote IP address

func (*Session) SetAwayMessage

func (s *Session) SetAwayMessage(awayMessage string)

SetAwayMessage sets the user's away message.

func (*Session) SetCaps

func (s *Session) SetCaps(caps [][16]byte)

SetCaps sets capability UUIDs that represent the features the client supports. If set, capability metadata appears in the user info TLV list.

func (*Session) SetChatRoomCookie

func (s *Session) SetChatRoomCookie(cookie string)

SetChatRoomCookie sets the chatRoomCookie for the chat room the user is currently in.

func (*Session) SetClientID added in v0.13.0

func (s *Session) SetClientID(clientID string)

SetClientID sets the client ID.

func (*Session) SetDisplayScreenName added in v0.7.0

func (s *Session) SetDisplayScreenName(displayScreenName DisplayScreenName)

SetDisplayScreenName sets the user's screen name.

func (*Session) SetFoodGroupVersions added in v0.17.0

func (s *Session) SetFoodGroupVersions(versions [wire.MDir + 1]uint16)

SetFoodGroupVersions sets the client's supported food group versions

func (*Session) SetIdentScreenName added in v0.7.0

func (s *Session) SetIdentScreenName(screenName IdentScreenName)

SetIdentScreenName sets the user's screen name.

func (*Session) SetIdle

func (s *Session) SetIdle(dur time.Duration)

SetIdle sets the user's idle state.

func (*Session) SetRateClasses added in v0.17.0

func (s *Session) SetRateClasses(now time.Time, classes wire.RateLimitClasses)

func (*Session) SetRemoteAddr added in v0.16.0

func (s *Session) SetRemoteAddr(remoteAddr *netip.AddrPort)

SetRemoteAddr sets the user's remote IP address

func (*Session) SetSignonComplete added in v0.3.0

func (s *Session) SetSignonComplete()

SetSignonComplete indicates that the client has completed the sign-on sequence.

func (*Session) SetSignonTime

func (s *Session) SetSignonTime(t time.Time)

SetSignonTime sets the user's sign-ontime.

func (*Session) SetTypingEventsEnabled added in v0.17.0

func (s *Session) SetTypingEventsEnabled(enabled bool)

SetTypingEventsEnabled sets whether the client wants to send and receive typing events.

func (*Session) SetUIN added in v0.10.0

func (s *Session) SetUIN(uin uint32)

SetUIN sets the user's ICQ number.

func (*Session) SetUserInfoFlag added in v0.9.0

func (s *Session) SetUserInfoFlag(flag uint16) (flags uint16)

SetUserInfoFlag sets a flag to and returns UserInfoBitmask

func (*Session) SetUserStatusBitmask added in v0.10.0

func (s *Session) SetUserStatusBitmask(bitmask uint32)

SetUserStatusBitmask sets the user status bitmask from the client.

func (*Session) SignonComplete added in v0.3.0

func (s *Session) SignonComplete() bool

SignonComplete indicates whether the client has completed the sign-on sequence.

func (*Session) SignonTime added in v0.11.0

func (s *Session) SignonTime() time.Time

SignonTime reports when the user signed on

func (*Session) SubscribeRateLimits added in v0.17.0

func (s *Session) SubscribeRateLimits(classes []wire.RateLimitClassID)

SubscribeRateLimits subscribes the Session to updates for the specified rate limit classes. Future calls to ObserveRateChanges will report changes for these classes.

func (*Session) TLVUserInfo

func (s *Session) TLVUserInfo() wire.TLVUserInfo

TLVUserInfo returns a TLV list containing session information required by multiple SNAC message types that convey user information.

func (*Session) TypingEventsEnabled added in v0.17.0

func (s *Session) TypingEventsEnabled() bool

TypingEventsEnabled indicates whether the client wants to send and receive typing events.

func (*Session) UIN added in v0.10.0

func (s *Session) UIN() uint32

UIN returns the user's ICQ number.

func (*Session) UnsetIdle

func (s *Session) UnsetIdle()

UnsetIdle removes the user's idle state.

func (*Session) UserInfoBitmask added in v0.10.0

func (s *Session) UserInfoBitmask() (flags uint16)

UserInfoBitmask returns UserInfoBitmask

func (*Session) Warning

func (s *Session) Warning() uint16

type User

type User struct {
	// IdentScreenName is the AIM screen name.
	IdentScreenName IdentScreenName
	// DisplayScreenName is the formatted screen name.
	DisplayScreenName DisplayScreenName
	// AuthKey is the salt for the MD5 password hash.
	AuthKey string
	// StrongMD5Pass is the MD5 password hash format used by AIM v4.8-v5.9.
	StrongMD5Pass []byte
	// WeakMD5Pass is the MD5 password hash format used by AIM v3.5-v4.7. This
	// hash is used to authenticate roasted passwords for AIM v1.0-v3.0.
	WeakMD5Pass []byte
	// IsICQ indicates whether the user is an ICQ account (true) or an AIM
	// account (false).
	IsICQ bool
	// ConfirmStatus indicates whether the user has confirmed their AIM account.
	ConfirmStatus bool
	// RegStatus is the AIM registration status.
	//  1: no disclosure
	//  2: limit disclosure
	//  3: full disclosure
	RegStatus int
	// SuspendedStatus is the account suspended status
	SuspendedStatus uint16
	// EmailAddress is the email address set by the AIM client.
	EmailAddress string
	// ICQAffiliations holds information about the user's affiliations,
	// including past and current affiliations.
	ICQAffiliations ICQAffiliations
	// ICQInterests holds information about the user's interests, categorized
	// by code and associated keywords.
	ICQInterests ICQInterests
	// ICQMoreInfo contains additional information about the user.
	ICQMoreInfo ICQMoreInfo
	// ICQPermissions specifies the user's privacy settings.
	ICQPermissions ICQPermissions
	// ICQBasicInfo contains the user's basic profile information, including
	// contact details and personal identifiers.
	ICQBasicInfo ICQBasicInfo
	// ICQNotes allows the user to store personal notes or additional
	// information within their profile.
	ICQNotes ICQUserNotes
	// ICQWorkInfo contains the user's professional information, including
	// their workplace address and job-related details.
	ICQWorkInfo      ICQWorkInfo
	AIMDirectoryInfo AIMNameAndAddr
	// TOCConfig is the user's saved server-side info (buddy list, etc) for
	// on the TOC service.
	TOCConfig string
	// IsBot indicates whether the user is a bot.
	IsBot bool
}

User represents a user account.

func NewStubUser

func NewStubUser(screenName DisplayScreenName) (User, error)

NewStubUser creates a new user with canned credentials. The default password is "welcome1". This is typically used for development purposes.

func (*User) Age added in v0.10.0

func (u *User) Age(timeNow func() time.Time) uint16

Age returns the user's age relative to their birthday and timeNow.

func (*User) HashPassword

func (u *User) HashPassword(passwd string) error

HashPassword computes MD5 hashes of the user's password. It computes both weak and strong variants and stores them in the struct.

func (*User) ValidateHash added in v0.4.0

func (u *User) ValidateHash(md5Hash []byte) bool

ValidateHash validates MD5-hashed passwords for BUCP auth. It handles hashes used in early AIM 4.x versions ("weak" hashes) and later AIM 4.x-5.x versions ("strong" hashes).

func (*User) ValidatePlaintextPass added in v0.18.0

func (u *User) ValidatePlaintextPass(plaintextPass []byte) bool

ValidatePlaintextPass validates plaintext passwords used in Kerberos auth.

func (*User) ValidateRoastedJavaPass added in v0.16.1

func (u *User) ValidateRoastedJavaPass(roastedPass []byte) bool

ValidateRoastedJavaPass validates roasted passwords for the Java AIM client FLAP auth.

func (*User) ValidateRoastedKerberosPass added in v0.19.0

func (u *User) ValidateRoastedKerberosPass(roastedPass []byte) bool

ValidateRoastedKerberosPass validates roasted passwords used in Kerberos auth.

func (*User) ValidateRoastedPass added in v0.4.0

func (u *User) ValidateRoastedPass(roastedPass []byte) bool

ValidateRoastedPass validates roasted passwords for FLAP auth.

func (*User) ValidateRoastedTOCPass added in v0.15.0

func (u *User) ValidateRoastedTOCPass(roastedPass []byte) bool

ValidateRoastedTOCPass validates roasted passwords for TOC auth.

Jump to

Keyboard shortcuts

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