mirror of
https://github.com/AsamK/signal-cli.git
synced 2026-11-29 08:55:48 +00:00
Add --tls-proxy to connect through a Signal TLS proxy (#2163)
* Add --tls-proxy to connect through a Signal TLS proxy Networks that block Signal can be passed with a Signal TLS proxy, as in the official apps. The new global option (config key tlsProxy) takes a host, host:port or a https://signal.tube/#host link and sets the proxy for the service configuration and for libsignal's Network. Behind the proxy only the proxy host is resolved, so that the Signal host names don't reach the local resolver. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fix the TLS named groups of the native image at build time Through a TLS proxy, Java's TLS negotiates X25519MLKEM768 and looks for a KEM in all providers, including BouncyCastle, which is registered at run time and rejected by the native image ("Failed to get provisioning URL"). A run-time jdk.tls.namedGroups is ignored by the native image. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2a8a141e9e
commit
a974564fb6
13 files changed
+238
-17
No files matched your search
@@ -36,6 +36,10 @@ graalvmNative {
|
||||
buildArgs.add("-J-Dfile.encoding=UTF-8")
|
||||
buildArgs.add("-march=compatibility")
|
||||
buildArgs.add("--enable-native-access=ALL-UNNAMED")
|
||||
// Java's TLS would offer the hybrid X25519MLKEM768 key exchange, e.g. to a Signal TLS proxy, and then look
|
||||
// for a KEM implementation in all providers, including BouncyCastle, which is only registered at run time
|
||||
// and is rejected by the native image. The groups can only be set at build time for the native image.
|
||||
buildArgs.add("-J-Djdk.tls.namedGroups=x25519,secp256r1,secp384r1,secp521r1,x448,ffdhe2048,ffdhe3072")
|
||||
resources.autodetect()
|
||||
if (System.getenv("GRAALVM_HOME") == null) {
|
||||
toolchainDetection.set(true)
|
||||
|
||||
@@ -4,6 +4,7 @@ import org.asamk.signal.manager.api.AccountCheckException;
|
||||
import org.asamk.signal.manager.api.NotRegisteredException;
|
||||
import org.asamk.signal.manager.api.Pair;
|
||||
import org.asamk.signal.manager.api.ServiceEnvironment;
|
||||
import org.asamk.signal.manager.api.TlsProxy;
|
||||
import org.asamk.signal.manager.config.ServiceConfig;
|
||||
import org.asamk.signal.manager.config.ServiceEnvironmentConfig;
|
||||
import org.asamk.signal.manager.internal.AccountFileUpdaterImpl;
|
||||
@@ -16,6 +17,7 @@ import org.asamk.signal.manager.storage.SignalAccount;
|
||||
import org.asamk.signal.manager.storage.accounts.AccountsStore;
|
||||
import org.asamk.signal.manager.util.KeyUtils;
|
||||
import org.signal.core.models.ServiceId.ACI;
|
||||
import org.signal.network.config.SignalProxy;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.DeprecatedVersionException;
|
||||
@@ -23,6 +25,7 @@ import org.whispersystems.signalservice.api.push.exceptions.DeprecatedVersionExc
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -43,10 +46,26 @@ 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 {
|
||||
this.pathConfig = PathConfig.createDefault(settingsPath);
|
||||
this.serviceEnvironment = serviceEnvironment;
|
||||
this.serviceEnvironmentConfig = ServiceConfig.getServiceEnvironmentConfig(this.serviceEnvironment, userAgent);
|
||||
this.serviceEnvironmentConfig = ServiceConfig.getServiceEnvironmentConfig(this.serviceEnvironment,
|
||||
userAgent,
|
||||
tlsProxy.map(proxy -> new SignalProxy(proxy.host(), proxy.port())));
|
||||
this.userAgent = userAgent;
|
||||
this.settings = settings;
|
||||
this.accountsStore = new AccountsStore(pathConfig.dataPath(), serviceEnvironment, accountPath -> {
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package org.asamk.signal.manager.api;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* A Signal TLS proxy, as used by the official Signal apps.
|
||||
*/
|
||||
public record TlsProxy(String host, int port) {
|
||||
|
||||
private static final int DEFAULT_PORT = 443;
|
||||
|
||||
/**
|
||||
* Parses a proxy given as "HOST", "HOST:PORT" (default port 443) or as a proxy link like the ones shared for
|
||||
* the Signal apps ("https://signal.tube/#HOST" or "sgnl://signal.tube/#HOST").
|
||||
*
|
||||
* @throws InvalidTlsProxyException If the value is not a valid proxy.
|
||||
*/
|
||||
public static TlsProxy parse(String value) throws InvalidTlsProxyException {
|
||||
var address = value.strip();
|
||||
if (address.contains("://")) {
|
||||
final URI uri;
|
||||
try {
|
||||
uri = new URI(address);
|
||||
} catch (URISyntaxException e) {
|
||||
throw new InvalidTlsProxyException("Invalid TLS proxy link: " + value, e);
|
||||
}
|
||||
final var scheme = uri.getScheme() == null ? "" : uri.getScheme().toLowerCase(Locale.ROOT);
|
||||
if (!(scheme.equals("https") || scheme.equals("sgnl")) || !"signal.tube".equalsIgnoreCase(uri.getHost())) {
|
||||
throw new InvalidTlsProxyException("Invalid TLS proxy link (expected https://signal.tube/#HOST): "
|
||||
+ value);
|
||||
}
|
||||
address = uri.getFragment() == null ? "" : uri.getFragment();
|
||||
}
|
||||
|
||||
final var colonIndex = address.lastIndexOf(':');
|
||||
final var host = colonIndex < 0 ? address : address.substring(0, colonIndex);
|
||||
final int port;
|
||||
if (colonIndex < 0) {
|
||||
port = DEFAULT_PORT;
|
||||
} else {
|
||||
final var portString = address.substring(colonIndex + 1);
|
||||
try {
|
||||
port = Integer.parseInt(portString);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new InvalidTlsProxyException("Invalid TLS proxy port: " + portString, e);
|
||||
}
|
||||
if (port < 1 || port > 65535) {
|
||||
throw new InvalidTlsProxyException("Invalid TLS proxy port: " + portString);
|
||||
}
|
||||
}
|
||||
if (!host.matches("[A-Za-z0-9.-]+") || host.startsWith(".") || host.endsWith(".")) {
|
||||
throw new InvalidTlsProxyException("Invalid TLS proxy host: " + host);
|
||||
}
|
||||
return new TlsProxy(host, port);
|
||||
}
|
||||
|
||||
public static final class InvalidTlsProxyException extends Exception {
|
||||
|
||||
public InvalidTlsProxyException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public InvalidTlsProxyException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,6 @@ class LiveConfig {
|
||||
private static final TrustStore TRUST_STORE = new WhisperTrustStore();
|
||||
|
||||
private static final Optional<Dns> dns = Optional.empty();
|
||||
private static final Optional<SignalProxy> proxy = Optional.empty();
|
||||
|
||||
private static final byte[] zkGroupServerPublicParams = Base64.getDecoder()
|
||||
.decode("AMhf5ywVwITZMsff/eCyudZx9JDmkkkbV6PInzG4p8x3VqVJSFiMvnvlEKWuRob/1eaIetR31IYeAbm0NdOuHH8Qi+Rexi1wLlpzIo1gstHWBfZzy1+qHRV5A4TqPp15YzBPm0WSggW6PbSn+F4lf57VCnHF7p8SvzAA2ZZJPYJURt8X7bbg+H3i+PEjH9DXItNEqs2sNcug37xZQDLm7X36nOoGPs54XsEGzPdEV+itQNGUFEjY6X9Uv+Acuks7NpyGvCoKxGwgKgE5XyJ+nNKlyHHOLb6N1NuHyBrZrgtY/JYJHRooo5CEqYKBqdFnmbTVGEkCvJKxLnjwKWf+fEPoWeQFj5ObDjcKMZf2Jm2Ae69x+ikU5gBXsRmoF94GXTLfN0/vLt98KDPnxwAQL9j5V1jGOY8jQl6MLxEs56cwXN0dqCnImzVH3TZT1cJ8SW1BRX6qIVxEzjsSGx3yxF3suAilPMqGRp4ffyopjMD1JXiKR2RwLKzizUe5e8XyGOy9fplzhw3jVzTRyUZTRSZKkMLWcQ/gv0E4aONNqs4P+NameAZYOD12qRkxosQQP5uux6B2nRyZ7sAV54DgFyLiRcq1FvwKw2EPQdk4HDoePrO/RNUbyNddnM/mMgj4FW65xCoT1LmjrIjsv/Ggdlx46ueczhMgtBunx1/w8k8V+l8LVZ8gAT6wkU5J+DPQalQguMg12Jzug3q4TbdHiGCmD9EunCwOmsLuLJkz6EcSYXtrlDEnAM+hicw7iergYLLlMXpfTdGxJCWJmP4zqUFeTTmsmhsjGBt7NiEB/9pFFEB3pSbf4iiUukw63Eo8Aqnf4iwob6X1QviCWuc8t0LUlT9vALgh/f2DPVOOmR0RW6bgRvc7DSF20V/omg+YBw==");
|
||||
@@ -55,7 +54,8 @@ class LiveConfig {
|
||||
private static final Environment LIBSIGNAL_NET_ENV = Environment.PRODUCTION;
|
||||
|
||||
static SignalServiceConfiguration createDefaultServiceConfiguration(
|
||||
final List<Interceptor> interceptors
|
||||
final List<Interceptor> interceptors,
|
||||
final Optional<SignalProxy> proxy
|
||||
) {
|
||||
return new SignalServiceConfiguration(new SignalServiceUrl[]{new SignalServiceUrl(URL, TRUST_STORE)},
|
||||
Map.of(0,
|
||||
@@ -68,7 +68,7 @@ class LiveConfig {
|
||||
new SignalCdsiUrl[]{new SignalCdsiUrl(SIGNAL_CDSI_URL, TRUST_STORE)},
|
||||
new SignalSvr2Url[]{new SignalSvr2Url(SIGNAL_SVR2_URL, TRUST_STORE, null, null)},
|
||||
interceptors,
|
||||
dns,
|
||||
proxy.map(ServiceConfig::dnsBehindTlsProxy).or(() -> dns),
|
||||
proxy,
|
||||
zkGroupServerPublicParams,
|
||||
genericServerPublicParams,
|
||||
@@ -85,10 +85,13 @@ class LiveConfig {
|
||||
}
|
||||
}
|
||||
|
||||
static ServiceEnvironmentConfig getServiceEnvironmentConfig(List<Interceptor> interceptors) {
|
||||
static ServiceEnvironmentConfig getServiceEnvironmentConfig(
|
||||
List<Interceptor> interceptors,
|
||||
Optional<SignalProxy> proxy
|
||||
) {
|
||||
return new ServiceEnvironmentConfig(LIVE,
|
||||
LIBSIGNAL_NET_ENV,
|
||||
createDefaultServiceConfiguration(interceptors),
|
||||
createDefaultServiceConfiguration(interceptors, proxy),
|
||||
getUnidentifiedSenderTrustRoots(),
|
||||
CDSI_MRENCLAVE,
|
||||
List.of(SVR2_MRENCLAVE, SVR2_MRENCLAVE_LEGACY));
|
||||
|
||||
@@ -2,11 +2,15 @@ package org.asamk.signal.manager.config;
|
||||
|
||||
import org.asamk.signal.manager.api.ServiceEnvironment;
|
||||
import org.signal.libsignal.protocol.util.Medium;
|
||||
import org.signal.network.config.SignalProxy;
|
||||
import org.whispersystems.signalservice.api.account.AccountAttributes;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import okhttp3.Dns;
|
||||
import okhttp3.Interceptor;
|
||||
|
||||
public class ServiceConfig {
|
||||
@@ -47,6 +51,14 @@ public class ServiceConfig {
|
||||
public static ServiceEnvironmentConfig getServiceEnvironmentConfig(
|
||||
ServiceEnvironment serviceEnvironment,
|
||||
String userAgent
|
||||
) {
|
||||
return getServiceEnvironmentConfig(serviceEnvironment, userAgent, Optional.empty());
|
||||
}
|
||||
|
||||
public static ServiceEnvironmentConfig getServiceEnvironmentConfig(
|
||||
ServiceEnvironment serviceEnvironment,
|
||||
String userAgent,
|
||||
Optional<SignalProxy> tlsProxy
|
||||
) {
|
||||
final Interceptor userAgentInterceptor = chain -> chain.proceed(chain.request()
|
||||
.newBuilder()
|
||||
@@ -56,8 +68,22 @@ public class ServiceConfig {
|
||||
final var interceptors = List.of(userAgentInterceptor);
|
||||
|
||||
return switch (serviceEnvironment) {
|
||||
case LIVE -> LiveConfig.getServiceEnvironmentConfig(interceptors);
|
||||
case STAGING -> StagingConfig.getServiceEnvironmentConfig(interceptors);
|
||||
case LIVE -> LiveConfig.getServiceEnvironmentConfig(interceptors, tlsProxy);
|
||||
case STAGING -> StagingConfig.getServiceEnvironmentConfig(interceptors, tlsProxy);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Behind a Signal TLS proxy every connection goes to the proxy, regardless of the address resolved for the
|
||||
* target host. Only the proxy host is looked up, so that the Signal host names don't reach the local resolver,
|
||||
* which might block or log them.
|
||||
*/
|
||||
static Dns dnsBehindTlsProxy(SignalProxy proxy) {
|
||||
return hostname -> {
|
||||
if (hostname.equalsIgnoreCase(proxy.getHost())) {
|
||||
return Dns.SYSTEM.lookup(hostname);
|
||||
}
|
||||
return List.of(InetAddress.getByAddress(hostname, new byte[]{127, 0, 0, 1}));
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,6 @@ class StagingConfig {
|
||||
private static final TrustStore TRUST_STORE = new WhisperTrustStore();
|
||||
|
||||
private static final Optional<Dns> dns = Optional.empty();
|
||||
private static final Optional<SignalProxy> proxy = Optional.empty();
|
||||
|
||||
private static final byte[] zkGroupServerPublicParams = Base64.getDecoder()
|
||||
.decode("ABSY21VckQcbSXVNCGRYJcfWHiAMZmpTtTELcDmxgdFbtp/bWsSxZdMKzfCp8rvIs8ocCU3B37fT3r4Mi5qAemeGeR2X+/YmOGR5ofui7tD5mDQfstAI9i+4WpMtIe8KC3wU5w3Inq3uNWVmoGtpKndsNfwJrCg0Hd9zmObhypUnSkfYn2ooMOOnBpfdanRtrvetZUayDMSC5iSRcXKpdlukrpzzsCIvEwjwQlJYVPOQPj4V0F4UXXBdHSLK05uoPBCQG8G9rYIGedYsClJXnbrgGYG3eMTG5hnx4X4ntARBgELuMWWUEEfSK0mjXg+/2lPmWcTZWR9nkqgQQP0tbzuiPm74H2wMO4u1Wafe+UwyIlIT9L7KLS19Aw8r4sPrXZSSsOZ6s7M1+rTJN0bI5CKY2PX29y5Ok3jSWufIKcgKOnWoP67d5b2du2ZVJjpjfibNIHbT/cegy/sBLoFwtHogVYUewANUAXIaMPyCLRArsKhfJ5wBtTminG/PAvuBdJ70Z/bXVPf8TVsR292zQ65xwvWTejROW6AZX6aqucUjlENAErBme1YHmOSpU6tr6doJ66dPzVAWIanmO/5mgjNEDeK7DDqQdB1xd03HT2Qs2TxY3kCK8aAb/0iM0HQiXjxZ9HIgYhbtvGEnDKW5ILSUydqH/KBhW4Pb0jZWnqN/YgbWDKeJxnDbYcUob5ZY5Lt5ZCMKuaGUvCJRrCtuugSMaqjowCGRempsDdJEt+cMaalhZ6gczklJB/IbdwENW9KeVFPoFNFzhxWUIS5ML9riVYhAtE6JE5jX0xiHNVIIPthb458cfA8daR0nYfYAUKogQArm0iBezOO+mPk5vCNWI+wwkyFCqNDXz/qxl1gAntuCJtSfq9OC3NkdhQlgYQ==");
|
||||
@@ -55,7 +54,8 @@ class StagingConfig {
|
||||
private static final Network.Environment LIBSIGNAL_NET_ENV = Network.Environment.STAGING;
|
||||
|
||||
static SignalServiceConfiguration createDefaultServiceConfiguration(
|
||||
final List<Interceptor> interceptors
|
||||
final List<Interceptor> interceptors,
|
||||
final Optional<SignalProxy> proxy
|
||||
) {
|
||||
return new SignalServiceConfiguration(new SignalServiceUrl[]{new SignalServiceUrl(URL, TRUST_STORE)},
|
||||
Map.of(0,
|
||||
@@ -68,7 +68,7 @@ class StagingConfig {
|
||||
new SignalCdsiUrl[]{new SignalCdsiUrl(SIGNAL_CDSI_URL, TRUST_STORE)},
|
||||
new SignalSvr2Url[]{new SignalSvr2Url(SIGNAL_SVR2_URL, TRUST_STORE, null, null)},
|
||||
interceptors,
|
||||
dns,
|
||||
proxy.map(ServiceConfig::dnsBehindTlsProxy).or(() -> dns),
|
||||
proxy,
|
||||
zkGroupServerPublicParams,
|
||||
genericServerPublicParams,
|
||||
@@ -85,10 +85,13 @@ class StagingConfig {
|
||||
}
|
||||
}
|
||||
|
||||
static ServiceEnvironmentConfig getServiceEnvironmentConfig(List<Interceptor> interceptors) {
|
||||
static ServiceEnvironmentConfig getServiceEnvironmentConfig(
|
||||
List<Interceptor> interceptors,
|
||||
Optional<SignalProxy> proxy
|
||||
) {
|
||||
return new ServiceEnvironmentConfig(STAGING,
|
||||
LIBSIGNAL_NET_ENV,
|
||||
createDefaultServiceConfiguration(interceptors),
|
||||
createDefaultServiceConfiguration(interceptors, proxy),
|
||||
getUnidentifiedSenderTrustRoots(),
|
||||
CDSI_MRENCLAVE,
|
||||
List.of(SVR2_MRENCLAVE, SVR2_MRENCLAVE_LEGACY));
|
||||
|
||||
@@ -178,6 +178,15 @@ public class SignalDependencies {
|
||||
}
|
||||
|
||||
private void setSignalNetworkProxy(Network libSignalNetwork) {
|
||||
final var tlsProxy = serviceEnvironmentConfig.signalServiceConfiguration().getSignalProxy();
|
||||
if (tlsProxy.isPresent()) {
|
||||
try {
|
||||
libSignalNetwork.setProxy(tlsProxy.get().getHost(), tlsProxy.get().getPort());
|
||||
} catch (IOException e) {
|
||||
logger.warn("Failed to set Signal TLS proxy", e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
final var proxy = Utils.getHttpsProxy();
|
||||
if (proxy.address() instanceof InetSocketAddress addr) {
|
||||
switch (proxy.type()) {
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.asamk.signal.manager.api;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
class TlsProxyTest {
|
||||
|
||||
@Test
|
||||
void parsesHostWithDefaultPort() throws TlsProxy.InvalidTlsProxyException {
|
||||
assertEquals(new TlsProxy("proxy.example.org", 443), TlsProxy.parse("proxy.example.org"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void parsesHostAndPort() throws TlsProxy.InvalidTlsProxyException {
|
||||
assertEquals(new TlsProxy("proxy.example.org", 8443), TlsProxy.parse("proxy.example.org:8443"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void parsesProxyLinks() throws TlsProxy.InvalidTlsProxyException {
|
||||
assertEquals(new TlsProxy("proxy.example.org", 443), TlsProxy.parse("https://signal.tube/#proxy.example.org"));
|
||||
assertEquals(new TlsProxy("proxy.example.org", 443), TlsProxy.parse("sgnl://signal.tube/#proxy.example.org"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsInvalidValues() {
|
||||
for (final var value : new String[]{
|
||||
"",
|
||||
"proxy.example.org:",
|
||||
"proxy.example.org:70000",
|
||||
"https://example.org/#proxy.example.org",
|
||||
"https://signal.tube/",
|
||||
"user@proxy.example.org"
|
||||
}) {
|
||||
assertThrows(TlsProxy.InvalidTlsProxyException.class, () -> TlsProxy.parse(value), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.asamk.signal.manager.config;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.signal.network.config.SignalProxy;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
|
||||
class ServiceConfigTest {
|
||||
|
||||
@Test
|
||||
void resolvesOnlyTheTlsProxyHost() throws UnknownHostException {
|
||||
final var dns = ServiceConfig.dnsBehindTlsProxy(new SignalProxy("localhost", 443));
|
||||
|
||||
assertFalse(dns.lookup("localhost").isEmpty());
|
||||
|
||||
final var addresses = dns.lookup("chat.signal.org");
|
||||
assertEquals(1, addresses.size());
|
||||
assertEquals("chat.signal.org", addresses.getFirst().getHostName());
|
||||
assertEquals("127.0.0.1", addresses.getFirst().getHostAddress());
|
||||
}
|
||||
}
|
||||
@@ -101,6 +101,11 @@ Choose when to trust new identities:
|
||||
*--disable-send-log*::
|
||||
Disable message send log (for resending messages that recipient couldn't decrypt).
|
||||
|
||||
*--tls-proxy* PROXY::
|
||||
Connect to the Signal servers through a Signal TLS proxy, like the proxy setting of the official Signal apps.
|
||||
PROXY is the proxy host, optionally with a port (`HOST:PORT`, default 443), or a proxy link like `https://signal.tube/#HOST`.
|
||||
All connections then go to the proxy and only its host name is resolved via DNS.
|
||||
|
||||
== Commands
|
||||
|
||||
=== register
|
||||
@@ -1237,7 +1242,7 @@ The password and cryptographic keys are created when registering and stored in t
|
||||
=== Configuration file
|
||||
|
||||
signal-cli supports a JSON-based global configuration file that provides defaults for CLI options.
|
||||
Keys use camelCase and generally match the long CLI parameter names (for example `dataDir`, `verbose`, `logFile`, `serviceEnvironment`, `trustNewIdentities`, `output`, `disableSendLog`, `account`).
|
||||
Keys use camelCase and generally match the long CLI parameter names (for example `dataDir`, `verbose`, `logFile`, `serviceEnvironment`, `trustNewIdentities`, `output`, `disableSendLog`, `tlsProxy`, `account`).
|
||||
|
||||
Configuration files are read and merged in this order; later files override earlier ones:
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.asamk.signal.manager.SignalAccountFiles;
|
||||
import org.asamk.signal.manager.api.AccountCheckException;
|
||||
import org.asamk.signal.manager.api.NotRegisteredException;
|
||||
import org.asamk.signal.manager.api.ServiceEnvironment;
|
||||
import org.asamk.signal.manager.api.TlsProxy;
|
||||
import org.asamk.signal.manager.api.TrustNewIdentity;
|
||||
import org.asamk.signal.output.JsonWriterImpl;
|
||||
import org.asamk.signal.output.OutputWriter;
|
||||
@@ -35,6 +36,7 @@ import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import static net.sourceforge.argparse4j.DefaultSettings.VERSION_0_9_0_DEFAULT_SETTINGS;
|
||||
@@ -114,6 +116,10 @@ public class App {
|
||||
.action(Arguments.storeTrue())
|
||||
.setDefault(cfg.disableSendLog() != null ? cfg.disableSendLog() : false);
|
||||
|
||||
parser.addArgument("--tls-proxy")
|
||||
.help("Connect to the Signal servers through a Signal TLS proxy (HOST, HOST:PORT or a https://signal.tube/#HOST link).")
|
||||
.setDefault(cfg.tlsProxy());
|
||||
|
||||
parser.epilog(
|
||||
"The global arguments are shown with 'signal-cli -h' and need to come before the subcommand, while the subcommand-specific arguments (shown with 'signal-cli SUBCOMMAND -h') need to be given after the subcommand.");
|
||||
|
||||
@@ -238,7 +244,7 @@ public class App {
|
||||
return outputWriter;
|
||||
}
|
||||
|
||||
private SignalAccountFiles loadSignalAccountFiles() throws IOErrorException {
|
||||
private SignalAccountFiles loadSignalAccountFiles() throws IOErrorException, UserErrorException {
|
||||
final File dataPath;
|
||||
final var dataDir = ns.getString("data-dir");
|
||||
if (dataDir != null) {
|
||||
@@ -259,11 +265,22 @@ public class App {
|
||||
|
||||
final var disableSendLog = Boolean.TRUE.equals(ns.getBoolean("disable-send-log"));
|
||||
|
||||
final var tlsProxyArgument = ns.getString("tls-proxy");
|
||||
TlsProxy tlsProxy = null;
|
||||
if (tlsProxyArgument != null) {
|
||||
try {
|
||||
tlsProxy = TlsProxy.parse(tlsProxyArgument);
|
||||
} catch (TlsProxy.InvalidTlsProxyException e) {
|
||||
throw new UserErrorException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
return new SignalAccountFiles(dataPath,
|
||||
serviceEnvironment,
|
||||
BaseConfig.USER_AGENT,
|
||||
new Settings(trustNewIdentity, disableSendLog));
|
||||
new Settings(trustNewIdentity, disableSendLog),
|
||||
Optional.ofNullable(tlsProxy));
|
||||
} catch (IOException e) {
|
||||
throw new IOErrorException("Failed to read local accounts list", e);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ public record GlobalConfig(
|
||||
@JsonProperty("serviceEnvironment") ServiceEnvironmentCli serviceEnvironment,
|
||||
@JsonProperty("trustNewIdentities") TrustNewIdentityCli trustNewIdentities,
|
||||
@JsonProperty("disableSendLog") Boolean disableSendLog,
|
||||
@JsonProperty("tlsProxy") String tlsProxy,
|
||||
@JsonProperty("account") String account
|
||||
) {
|
||||
|
||||
@@ -28,9 +29,10 @@ public record GlobalConfig(
|
||||
ServiceEnvironmentCli.LIVE,
|
||||
TrustNewIdentityCli.ON_FIRST_USE,
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
|
||||
public static GlobalConfig empty() {
|
||||
return new GlobalConfig(null, null, null, null, null, null, null, null, null, null, null, null);
|
||||
return new GlobalConfig(null, null, null, null, null, null, null, null, null, null, null, null, null);
|
||||
}
|
||||
}
|
||||
+1
@@ -2341,6 +2341,7 @@
|
||||
"org.asamk.signal.ServiceEnvironmentCli",
|
||||
"org.asamk.signal.TrustNewIdentityCli",
|
||||
"java.lang.Boolean",
|
||||
"java.lang.String",
|
||||
"java.lang.String"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user