Documentation
¶
Overview ¶
Package mobile provides gomobile-compatible bindings for KeibiDrop. All exported types and functions follow gomobile restrictions: no maps, no slices (except []byte), no channels, no complex types. File lists use index-based access (GetRemoteFileCount + GetRemoteFileName).
Index ¶
- Constants
- func FileTypeFromName(name string) string
- func FormatFileSize(bytes int64) string
- func GenerateMasterKeyHex() (string, error)
- type API
- func (api *API) AddContact(name string, fingerprint string) error
- func (api *API) CancelDownload(remoteName string) error
- func (api *API) CancelOp() error
- func (api *API) Connect() error
- func (api *API) ConnectAsync() error
- func (api *API) ConnectToContactAsync(fingerprint string) error
- func (api *API) CreateRoom() error
- func (api *API) CreateRoomAsync() error
- func (api *API) DecideLocalRole(myName, peerName, peerAddr string) bool
- func (api *API) Disconnect() error
- func (api *API) EnablePersistentIdentity(configDir string, masterKeyHex string) error
- func (api *API) ExportFile(remoteName string, destPath string) error
- func (api *API) Fingerprint() (string, error)
- func (api *API) GetConnectionMode() string
- func (api *API) GetConnectionStatus() int
- func (api *API) GetContactCount() int
- func (api *API) GetContactFingerprint(i int) string
- func (api *API) GetContactName(i int) string
- func (api *API) GetDiscoveredPeerAddr(i int) string
- func (api *API) GetDiscoveredPeerCount() int
- func (api *API) GetDiscoveredPeerName(i int) string
- func (api *API) GetDiscoveryName() string
- func (api *API) GetDownloadProgress(remoteName string) int
- func (api *API) GetLastError() string
- func (api *API) GetLocalAddress() string
- func (api *API) GetLocalFileCount() int
- func (api *API) GetLocalFileName(i int) string
- func (api *API) GetOpStatus() *OpStatus
- func (api *API) GetRemoteFileCount() int
- func (api *API) GetRemoteFileName(i int) string
- func (api *API) GetRemoteFileSize(i int) int64
- func (api *API) GetSavePath() string
- func (api *API) GetVersion() string
- func (api *API) HasResumableDownload(remoteName string) bool
- func (api *API) ImportFile(localPath string) error
- func (api *API) ImportFileAs(localPath string, remoteName string) error
- func (api *API) Initialize(logFilePath string, relayURL string, inboundPort int, outboundPort int, ...) error
- func (api *API) IsContactOnline(i int) bool
- func (api *API) IsIncognito() bool
- func (api *API) IsPeerAlreadyContact() bool
- func (api *API) IsPeerPersistent() bool
- func (api *API) JoinRoom() error
- func (api *API) JoinRoomAsync() error
- func (api *API) PeerFingerprint() string
- func (api *API) PollEvent() string
- func (api *API) RefreshContacts()
- func (api *API) RefreshFileList()
- func (api *API) RegisterPeer(fingerprint string) error
- func (api *API) RelayEndpoint() string
- func (api *API) RemoveContact(fingerprint string) error
- func (api *API) SaveAllFiles() int
- func (api *API) SaveCurrentPeerAsContact(name string) error
- func (api *API) SaveFile(remoteName string) (string, error)
- func (api *API) SetBridgeAddr(addr string)
- func (api *API) SetPeerDirectAddress(addr string) error
- func (api *API) SetStrictMode(enabled bool)
- func (api *API) SetupEventCallbacks()
- func (api *API) Start() error
- func (api *API) StartDiscovery()
- func (api *API) Stop() error
- func (api *API) StopDiscovery()
- func (api *API) ToggleIncognito(incognito bool) (string, error)
- func (api *API) UnshareFile(name string) error
- type OpStatus
Constants ¶
const ( OpStatusIdle = "idle" OpStatusRunning = "running" OpStatusSucceeded = "succeeded" OpStatusFailed = "failed" OpStatusTimeout = "timeout" )
Operation status constants (polled from Swift/Kotlin).
Variables ¶
This section is empty.
Functions ¶
func FileTypeFromName ¶
FileTypeFromName returns a category string for a file based on its extension. Returns one of: "pdf", "image", "video", "audio", "code", "archive", "text", "other".
func FormatFileSize ¶
FormatFileSize returns a human-readable file size string.
func GenerateMasterKeyHex ¶ added in v0.3.0
GenerateMasterKeyHex generates a random 32-byte master key and returns it as a hex string. The native app should persist this in iOS Keychain or Android Keystore, then pass it back on every launch via EnablePersistentIdentity.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is the main entry point for mobile apps. Create one instance, call Initialize, then Start in a background thread.
func (*API) AddContact ¶ added in v0.3.0
AddContact adds a new contact by name and fingerprint.
func (*API) CancelDownload ¶
CancelDownload stops an active download. Partial data is preserved. Call SaveFile or ExportFile again to resume.
func (*API) Connect ¶
Connect determines the creator/joiner role automatically via fingerprint comparison, then creates or joins a room. Blocking.
func (*API) ConnectAsync ¶
ConnectAsync starts Connect in the background. Poll GetOpStatus() to check progress.
func (*API) ConnectToContactAsync ¶ added in v0.3.0
ConnectToContactAsync starts connecting to a saved contact in the background. Poll GetOpStatus() to check progress.
func (*API) CreateRoom ¶
CreateRoom creates a room and waits for the peer to join. Blocking.
func (*API) CreateRoomAsync ¶
CreateRoomAsync starts room creation in the background. Poll GetOpStatus() to check progress.
func (*API) DecideLocalRole ¶ added in v0.3.5
DecideLocalRole reports whether this device should create (true) or join (false) a local-mode connection to peerName at peerAddr. Same decider as the desktop, so the two sides break colliding discovery names the same way.
func (*API) Disconnect ¶
Disconnect ends the current session but keeps the engine alive. You can CreateRoom/JoinRoom again after this.
func (*API) EnablePersistentIdentity ¶ added in v0.3.0
EnablePersistentIdentity loads or creates a stable device identity. masterKeyHex is a 64-char hex string (32 bytes) from the platform keychain. Call once after Initialize, before Start.
func (*API) ExportFile ¶
ExportFile downloads a file from the peer and saves it to destPath. destPath is where to write on the device (app sandbox, then share via OS).
func (*API) Fingerprint ¶
Fingerprint returns your local fingerprint code. Share this with your peer via Signal, Telegram, email, etc.
func (*API) GetConnectionMode ¶
GetConnectionMode returns the current connection mode: "lan", "direct", "bridge", or "" if not connected.
func (*API) GetConnectionStatus ¶
GetConnectionStatus returns 0=disconnected, 2=connected, 3=reconnecting.
func (*API) GetContactCount ¶ added in v0.3.0
GetContactCount returns the number of contacts in the last snapshot.
func (*API) GetContactFingerprint ¶ added in v0.3.0
GetContactFingerprint returns the fingerprint of the contact at index i.
func (*API) GetContactName ¶ added in v0.3.0
GetContactName returns the name of the contact at index i.
func (*API) GetDiscoveredPeerAddr ¶
GetDiscoveredPeerAddr returns the address of the discovered peer at index i.
func (*API) GetDiscoveredPeerCount ¶
GetDiscoveredPeerCount returns the number of discovered peers on the LAN.
func (*API) GetDiscoveredPeerName ¶
GetDiscoveredPeerName returns the name of the discovered peer at index i.
func (*API) GetDiscoveryName ¶
GetDiscoveryName returns this device's random display name for LAN discovery.
func (*API) GetDownloadProgress ¶
GetDownloadProgress returns download progress as 0-100, or -1 if not active.
func (*API) GetLastError ¶
GetLastError returns the last error message, or empty string.
func (*API) GetLocalAddress ¶
GetLocalAddress returns the link-local IPv6 address for local mode connections. Format: "fe80::1234:5678%en0:26431"
func (*API) GetLocalFileCount ¶
GetLocalFileCount returns the number of local files in the last snapshot.
func (*API) GetLocalFileName ¶
GetLocalFileName returns the name of the local file at index i in the last snapshot. Returns empty string if i is out of bounds.
func (*API) GetOpStatus ¶
GetOpStatus returns the status of the current async operation.
func (*API) GetRemoteFileCount ¶
GetRemoteFileCount returns the number of remote files in the last snapshot.
func (*API) GetRemoteFileName ¶
GetRemoteFileName returns the name of the remote file at index i in the last snapshot. Returns empty string if i is out of bounds.
func (*API) GetRemoteFileSize ¶
GetRemoteFileSize returns the size in bytes of the remote file at index i in the last snapshot. Returns 0 if i is out of bounds.
func (*API) GetSavePath ¶
GetSavePath returns the configured save folder path.
func (*API) HasResumableDownload ¶
HasResumableDownload returns true if a .kdbitmap file exists for the given file, meaning a previous download was interrupted and can be resumed.
func (*API) ImportFile ¶
ImportFile adds a local file to share with the peer. localPath is a path to a file on the device (from file picker, Photos, etc).
func (*API) ImportFileAs ¶
ImportFileAs adds a local file with a custom remote name (preserving folder paths).
func (*API) Initialize ¶
func (api *API) Initialize(logFilePath string, relayURL string, inboundPort int, outboundPort int, savePath string) error
Initialize sets up the KeibiDrop engine. Call once before Start. savePath is where received files are stored (app sandbox directory). No FUSE on mobile. prefetchOnOpen and pushOnWrite are ignored.
func (*API) IsContactOnline ¶ added in v0.3.0
IsContactOnline returns whether the contact at index i is online.
func (*API) IsIncognito ¶ added in v0.3.0
IsIncognito returns whether the engine is in incognito mode.
func (*API) IsPeerAlreadyContact ¶ added in v0.3.0
IsPeerAlreadyContact returns whether the connected peer is already in the address book.
func (*API) IsPeerPersistent ¶ added in v0.3.0
IsPeerPersistent returns whether the connected peer has a stable identity.
func (*API) JoinRoomAsync ¶
JoinRoomAsync starts joining a room in the background. Poll GetOpStatus() to check progress.
func (*API) PeerFingerprint ¶
PeerFingerprint returns the registered peer's fingerprint, or empty string.
func (*API) PollEvent ¶
PollEvent returns the next event string, or empty string if none. Non-blocking. Event format: "type:payload" (e.g. "health_changed:healthy:disconnected").
func (*API) RefreshContacts ¶ added in v0.3.0
func (api *API) RefreshContacts()
RefreshContacts takes a snapshot of the address book for index-based access.
func (*API) RefreshFileList ¶
func (api *API) RefreshFileList()
RefreshFileList takes a consistent snapshot of remote and local files. Call this once per poll cycle, then use the count/name/size getters.
func (*API) RegisterPeer ¶
RegisterPeer registers the peer's fingerprint code.
func (*API) RelayEndpoint ¶
RelayEndpoint returns the relay URL string.
func (*API) RemoveContact ¶ added in v0.3.0
RemoveContact removes a contact by fingerprint.
func (*API) SaveAllFiles ¶
SaveAllFiles downloads all remote files to the save folder sequentially. Returns the number of files successfully saved.
func (*API) SaveCurrentPeerAsContact ¶ added in v0.3.0
SaveCurrentPeerAsContact saves the connected peer as a named contact.
func (*API) SaveFile ¶
SaveFile downloads a file from the peer into the save folder. If the file already exists at the correct size, it skips the download. Returns the local path where the file was saved.
func (*API) SetBridgeAddr ¶
SetBridgeAddr overrides the default bridge relay address.
func (*API) SetPeerDirectAddress ¶
SetPeerDirectAddress sets the peer's address for local mode (no relay). Automatically enables local mode (skips relay, uses TOFU handshake).
func (*API) SetStrictMode ¶
SetStrictMode enables/disables strict mode (no data relay fallback).
func (*API) SetupEventCallbacks ¶
func (api *API) SetupEventCallbacks()
SetupEventCallbacks wires health/reconnect events into the event queue. Call once after Initialize, before Start.
func (*API) Start ¶
Start runs the KeibiDrop event loop. Blocks until Stop is called. Call this from a background thread on mobile.
func (*API) StartDiscovery ¶
func (api *API) StartDiscovery()
StartDiscovery begins broadcasting presence and listening for peers on the LAN. Also enables local mode (skips relay for connections).
func (*API) StopDiscovery ¶
func (api *API) StopDiscovery()
StopDiscovery stops LAN discovery and disables local mode.
func (*API) ToggleIncognito ¶ added in v0.3.0
ToggleIncognito switches between persistent and ephemeral identity. Returns the new fingerprint string.
func (*API) UnshareFile ¶ added in v0.3.0
UnshareFile removes a file from the shared list without deleting from disk.