Session

open class Session

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
suspend fun addUserProvidedPeers(addrs: List<String>)

Adds peers to connect to.

Link copied to clipboard
suspend fun bindMetrics(addr: String?)
Link copied to clipboard
suspend fun bindNetwork(addrs: List<String>)

Binds the network listeners to the specified interfaces.

Link copied to clipboard
suspend fun bindRemoteControl(addr: String?): Short
Link copied to clipboard
suspend fun Session.close()

Closes the session.

Link copied to clipboard
suspend fun copy(srcRepo: String? = null, srcPath: String, dstRepo: String? = null, dstPath: String)

Copy file or directory into, from or between repositories

Link copied to clipboard
suspend fun createRepository(path: String, readSecret: SetLocalSecret? = null, writeSecret: SetLocalSecret? = null, token: ShareToken? = null, syncEnabled: Boolean = false, dhtEnabled: Boolean = false, pexEnabled: Boolean = false): Repository

Creates a new repository.

Link copied to clipboard
suspend fun deleteRepositoryByName(name: String)

Delete a repository with the given name.

Link copied to clipboard
suspend fun deriveSecretKey(password: Password, salt: PasswordSalt): SecretKey
Link copied to clipboard
suspend fun findRepository(name: String): Repository
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Returns our Ouisync protocol version.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
suspend fun getDhtRouters(): List<String>

Returns the current DHT routers (bootstrap nodes). If the routers haven't been changed by the user yet, returns the default routers.

Link copied to clipboard
suspend fun getExternalAddrV4(): String?
Link copied to clipboard
suspend fun getExternalAddrV6(): String?
Link copied to clipboard

Returns the highest protocol version of all known peers.

Link copied to clipboard

Returns the listener addresses of this Ouisync instance.

Link copied to clipboard
Link copied to clipboard
suspend fun getMountRoot(): String?
Link copied to clipboard
suspend fun getNatBehavior(): NatBehavior?
Link copied to clipboard
suspend fun getNetworkStats(): Stats
Link copied to clipboard
suspend fun getPeers(): List<PeerInfo>

Returns info about all known peers (both discovered and explicitly added).

Link copied to clipboard
Link copied to clipboard

Returns the listener addresses of the specified remote Ouisync instance. Works only if the remote control API is enabled on the remote instance. Typically used with cache servers.

Link copied to clipboard

Returns the runtime id of this Ouisync instance.

Link copied to clipboard

Returns the access mode that the given token grants.

Link copied to clipboard

Return the info-hash of the repository corresponding to the given token, formatted as hex string.

Link copied to clipboard

Returns the suggested name for the repository corresponding to the given token.

Link copied to clipboard
Link copied to clipboard
suspend fun getStoreDirs(): List<String>
Link copied to clipboard
Link copied to clipboard
suspend fun initNetwork(defaults: NetworkDefaults)

Initializes the network according to the stored configuration. If a particular network parameter is not yet configured, falls back to the given defaults.

Link copied to clipboard
suspend fun insertStoreDirs(paths: List<String>)
Link copied to clipboard
suspend fun isLocalDhtEnabled(): Boolean

Checks whether local DHT is enabled.

Link copied to clipboard

Is local discovery enabled?

Link copied to clipboard
suspend fun isPexRecvEnabled(): Boolean

Checks whether accepting peers discovered on the peer exchange is enabled.

Link copied to clipboard
suspend fun isPexSendEnabled(): Boolean
Link copied to clipboard

Is port forwarding (UPnP) enabled?

Link copied to clipboard
Link copied to clipboard
suspend fun mirrorExists(token: ShareToken, host: String): Boolean
Link copied to clipboard

Opens a side channel to the underlying IPv4 UDP socket. The side channel is used to send/receive raw UDP datagrams on the same socket that the sync protocol uses. This is useful to share the socket between different protocols for hole punching.

Link copied to clipboard

Opens a side channel to the underlying IPv6 UDP socket. The side channel is used to send/receive raw UDP datagrams on the same socket that the sync protocol uses. This is useful to share the socket between different protocols for hole punching.

Link copied to clipboard
suspend fun openNetworkStream(addr: String, topicId: TopicId): NetworkStream

Opens a raw byte streams to the given peer, bound to the given topic.

Link copied to clipboard
suspend fun openRepository(path: String, localSecret: LocalSecret? = null): Repository

Opens an existing repository.

Link copied to clipboard
suspend fun pinDht()

Pin the DHT to ensure it starts and remains running even when there are no active DHT lookups and no DHT-enabled repositories. This is useful to prevent the DHT restarting between the lookups (which could be slow).

Link copied to clipboard
suspend fun removeStoreDirs(paths: List<String>)
Link copied to clipboard
suspend fun removeUserProvidedPeers(addrs: List<String>)

Removes peers previously added with Self::session_add_user_provided_peers.

Link copied to clipboard
suspend fun setDefaultBlockExpiration(value: Duration?)
Link copied to clipboard
suspend fun setDefaultQuota(value: StorageSize?)
Link copied to clipboard
Link copied to clipboard
suspend fun setDhtRouters(routers: List<String>)

Changes the DHT routers (bootstrap nodes), rebootstraps the DHTs and restart any ongoing lookups. If this is not called, a default set of routers is used. Each router is specified as hostname + port or ip address + port.

Link copied to clipboard
suspend fun setLocalDhtEnabled(enabled: Boolean)

Set whether DHT on the local network or localhost is allowed. By default this is false because DHT is a global discovery mechanism and finding a local peer on it is unexpected (and could indicate malice). However, is some situations it's still useful to enable it (typically for testing).

Link copied to clipboard
suspend fun setLocalDiscoveryEnabled(enabled: Boolean)

Enables/disables local discovery.

Link copied to clipboard
suspend fun setMountRoot(path: String?)
Link copied to clipboard
suspend fun setPexRecvEnabled(enabled: Boolean)
Link copied to clipboard
suspend fun setPexSendEnabled(enabled: Boolean)
Link copied to clipboard
suspend fun setPortForwardingEnabled(enabled: Boolean)

Enables/disables port forwarding (UPnP).

Link copied to clipboard
suspend fun setStoreDirs(paths: List<String>)
Link copied to clipboard
Link copied to clipboard
suspend fun unpinDht()

Unpin the DHT. If the DHT is not pinned and there are no more active DHT lookups and no DHT-enabled repositories, the DHT shuts down.

Link copied to clipboard
suspend fun validateShareToken(token: String): ShareToken

Checks whether the given string is a valid share token.