Documentation
¶
Index ¶
- type Accesspoint
- func (ap *Accesspoint) Close()
- func (ap *Accesspoint) Connect(ctx context.Context, creds *pb.LoginCredentials) error
- func (ap *Accesspoint) ConnectBlob(ctx context.Context, username string, encryptedBlob64 []byte) error
- func (ap *Accesspoint) ConnectSpotifyToken(ctx context.Context, username, token string) error
- func (ap *Accesspoint) ConnectStored(ctx context.Context, username string, data []byte) error
- func (ap *Accesspoint) Receive(types ...PacketType) <-chan Packet
- func (ap *Accesspoint) Send(ctx context.Context, pktType PacketType, payload []byte) error
- func (ap *Accesspoint) StoredCredentials() []byte
- func (ap *Accesspoint) Username() string
- func (ap *Accesspoint) Welcome() *pb.APWelcome
- type AccesspointLoginError
- type Packet
- type PacketType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Accesspoint ¶
type Accesspoint struct {
// contains filtered or unexported fields
}
Accesspoint manages the TCP connection to a Spotify access point, including key exchange, Shannon-cipher encrypted communication, authentication, automatic reconnection, and packet dispatching to registered receivers.
func NewAccesspoint ¶
func NewAccesspoint(log spotcontrol.Logger, addr spotcontrol.GetAddressFunc, deviceId string) *Accesspoint
NewAccesspoint creates a new Accesspoint that will dial using the given address function and identify itself with the given device ID.
func (*Accesspoint) Close ¶
func (ap *Accesspoint) Close()
Close terminates the AP connection and stops all background goroutines.
func (*Accesspoint) Connect ¶
func (ap *Accesspoint) Connect(ctx context.Context, creds *pb.LoginCredentials) error
Connect performs the full connection flow: TCP dial, key exchange, challenge solving, and authentication. It retries with back-off on transient failures.
func (*Accesspoint) ConnectBlob ¶
func (ap *Accesspoint) ConnectBlob(ctx context.Context, username string, encryptedBlob64 []byte) error
ConnectBlob authenticates with an encrypted discovery blob (base64-encoded).
func (*Accesspoint) ConnectSpotifyToken ¶
func (ap *Accesspoint) ConnectSpotifyToken(ctx context.Context, username, token string) error
ConnectSpotifyToken authenticates with a Spotify OAuth access token.
func (*Accesspoint) ConnectStored ¶
ConnectStored authenticates with a stored credential (reusable auth data from a previous APWelcome).
func (*Accesspoint) Receive ¶
func (ap *Accesspoint) Receive(types ...PacketType) <-chan Packet
Receive registers one or more packet types for reception and returns a channel that will receive matching packets. The receive loop is started automatically on the first call.
func (*Accesspoint) Send ¶
func (ap *Accesspoint) Send(ctx context.Context, pktType PacketType, payload []byte) error
Send sends an encrypted packet to the access point.
func (*Accesspoint) StoredCredentials ¶
func (ap *Accesspoint) StoredCredentials() []byte
StoredCredentials returns the reusable auth credentials from the most recent APWelcome. These can be persisted and used to re-authenticate later without the original password. It panics if the access point has not been authenticated yet.
func (*Accesspoint) Username ¶
func (ap *Accesspoint) Username() string
Username returns the canonical username from the most recent APWelcome. It panics if the access point has not been authenticated yet.
func (*Accesspoint) Welcome ¶
func (ap *Accesspoint) Welcome() *pb.APWelcome
Welcome returns the full APWelcome protobuf from the most recent authentication. Returns nil if not yet authenticated.
type AccesspointLoginError ¶
type AccesspointLoginError struct {
Message *pb.APLoginFailed
}
AccesspointLoginError is returned when the AP rejects the login credentials.
func (*AccesspointLoginError) Error ¶
func (e *AccesspointLoginError) Error() string
type Packet ¶
type Packet struct {
Type PacketType
Payload []byte
}
Packet represents a single AP protocol packet consisting of a type byte and a variable-length payload.
type PacketType ¶
type PacketType byte
const ( PacketTypeSecretBlock PacketType = 0x02 PacketTypePing PacketType = 0x04 PacketTypeStreamChunk PacketType = 0x08 PacketTypeStreamChunkRes PacketType = 0x09 PacketTypeChannelError PacketType = 0x0a PacketTypeChannelAbort PacketType = 0x0b PacketTypeRequestKey PacketType = 0x0c PacketTypeAesKey PacketType = 0x0d PacketTypeAesKeyError PacketType = 0x0e PacketTypeImage PacketType = 0x19 PacketTypeCountryCode PacketType = 0x1b PacketTypePong PacketType = 0x49 PacketTypePongAck PacketType = 0x4a PacketTypePause PacketType = 0x4b PacketTypeProductInfo PacketType = 0x50 PacketTypeLegacyWelcome PacketType = 0x69 PacketTypeLicenseVersion PacketType = 0x76 PacketTypeLogin PacketType = 0xab PacketTypeAPWelcome PacketType = 0xac PacketTypeAuthFailure PacketType = 0xad PacketTypeMercuryReq PacketType = 0xb2 PacketTypeMercurySub PacketType = 0xb3 PacketTypeMercuryUnsub PacketType = 0xb4 PacketTypeMercuryEvent PacketType = 0xb5 PacketTypeTrackEndedTime PacketType = 0x82 PacketTypePreferredLocale PacketType = 0x74 PacketTypeUnknown1f PacketType = 0x1f PacketTypeUnknown4f PacketType = 0x4f PacketTypeUnknown0f PacketType = 0x0f PacketTypeUnknown10 PacketType = 0x10 )