setup

package
v0.71.2 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package setup contains speaker migration and configuration helpers.

Index

Constants

View Source
const CALabel = "# AfterTouch"

CALabel is the label used to identify the local CA certificate in the trust store.

View Source
const SoundTouchSdkPrivateCfgPath = "/opt/Bose/etc/SoundTouchSdkPrivateCfg.xml"

SoundTouchSdkPrivateCfgPath is the path to the speaker's private configuration file on device.

View Source
const TestDomain = "custom-test-api.bose.fake"

TestDomain is the fake domain used for preliminary redirection tests.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeviceInfoXML

type DeviceInfoXML struct {
	XMLName          xml.Name `xml:"info" json:"-"`
	DeviceID         string   `xml:"deviceID,attr" json:"deviceID"`
	Name             string   `xml:"name" json:"name"`
	Type             string   `xml:"type" json:"type"`
	ModuleType       string   `xml:"moduleType" json:"moduleType"`
	MargeAccountUUID string   `xml:"margeAccountUUID" json:"margeAccountUUID"`
	MargeURL         string   `xml:"margeURL" json:"margeURL"`
	CountryCode      string   `xml:"countryCode" json:"countryCode"`
	RegionCode       string   `xml:"regionCode" json:"regionCode"`
	Variant          string   `xml:"variant" json:"variant"`
	VariantMode      string   `xml:"variantMode" json:"variantMode"`
	Components       []struct {
		Category        string `xml:"componentCategory"`
		SoftwareVersion string `xml:"softwareVersion"`
		SerialNumber    string `xml:"serialNumber"`
	} `xml:"components>component" json:"-"`
	NetworkInfo []struct {
		Type       string `xml:"type,attr"`
		MacAddress string `xml:"macAddress"`
		IPAddress  string `xml:"ipAddress"`
	} `xml:"networkInfo" json:"networkInfo"`
	SoftwareVer  string `xml:"-" json:"softwareVersion"`
	SerialNumber string `xml:"-" json:"serialNumber"`
}

DeviceInfoXML represents the XML structure from :8090/info

func (*DeviceInfoXML) GetPrimaryMacAddress added in v0.40.0

func (d *DeviceInfoXML) GetPrimaryMacAddress() string

GetPrimaryMacAddress returns the primary MAC address from the SCM network interface.

type Manager

type Manager struct {
	ServerURL string
	DataStore *datastore.DataStore
	Crypto    *certmanager.CertificateManager
	NewSSH    func(host string) SSHClient

	// GetDNSRunning is an optional callback to check the actual state of the DNS server.
	GetDNSRunning func() (bool, string)

	// HTTPGet is an optional override for http.Get (primarily for testing).
	HTTPGet func(url string) (*http.Response, error)

	// Spotify management credentials for the boot primer
	MgmtUsername string
	MgmtPassword string
}

Manager handles the migration of speakers to the service.

func NewManager

func NewManager(serverURL string, ds *datastore.DataStore, cm *certmanager.CertificateManager) *Manager

NewManager creates a new Manager with the given base server URL.

func (*Manager) BackupConfig

func (m *Manager) BackupConfig(deviceIP string) (string, error)

BackupConfig creates a backup of the current configuration on the speaker.

func (*Manager) BackupConfigOffDevice added in v0.17.0

func (m *Manager) BackupConfigOffDevice(deviceIP string) error

BackupConfigOffDevice creates a local backup of the speaker's configuration files in the DataStore.

func (*Manager) EnsureRemoteServices

func (m *Manager) EnsureRemoteServices(deviceIP string) (string, error)

EnsureRemoteServices ensures that remote services are enabled on the device. It tries to create an empty file in one of the known valid locations.

func (*Manager) GetLiveDeviceInfo

func (m *Manager) GetLiveDeviceInfo(deviceIP string) (*DeviceInfoXML, error)

GetLiveDeviceInfo fetches live information from the speaker's :8090/info endpoint.

func (*Manager) GetMigrationSummary

func (m *Manager) GetMigrationSummary(deviceIP, targetURL, proxyURL string, options map[string]string) (*MigrationSummary, error)

GetMigrationSummary returns a summary of the current and planned state of the speaker.

func (*Manager) GetResolvedIP added in v0.29.0

func (m *Manager) GetResolvedIP(host string) string

GetResolvedIP returns the resolved IP for a hostname, attempting to resolve it from any connected device first.

func (*Manager) MigrateSpeaker

func (m *Manager) MigrateSpeaker(deviceIP, targetURL, proxyURL string, options map[string]string, method MigrationMethod) (string, error)

MigrateSpeaker configures the speaker at the given IP to use this service.

func (*Manager) Reboot added in v0.16.0

func (m *Manager) Reboot(deviceIP string) (string, error)

Reboot reboots the speaker at the given IP.

func (*Manager) RemoveRemoteServices added in v0.11.0

func (m *Manager) RemoveRemoteServices(deviceIP string) (string, error)

RemoveRemoteServices removes remote services from the device by deleting the known remote_services files.

func (*Manager) RevertMigration added in v0.16.0

