2 Copyright (C) 2015-2021 AsamK and contributors
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org
.asamk
.signal
;
19 import net
.sourceforge
.argparse4j
.ArgumentParsers
;
20 import net
.sourceforge
.argparse4j
.impl
.Arguments
;
21 import net
.sourceforge
.argparse4j
.inf
.ArgumentParserException
;
22 import net
.sourceforge
.argparse4j
.inf
.Namespace
;
24 import org
.asamk
.signal
.manager
.LibSignalLogger
;
25 import org
.asamk
.signal
.util
.SecurityProvider
;
26 import org
.bouncycastle
.jce
.provider
.BouncyCastleProvider
;
28 import java
.security
.Security
;
32 public static void main(String
[] args
) {
33 installSecurityProviderWorkaround();
35 // Configuring the logger needs to happen before any logger is initialized
36 configureLogging(isVerbose(args
));
38 var parser
= App
.buildArgumentParser();
40 var ns
= parser
.parseArgsOrFail(args
);
42 var res
= new App(ns
).init();
46 private static void installSecurityProviderWorkaround() {
47 // Register our own security provider
48 Security
.insertProviderAt(new SecurityProvider(), 1);
49 Security
.addProvider(new BouncyCastleProvider());
52 private static boolean isVerbose(String
[] args
) {
53 var parser
= ArgumentParsers
.newFor("signal-cli").build().defaultHelp(false);
54 parser
.addArgument("--verbose").action(Arguments
.storeTrue());
58 ns
= parser
.parseKnownArgs(args
, null);
59 } catch (ArgumentParserException e
) {
63 return ns
.getBoolean("verbose");
66 private static void configureLogging(final boolean verbose
) {
68 System
.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "debug");
69 System
.setProperty("org.slf4j.simpleLogger.showThreadName", "true");
70 System
.setProperty("org.slf4j.simpleLogger.showShortLogName", "false");
71 System
.setProperty("org.slf4j.simpleLogger.showDateTime", "true");
72 System
.setProperty("org.slf4j.simpleLogger.dateTimeFormat", "yyyy-MM-dd'T'HH:mm:ss.SSSXX");
73 LibSignalLogger
.initLogger();
75 System
.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "info");
76 System
.setProperty("org.slf4j.simpleLogger.showThreadName", "false");
77 System
.setProperty("org.slf4j.simpleLogger.showShortLogName", "true");
78 System
.setProperty("org.slf4j.simpleLogger.showDateTime", "false");