mirror of
https://github.com/AsamK/signal-cli.git
synced 2026-11-29 08:55:48 +00:00
Move proxy parsing to lib
This commit is contained in:
1 parent
9d081e5080
commit
7442d8af4f
3 files changed
+15
-30
No files matched your search
@@ -2,7 +2,7 @@ package org.asamk.signal.manager;
|
||||
|
||||
import org.asamk.signal.manager.api.TrustNewIdentity;
|
||||
|
||||
public record Settings(TrustNewIdentity trustNewIdentity, boolean disableMessageSendLog) {
|
||||
public record Settings(TrustNewIdentity trustNewIdentity, boolean disableMessageSendLog, String tlsProxy) {
|
||||
|
||||
public static final Settings DEFAULT = new Settings(TrustNewIdentity.ON_FIRST_USE, false);
|
||||
public static final Settings DEFAULT = new Settings(TrustNewIdentity.ON_FIRST_USE, false, null);
|
||||
}
|
||||
@@ -46,26 +46,19 @@ public class SignalAccountFiles {
|
||||
final ServiceEnvironment serviceEnvironment,
|
||||
final String userAgent,
|
||||
final Settings settings
|
||||
) throws IOException {
|
||||
this(settingsPath, serviceEnvironment, userAgent, settings, Optional.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tlsProxy a Signal TLS proxy, as used by the official Signal apps, through which all connections to
|
||||
* the Signal servers are made.
|
||||
*/
|
||||
public SignalAccountFiles(
|
||||
final File settingsPath,
|
||||
final ServiceEnvironment serviceEnvironment,
|
||||
final String userAgent,
|
||||
final Settings settings,
|
||||
final Optional<TlsProxy> tlsProxy
|
||||
) throws IOException {
|
||||
) throws IOException, TlsProxy.InvalidTlsProxyException {
|
||||
this.pathConfig = PathConfig.createDefault(settingsPath);
|
||||
this.serviceEnvironment = serviceEnvironment;
|
||||
final Optional<SignalProxy> signalProxy;
|
||||
if (settings.tlsProxy() == null) {
|
||||
signalProxy = Optional.empty();
|
||||
} else {
|
||||
final var proxy = TlsProxy.parse(settings.tlsProxy());
|
||||
signalProxy = Optional.of(new SignalProxy(proxy.host(), proxy.port()));
|
||||
}
|
||||
this.serviceEnvironmentConfig = ServiceConfig.getServiceEnvironmentConfig(this.serviceEnvironment,
|
||||
userAgent,
|
||||
tlsProxy.map(proxy -> new SignalProxy(proxy.host(), proxy.port())));
|
||||
signalProxy);
|
||||
this.userAgent = userAgent;
|
||||
this.settings = settings;
|
||||
this.accountsStore = new AccountsStore(pathConfig.dataPath(), serviceEnvironment, accountPath -> {
|
||||
|
||||
Reference in new issue
Block a user