func (m *Manager) RevertMigration(deviceIP string) (string, error)

RevertMigration reverts the speaker to its original Bose cloud configuration.

func (*Manager) SyncDeviceData added in v0.13.0

func (m *Manager) SyncDeviceData(deviceIP string) error

SyncDeviceData fetches presets, recents and sources from the device and saves them to the datastore.

func (*Manager) TestConnection added in v0.12.0

func (m *Manager) TestConnection(deviceIP, targetURL string, useExplicitCA bool) (string, error)

TestConnection performs a connection check from the device to the server.

func (*Manager) TestDNSRedirection added in v0.29.0

func (m *Manager) TestDNSRedirection(deviceIP, targetURL string) (string, error)

TestDNSRedirection performs a check from the device to see if DNS queries are intercepted by the AfterTouch service.

func (*Manager) TestHostsRedirection added in v0.12.0

func (m *Manager) TestHostsRedirection(deviceIP, targetURL string) (string, error)

TestHostsRedirection performs a preliminary check to see if /etc/hosts redirection works.

func (*Manager) TrustCACert added in v0.12.2

func (m *Manager) TrustCACert(deviceIP string) (string, error)

TrustCACert injects the local CA certificate into the device's shared trust store.

type MigrationMethod added in v0.12.0

type MigrationMethod string

MigrationMethod represents the method used to migrate a speaker.

const (
	// MigrationMethodXML redirects services by modifying SoundTouchSdkPrivateCfg.xml.
	MigrationMethodXML MigrationMethod = "xml"
	// MigrationMethodHosts redirects services by modifying /etc/hosts and updating the CA trust store.
	MigrationMethodHosts MigrationMethod = "hosts"
	// MigrationMethodResolvConf redirects services by injecting a priority DNS hook into the DHCP logic and updating the CA trust store.
	MigrationMethodResolvConf MigrationMethod = "resolv"
)

type MigrationSummary

type MigrationSummary struct {
	SSHSuccess               bool        `json:"ssh_success"`
	CurrentConfig            string      `json:"current_config"`
	PlannedConfig            string      `json:"planned_config"`
	OriginalConfig           string      `json:"original_config,omitempty"`
	ParsedCurrentConfig      *PrivateCfg `json:"parsed_current_config,omitempty"`
	PlannedHosts             string      `json:"planned_hosts,omitempty"`
	RemoteServicesEnabled    bool        `json:"remote_services_enabled"`
	RemoteServicesPersistent bool        `json:"remote_services_persistent"`
	RemoteServicesFound      []string    `json:"remote_services_found"`
	RemoteServicesCheckErr   string      `json:"remote_services_check_err,omitempty"`
	DeviceName               string      `json:"device_name,omitempty"`
	DeviceModel              string      `json:"device_model,omitempty"`
	DeviceSerial             string      `json:"device_serial,omitempty"`
	DeviceID                 string      `json:"device_id,omitempty"`
	AccountID                string      `json:"account_id,omitempty"`
	FirmwareVersion          string      `json:"firmware_version,omitempty"`
	CACertTrusted            bool        `json:"ca_cert_trusted"`
	ServerHTTPSURL           string      `json:"server_https_url,omitempty"`
	CurrentResolvConf        string      `json:"current_resolv_conf,omitempty"`
	PlannedResolv            string      `json:"planned_resolv,omitempty"`
	IsMigrated               bool        `json:"is_migrated"`
	ResolveIPError           string      `json:"resolve_ip_error,omitempty"`
	MirrorEnabled            bool        `json:"mirror_enabled"`
	MirrorEndpoints          []string    `json:"mirror_endpoints,omitempty"`
	SkipMirrorEndpoints      []string    `json:"skip_mirror_endpoints,omitempty"`
	PreferredSource          string      `json:"preferred_source,omitempty"`
}

MigrationSummary provides details about the state of a speaker before migration.

type PrivateCfg

type PrivateCfg struct {
	XMLName                    xml.Name `xml:"SoundTouchSdkPrivateCfg" json:"-"`
	MargeServerUrl             string   `xml:"margeServerUrl" json:"margeServerUrl"`
	StatsServerUrl             string   `xml:"statsServerUrl" json:"statsServerUrl"`
	SwUpdateUrl                string   `xml:"swUpdateUrl" json:"swUpdateUrl"`
	UsePandoraProductionServer bool     `xml:"usePandoraProductionServer" json:"usePandoraProductionServer"`
	IsZeroconfEnabled          bool     `xml:"isZeroconfEnabled" json:"isZeroconfEnabled"`
	SaveMargeCustomerReport    bool     `xml:"saveMargeCustomerReport" json:"saveMargeCustomerReport"`
	BmxRegistryUrl             string   `xml:"bmxRegistryUrl" json:"bmxRegistryUrl"`
}

PrivateCfg represents the SoundTouchSdkPrivateCfg XML structure.

type SSHClient added in v0.12.0

type SSHClient interface {
	Run(command string) (string, error)
	UploadContent(content []byte, remotePath string) error
}

SSHClient defines the interface for SSH operations.

Jump to

Keyboard shortcuts

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