first commit

This commit is contained in:
2026-03-28 15:43:18 +08:00
commit e5611df24e
54 changed files with 11065 additions and 0 deletions

View File

@@ -0,0 +1,125 @@
package model
import "time"
const (
RoomStatusWaiting = "waiting"
RoomStatusJoined = "joined"
RoomStatusCanceled = "canceled"
RoomStatusExpired = "expired"
ChannelP2P = "p2p"
ChannelTURN = "turn"
ChannelMinIO = "minio"
TransferPending = "pending"
TransferConnecting = "connecting"
TransferP2PTransferring = "p2p_transferring"
TransferTURNRelaying = "turn_relaying"
TransferFallbackUploading = "fallback_uploading"
TransferCompleted = "completed"
TransferFailed = "failed"
TransferCancelled = "cancelled"
)
type RuntimeConfig struct {
MaxMinIOFallbackSizeBytes int64 `json:"max_minio_fallback_size_bytes"`
MinIOCapacityBytes int64 `json:"minio_capacity_bytes"`
MinIORetentionHours int `json:"minio_retention_hours"`
MinIOUsageAlertPercent int `json:"minio_usage_alert_percent"`
P2PConnectTimeoutSec int `json:"p2p_connect_timeout_sec"`
TURNConnectTimeoutSec int `json:"turn_connect_timeout_sec"`
MinIOFallbackEnabled bool `json:"minio_fallback_enabled"`
TURNURLs []string `json:"turn_urls"`
TURNUsername string `json:"turn_username"`
TURNPassword string `json:"turn_password"`
}
type Device struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
UserAgent string `json:"user_agent,omitempty"`
NetworkGroupKey string `json:"network_group_key,omitempty"`
PublicIPHash string `json:"public_ip_hash,omitempty"`
IsOnline bool `json:"is_online"`
LastSeenAt time.Time `json:"last_seen_at"`
CreatedAt time.Time `json:"created_at"`
}
type Room struct {
Code string `json:"code"`
CreatorDeviceID string `json:"creator_device_id"`
JoinerDeviceID string `json:"joiner_device_id,omitempty"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at"`
}
type Transfer struct {
ID string `json:"id"`
SessionID string `json:"session_id,omitempty"`
Kind string `json:"kind"`
Name string `json:"name"`
Content string `json:"content,omitempty"`
SizeBytes int64 `json:"size_bytes"`
SenderDeviceID string `json:"sender_device_id"`
ReceiverDeviceID string `json:"receiver_device_id"`
TransferStrategy string `json:"transfer_strategy"`
CurrentChannel string `json:"current_channel"`
FallbackAllowed bool `json:"fallback_allowed"`
FinalStatus string `json:"final_status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
FallbackReason string `json:"fallback_reason,omitempty"`
ObjectKey string `json:"object_key,omitempty"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
}
type FallbackObject struct {
TransferID string `json:"transfer_id"`
ObjectKey string `json:"object_key"`
SizeBytes int64 `json:"size_bytes"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at"`
CleanedAt *time.Time `json:"cleaned_at,omitempty"`
CleanupState string `json:"cleanup_state"`
}
type PendingFallbackDownload struct {
TransferID string `json:"transfer_id"`
Name string `json:"name"`
SizeBytes int64 `json:"size_bytes"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at"`
DownloadPath string `json:"download_path"`
SenderDeviceID string `json:"sender_device_id"`
}
type MinIOStorageOverview struct {
Enabled bool `json:"enabled"`
UsedBytes int64 `json:"used_bytes"`
CapacityBytes int64 `json:"capacity_bytes"`
RemainingBytes int64 `json:"remaining_bytes"`
UsagePercent int `json:"usage_percent"`
ObjectCount int `json:"object_count"`
}
type AdminSession struct {
Token string `json:"token"`
CreatedAt time.Time `json:"created_at"`
}
type DeviceSession struct {
DeviceID string `json:"device_id"`
Token string `json:"token"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at"`
}
type SignalEnvelope struct {
Type string `json:"type"`
DeviceID string `json:"device_id,omitempty"`
TargetDeviceID string `json:"target_device_id,omitempty"`
Payload interface{} `json:"payload,omitempty"`
}