Documentation
¶
Overview ¶
Package model contains the data structures used throughout the LocalGo application
Index ¶
Constants ¶
const DefaultPort = 53317
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct {
IP string `json:"ip"`
Version string `json:"version"` // LocalSend protocol version
Port int `json:"port"`
Alias string `json:"alias"`
Protocol ProtocolType `json:"protocol"`
Fingerprint string `json:"fingerprint"`
DeviceModel *string `json:"deviceModel"` // nullable
DeviceType DeviceType `json:"deviceType"`
Download bool `json:"download"` // Whether the device has download server running
LastSeen time.Time `json:"-"` // Not serialized to JSON
Available bool `json:"-"` // Not serialized to JSON
}
Device represents a peer device.
func FromMulticastDto ¶
func FromMulticastDto(dto MulticastDto, ip net.IP) *Device
FromMulticastDto creates a Device from a MulticastDto and source IP
func (*Device) ToDebugString ¶
ToDebugString returns a string representation suitable for debugging
func (*Device) UpdateLastSeen ¶
func (d *Device) UpdateLastSeen()
UpdateLastSeen updates the last seen timestamp for a device
type DeviceInfo ¶
type DeviceInfo struct {
Alias string
Version string
DeviceModel *string
DeviceType DeviceType
Fingerprint string
Port int
DownloadDir string
IP string
Download bool
HttpsEnabled bool
}
DeviceInfo contains information about the current device
func (*DeviceInfo) ToInfoDto ¶
func (d *DeviceInfo) ToInfoDto() InfoDto
ToInfoDto converts DeviceInfo to InfoDto
func (*DeviceInfo) ToMulticastDto ¶
func (d *DeviceInfo) ToMulticastDto(announce bool) MulticastDto
ToMulticastDto converts DeviceInfo to MulticastDto
func (*DeviceInfo) ToRegisterDto ¶
func (d *DeviceInfo) ToRegisterDto() RegisterDto
ToRegisterDto converts DeviceInfo to RegisterDto
type DeviceType ¶
type DeviceType string
DeviceType defines the type of the device.
const ( DeviceTypeMobile DeviceType = "mobile" DeviceTypeDesktop DeviceType = "desktop" DeviceTypeWeb DeviceType = "web" DeviceTypeHeadless DeviceType = "headless" DeviceTypeServer DeviceType = "server" DeviceTypeLaptop DeviceType = "laptop" DeviceTypeTablet DeviceType = "tablet" DeviceTypeOther DeviceType = "other" )
type File ¶
type File struct {
ID string
Name string
Path string
Size int64
Type string
SHA256 string
LastModified int64
}
File represents a file to be shared or received
type FileDto ¶
type FileDto struct {
ID string `json:"id"`
FileName string `json:"fileName"`
Size int64 `json:"size"`
FileType string `json:"fileType"`
SHA256 *string `json:"sha256,omitempty"` // Use pointer for nullable
Preview *string `json:"preview,omitempty"` // Use pointer for nullable
Metadata *FileMetadata `json:"metadata,omitempty"` // Use pointer for nullable
Legacy bool `json:"legacy,omitempty"` // Added from Dart code
}
FileDto contains information about a file being uploaded
type FileMetadata ¶
type FileMetadata struct {
Modified *string `json:"modified,omitempty"` // Using string for ISO 8601 format
Accessed *string `json:"accessed,omitempty"` // Using string for ISO 8601 format
}
FileMetadata holds optional file metadata (added in v2.1)
type InfoDto ¶
type InfoDto struct {
Alias string `json:"alias"`
Version string `json:"version"`
DeviceModel *string `json:"deviceModel"` // nullable
DeviceType DeviceType `json:"deviceType"`
Fingerprint string `json:"fingerprint"`
Download bool `json:"download"`
}
InfoDto represents the response for /info and /register endpoints.
type MulticastDto ¶
type MulticastDto struct {
Alias string `json:"alias"`
Version string `json:"version"`
DeviceModel *string `json:"deviceModel"` // nullable
DeviceType DeviceType `json:"deviceType"`
Fingerprint string `json:"fingerprint"`
Port int `json:"port"`
Protocol ProtocolType `json:"protocol"` // http | https
Download bool `json:"download"`
Announce bool `json:"announce"` // True if initial announcement, false if response
}
MulticastDto represents the UDP discovery message.
type PrepareUploadRequestDto ¶
type PrepareUploadRequestDto struct {
Info InfoDto `json:"info"`
Files map[string]FileDto `json:"files"`
SendZipped bool `json:"sendZipped"`
ForceBulk bool `json:"forceBulk"`
TargetPath string `json:"targetPath"`
KeepFolders bool `json:"keepFolders"`
Token string `json:"token,omitempty"`
}
PrepareUploadRequestDto is sent to prepare file uploads
type PrepareUploadResponseDto ¶
type PrepareUploadResponseDto struct {
SessionID string `json:"sessionId"`
Files map[string]string `json:"files"`
Token string `json:"token,omitempty"`
}
PrepareUploadResponseDto is returned after a successful upload preparation
type ProtocolType ¶
type ProtocolType string
ProtocolType defines the protocol type.
const ( ProtocolTypeHTTP ProtocolType = "http" ProtocolTypeHTTPS ProtocolType = "https" )
type ReceiveRequestResponseDto ¶
type ReceiveRequestResponseDto struct {
Info InfoDto `json:"info"` // Added Info field as per protocol spec
SessionID string `json:"sessionId"`
Files map[string]FileDto `json:"files"` // Changed to use FileDto
}
ReceiveRequestResponseDto is returned for download preparations
type RegisterDto ¶
type RegisterDto struct {
Alias string `json:"alias"`
Version string `json:"version"`
DeviceModel *string `json:"deviceModel"` // nullable
DeviceType DeviceType `json:"deviceType"`
Fingerprint string `json:"fingerprint"`
Port int `json:"port"`
Protocol ProtocolType `json:"protocol"` // "http" or "https"
Download bool `json:"download"`
}
RegisterDto represents the request body for /register endpoint (sent by the discoverer).