Class Network
-
- All Implemented Interfaces:
public class Network
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumNetwork.Environment
-
Field Summary
Fields Modifier and Type Field Description public final static StringSIGNAL_TLS_PROXY_SCHEME
-
Constructor Summary
Constructors Constructor Description Network(Network.Environment env, String userAgent)Network(Network.Environment env, String userAgent, Map<String, String> remoteConfig)
-
Method Summary
Modifier and Type Method Description SvrBsvrB(String username, String password)Get the SVR-B (Secure Value Recovery for Backups) service for this network instance. voidsetProxy(String scheme, String host, Integer port, String username, String password)Sets the proxy host to be used for all new connections (until overridden). voidsetProxy(String host, int port)Sets the Signal TLS proxy host to be used for all new connections (until overridden). voidsetInvalidProxy()Refuses to make any new connections until a new proxy configuration is set or clearProxy is called. voidclearProxy()Ensures that future connections will be made directly, not through a proxy. voidsetCensorshipCircumventionEnabled(boolean enabled)Enables or disables censorship circumvention for all new connections (until changed). voidsetRemoteConfig(Map<String, String> remoteConfig)Updates libsignal's remote configuration settings. voidonNetworkChange()Notifies libsignal that the network has changed. CompletableFuture<CdsiLookupResponse>cdsiLookup(String username, String password, CdsiLookupRequest request, Consumer<Array<byte>> tokenConsumer)static voidcheckClassesCanBeLoadedAsyncForTest()Try to load several libsignal classes asynchronously, using the same mechanism as native (Rust) code. CompletableFuture<Void>preconnectChat()Starts the process of connecting to the chat server. CompletableFuture<UnauthenticatedChatConnection>connectUnauthChat(Locale locale, ChatConnectionListener listener)Initiates an unauthenticated connection attempt to the chat service. CompletableFuture<UnauthenticatedChatConnection>connectUnauthChat(ChatConnectionListener listener)Calls connectUnauthChat with no connection-level locale. CompletableFuture<AuthenticatedChatConnection>connectAuthChat(String username, String password, boolean receiveStories, Locale locale, ChatConnectionListener listener)Initiates an authenticated connection attempt to the chat service. CompletableFuture<AuthenticatedChatConnection>connectAuthChat(String username, String password, boolean receiveStories, ChatConnectionListener listener)Calls connectAuthChat with no connection-level locale. -
-
Constructor Detail
-
Network
Network(Network.Environment env, String userAgent)
-
Network
Network(Network.Environment env, String userAgent, Map<String, String> remoteConfig)
-
-
Method Detail
-
svrB
SvrB svrB(String username, String password)
Get the SVR-B (Secure Value Recovery for Backups) service for this network instance.
- Parameters:
username- The username for authenticating with the SVR-B service.password- The password for authenticating with the SVR-B service.- Returns:
An SvrB service instance configured for this network environment.
-
setProxy
void setProxy(String scheme, String host, Integer port, String username, String password)
Sets the proxy host to be used for all new connections (until overridden).
Sets a server to be used to proxy all new outgoing connections. The proxy can be overridden by calling this method again or unset by calling clearProxy. Passing
nullfor theportmeans the default port for the scheme will be used.usernameandpasswordcan benullas well.To specify a Signal transparent TLS proxy, use SIGNAL_TLS_PROXY_SCHEME, or the overload that takes a separate domain and port number.
Existing connections and services will continue with the setting they were created with. (In particular, changing this setting will not affect any existing ChatConnections.)
-
setProxy
void setProxy(String host, int port)
Sets the Signal TLS proxy host to be used for all new connections (until overridden).
Sets a domain name and port to be used to proxy all new outgoing connections, using a Signal transparent TLS proxy. The proxy can be overridden by calling this method again or unset by calling clearProxy.
Existing connections and services will continue with the setting they were created with. (In particular, changing this setting will not affect any existing ChatConnections.)
-
setInvalidProxy
void setInvalidProxy()
Refuses to make any new connections until a new proxy configuration is set or clearProxy is called.
Existing connections will not be affected.
-
clearProxy
void clearProxy()
Ensures that future connections will be made directly, not through a proxy.
Clears any proxy configuration set via setProxy or setInvalidProxy. If none was set, calling this method is a no-op.
Existing connections and services will continue with the setting they were created with. (In particular, changing this setting will not affect any existing ChatConnections.)
-
setCensorshipCircumventionEnabled
void setCensorshipCircumventionEnabled(boolean enabled)
Enables or disables censorship circumvention for all new connections (until changed).
If CC is enabled, new connections and services may try additional routes to the Signal servers. Existing connections and services will continue with the setting they were created with. (In particular, changing this setting will not affect any existing ChatConnections.)
CC is off by default.
-
setRemoteConfig
void setRemoteConfig(Map<String, String> remoteConfig)
Updates libsignal's remote configuration settings.
The provided configuration map must conform to the following requirements:
- Each key represents an enabled configuration and directly indicates that the setting is enabled.
- Keys must have had the platform-specific prefix (e.g., "android.libsignal.") removed.
- Entries explicitly disabled by the server must not appear in the map.
- Values originally set to
nullby the server must be represented as empty strings. - Values should otherwise maintain the same format as they are returned by the server.
These constraints ensure configurations passed to libsignal precisely reflect enabled server-provided settings, without ambiguity.
Only new connections made *after* this call will use the new remote config settings. Existing connections are not affected.
- Parameters:
remoteConfig- a map containing preprocessed libsignal configuration keys and their associated values
-
onNetworkChange
void onNetworkChange()
Notifies libsignal that the network has changed.
This will lead to, e.g. caches being cleared and cooldowns being reset.
-
cdsiLookup
CompletableFuture<CdsiLookupResponse> cdsiLookup(String username, String password, CdsiLookupRequest request, Consumer<Array<byte>> tokenConsumer)
-
checkClassesCanBeLoadedAsyncForTest
static void checkClassesCanBeLoadedAsyncForTest()
Try to load several libsignal classes asynchronously, using the same mechanism as native (Rust) code.
This should only be called in tests, and can be used to ensure at test time that libsignal async code won't fail to load exceptions.
-
preconnectChat
CompletableFuture<Void> preconnectChat()
Starts the process of connecting to the chat server.
If this completes successfully, the next call to connectAuthChat may be able to finish more quickly. If it's incomplete or produces an error, such a call will start from scratch as usual. Only one preconnect is recorded, so there's no point in calling this more than once.
-
connectUnauthChat
CompletableFuture<UnauthenticatedChatConnection> connectUnauthChat(Locale locale, ChatConnectionListener listener)
Initiates an unauthenticated connection attempt to the chat service.
The returned CompletableFuture will resolve when the connection attempt succeeds or fails. If it succeeds, the UnauthenticatedChatConnection can be used to send requests to the chat service, and incoming events will be provided via the provided argument.
If the connection attempt fails, the future will contain a ChatServiceException or other exception type wrapped in a ExecutionException.
-
connectUnauthChat
CompletableFuture<UnauthenticatedChatConnection> connectUnauthChat(ChatConnectionListener listener)
Calls connectUnauthChat with no connection-level locale.
-
connectAuthChat
CompletableFuture<AuthenticatedChatConnection> connectAuthChat(String username, String password, boolean receiveStories, Locale locale, ChatConnectionListener listener)
Initiates an authenticated connection attempt to the chat service.
The returned CompletableFuture will resolve when the connection attempt succeeds or fails. If it succeeds, the AuthenticatedChatConnection can be used to send requests to the chat service, and incoming events will be provided via the provided argument.
If the connection attempt fails, the future will contain a ChatServiceException or other exception type wrapped in a ExecutionException.
-
connectAuthChat
CompletableFuture<AuthenticatedChatConnection> connectAuthChat(String username, String password, boolean receiveStories, ChatConnectionListener listener)
Calls connectAuthChat with no connection-level locale.
-
-
-
-