-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1685 from ripcurlx/merge-remaining-repositories
Merge missing repositories into mono repository
- Loading branch information
Showing
78 changed files
with
4,432 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
plugins { | ||
id 'java' | ||
id 'application' | ||
} | ||
|
||
group = 'network.bisq' | ||
version = '0.8.0-SNAPSHOT' | ||
|
||
sourceCompatibility = 1.8 | ||
|
||
mainClassName = 'bisq.monitor.MonitorMain' | ||
|
||
repositories { | ||
jcenter() | ||
maven { url "https://jitpack.io" } | ||
maven { url 'https://raw.githubusercontent.com/JesusMcCloud/tor-binary/master/release/' } | ||
} | ||
|
||
dependencies { | ||
compile project(':core') | ||
compile 'com.sparkjava:spark-core:2.5.2' | ||
compile 'net.gpedro.integrations.slack:slack-webhook:1.1.1' | ||
compileOnly 'org.projectlombok:lombok:1.16.16' | ||
annotationProcessor 'org.projectlombok:lombok:1.16.16' | ||
} | ||
|
||
build.dependsOn installDist | ||
installDist.destinationDir = file('build/app') | ||
distZip.enabled = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* This file is part of Bisq. | ||
* | ||
* Bisq is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or (at | ||
* your option) any later version. | ||
* | ||
* Bisq is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public | ||
* License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package bisq.monitor; | ||
|
||
import bisq.monitor.metrics.MetricsModel; | ||
|
||
import com.google.inject.Injector; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
public class Monitor { | ||
@Setter | ||
private Injector injector; | ||
@Getter | ||
private MetricsModel metricsModel; | ||
|
||
public Monitor() { | ||
} | ||
|
||
public void startApplication() { | ||
metricsModel = injector.getInstance(MetricsModel.class); | ||
|
||
MonitorAppSetup appSetup = injector.getInstance(MonitorAppSetup.class); | ||
appSetup.start(); | ||
} | ||
} |
119 changes: 119 additions & 0 deletions
119
monitor/src/main/java/bisq/monitor/MonitorAppSetup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/* | ||
* This file is part of Bisq. | ||
* | ||
* bisq is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or (at | ||
* your option) any later version. | ||
* | ||
* bisq is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public | ||
* License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with bisq. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package bisq.monitor; | ||
|
||
import bisq.monitor.metrics.p2p.MonitorP2PService; | ||
|
||
import bisq.core.app.BisqEnvironment; | ||
import bisq.core.app.SetupUtils; | ||
import bisq.core.btc.wallet.WalletsSetup; | ||
|
||
import bisq.network.crypto.EncryptionService; | ||
import bisq.network.p2p.network.SetupListener; | ||
import bisq.network.p2p.peers.PeerManager; | ||
|
||
import bisq.common.app.Version; | ||
import bisq.common.crypto.KeyRing; | ||
import bisq.common.proto.persistable.PersistedDataHost; | ||
|
||
import javax.inject.Inject; | ||
|
||
import java.util.ArrayList; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
public class MonitorAppSetup { | ||
private MonitorP2PService seedNodeMonitorP2PService; | ||
private final WalletsSetup walletsSetup; | ||
private PeerManager peerManager; | ||
private final KeyRing keyRing; | ||
private final EncryptionService encryptionService; | ||
|
||
@Inject | ||
public MonitorAppSetup(MonitorP2PService seedNodeMonitorP2PService, | ||
WalletsSetup walletsSetup, | ||
PeerManager peerManager, | ||
KeyRing keyRing, | ||
EncryptionService encryptionService) { | ||
this.seedNodeMonitorP2PService = seedNodeMonitorP2PService; | ||
this.walletsSetup = walletsSetup; | ||
this.peerManager = peerManager; | ||
this.keyRing = keyRing; | ||
this.encryptionService = encryptionService; | ||
Version.setBaseCryptoNetworkId(BisqEnvironment.getBaseCurrencyNetwork().ordinal()); | ||
Version.printVersion(); | ||
} | ||
|
||
public void start() { | ||
SetupUtils.checkCryptoSetup(keyRing, encryptionService, () -> { | ||
initPersistedDataHosts(); | ||
initBasicServices(); | ||
}, throwable -> { | ||
log.error(throwable.getMessage()); | ||
throwable.printStackTrace(); | ||
System.exit(1); | ||
}); | ||
} | ||
|
||
public void initPersistedDataHosts() { | ||
ArrayList<PersistedDataHost> persistedDataHosts = new ArrayList<>(); | ||
persistedDataHosts.add(seedNodeMonitorP2PService); | ||
persistedDataHosts.add(peerManager); | ||
|
||
// we apply at startup the reading of persisted data but don't want to get it triggered in the constructor | ||
persistedDataHosts.forEach(e -> { | ||
try { | ||
log.info("call readPersisted at " + e.getClass().getSimpleName()); | ||
e.readPersisted(); | ||
} catch (Throwable e1) { | ||
log.error("readPersisted error", e1); | ||
} | ||
}); | ||
} | ||
|
||
protected void initBasicServices() { | ||
SetupUtils.readFromResources(seedNodeMonitorP2PService.getP2PDataStorage()).addListener((observable, oldValue, newValue) -> { | ||
if (newValue) { | ||
seedNodeMonitorP2PService.start(new SetupListener() { | ||
|
||
|
||
@Override | ||
public void onTorNodeReady() { | ||
walletsSetup.initialize(null, | ||
() -> log.info("walletsSetup completed"), | ||
throwable -> log.error(throwable.toString())); | ||
} | ||
|
||
@Override | ||
public void onHiddenServicePublished() { | ||
} | ||
|
||
@Override | ||
public void onSetupFailed(Throwable throwable) { | ||
} | ||
|
||
@Override | ||
public void onRequestCustomBridges() { | ||
} | ||
}); | ||
|
||
} | ||
}); | ||
} | ||
} |
129 changes: 129 additions & 0 deletions
129
monitor/src/main/java/bisq/monitor/MonitorEnvironment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
/* | ||
* This file is part of Bisq. | ||
* | ||
* bisq is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or (at | ||
* your option) any later version. | ||
* | ||
* bisq is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public | ||
* License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with bisq. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package bisq.monitor; | ||
|
||
import bisq.core.app.AppOptionKeys; | ||
import bisq.core.app.BisqEnvironment; | ||
import bisq.core.btc.BtcOptionKeys; | ||
import bisq.core.btc.UserAgent; | ||
import bisq.core.dao.DaoOptionKeys; | ||
|
||
import bisq.network.NetworkOptionKeys; | ||
|
||
import bisq.common.CommonOptionKeys; | ||
import bisq.common.app.Version; | ||
import bisq.common.crypto.KeyStorage; | ||
import bisq.common.storage.Storage; | ||
|
||
import org.springframework.core.env.JOptCommandLinePropertySource; | ||
import org.springframework.core.env.PropertiesPropertySource; | ||
import org.springframework.core.env.PropertySource; | ||
|
||
import joptsimple.OptionSet; | ||
|
||
import java.nio.file.Paths; | ||
|
||
import java.util.Properties; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
public class MonitorEnvironment extends BisqEnvironment { | ||
|
||
private String slackUrlSeedChannel = ""; | ||
private String slackUrlBtcChannel = ""; | ||
private String slackUrlProviderChannel = ""; | ||
private String port; | ||
|
||
public MonitorEnvironment(OptionSet options) { | ||
this(new JOptCommandLinePropertySource(BISQ_COMMANDLINE_PROPERTY_SOURCE_NAME, checkNotNull(options))); | ||
} | ||
|
||
public MonitorEnvironment(PropertySource commandLineProperties) { | ||
super(commandLineProperties); | ||
|
||
slackUrlSeedChannel = commandLineProperties.containsProperty(MonitorOptionKeys.SLACK_URL_SEED_CHANNEL) ? | ||
(String) commandLineProperties.getProperty(MonitorOptionKeys.SLACK_URL_SEED_CHANNEL) : | ||
""; | ||
|
||
slackUrlBtcChannel = commandLineProperties.containsProperty(MonitorOptionKeys.SLACK_BTC_SEED_CHANNEL) ? | ||
(String) commandLineProperties.getProperty(MonitorOptionKeys.SLACK_BTC_SEED_CHANNEL) : | ||
""; | ||
|
||
slackUrlProviderChannel = commandLineProperties.containsProperty(MonitorOptionKeys.SLACK_PROVIDER_SEED_CHANNEL) ? | ||
(String) commandLineProperties.getProperty(MonitorOptionKeys.SLACK_PROVIDER_SEED_CHANNEL) : | ||
""; | ||
|
||
port = commandLineProperties.containsProperty(MonitorOptionKeys.PORT) ? | ||
(String) commandLineProperties.getProperty(MonitorOptionKeys.PORT) : | ||
"80"; | ||
|
||
// hack because defaultProperties() is called from constructor and slackUrlSeedChannel would be null there | ||
getPropertySources().remove("bisqDefaultProperties"); | ||
getPropertySources().addLast(defaultPropertiesMonitor()); | ||
} | ||
|
||
protected PropertySource<?> defaultPropertiesMonitor() { | ||
return new PropertiesPropertySource(BISQ_DEFAULT_PROPERTY_SOURCE_NAME, new Properties() { | ||
{ | ||
setProperty(CommonOptionKeys.LOG_LEVEL_KEY, logLevel); | ||
setProperty(MonitorOptionKeys.SLACK_URL_SEED_CHANNEL, slackUrlSeedChannel); | ||
setProperty(MonitorOptionKeys.SLACK_BTC_SEED_CHANNEL, slackUrlBtcChannel); | ||
setProperty(MonitorOptionKeys.SLACK_PROVIDER_SEED_CHANNEL, slackUrlProviderChannel); | ||
setProperty(MonitorOptionKeys.PORT, port); | ||
|
||
setProperty(NetworkOptionKeys.SEED_NODES_KEY, seedNodes); | ||
setProperty(NetworkOptionKeys.MY_ADDRESS, myAddress); | ||
setProperty(NetworkOptionKeys.BAN_LIST, banList); | ||
setProperty(NetworkOptionKeys.TOR_DIR, Paths.get(btcNetworkDir, "tor").toString()); | ||
setProperty(NetworkOptionKeys.NETWORK_ID, String.valueOf(baseCurrencyNetwork.ordinal())); | ||
setProperty(NetworkOptionKeys.SOCKS_5_PROXY_BTC_ADDRESS, socks5ProxyBtcAddress); | ||
setProperty(NetworkOptionKeys.SOCKS_5_PROXY_HTTP_ADDRESS, socks5ProxyHttpAddress); | ||
|
||
setProperty(AppOptionKeys.APP_DATA_DIR_KEY, appDataDir); | ||
setProperty(AppOptionKeys.IGNORE_DEV_MSG_KEY, ignoreDevMsg); | ||
setProperty(AppOptionKeys.DUMP_STATISTICS, dumpStatistics); | ||
setProperty(AppOptionKeys.APP_NAME_KEY, appName); | ||
setProperty(AppOptionKeys.MAX_MEMORY, maxMemory); | ||
setProperty(AppOptionKeys.USER_DATA_DIR_KEY, userDataDir); | ||
setProperty(AppOptionKeys.PROVIDERS, providers); | ||
|
||
setProperty(DaoOptionKeys.RPC_USER, rpcUser); | ||
setProperty(DaoOptionKeys.RPC_PASSWORD, rpcPassword); | ||
setProperty(DaoOptionKeys.RPC_PORT, rpcPort); | ||
setProperty(DaoOptionKeys.RPC_BLOCK_NOTIFICATION_PORT, rpcBlockNotificationPort); | ||
setProperty(DaoOptionKeys.DUMP_BLOCKCHAIN_DATA, dumpBlockchainData); | ||
setProperty(DaoOptionKeys.FULL_DAO_NODE, fullDaoNode); | ||
setProperty(DaoOptionKeys.GENESIS_TX_ID, genesisTxId); | ||
setProperty(DaoOptionKeys.GENESIS_BLOCK_HEIGHT, genesisBlockHeight); | ||
|
||
setProperty(BtcOptionKeys.BTC_NODES, btcNodes); | ||
setProperty(BtcOptionKeys.USE_TOR_FOR_BTC, useTorForBtc); | ||
setProperty(BtcOptionKeys.WALLET_DIR, btcNetworkDir); | ||
setProperty(BtcOptionKeys.USER_AGENT, userAgent); | ||
setProperty(BtcOptionKeys.USE_ALL_PROVIDED_NODES, useAllProvidedNodes); | ||
setProperty(BtcOptionKeys.NUM_CONNECTIONS_FOR_BTC, numConnectionForBtc); | ||
|
||
setProperty(UserAgent.NAME_KEY, appName); | ||
setProperty(UserAgent.VERSION_KEY, Version.VERSION); | ||
|
||
setProperty(Storage.STORAGE_DIR, Paths.get(btcNetworkDir, "db").toString()); | ||
setProperty(KeyStorage.KEY_STORAGE_DIR, Paths.get(btcNetworkDir, "keys").toString()); | ||
} | ||
}); | ||
} | ||
} |
Oops, something went wrong.