Skip to content

Commit

Permalink
Merge pull request #494 from burst-apps-team/jjos/admin-backup
Browse files Browse the repository at this point in the history
Admin backup, certbot, etc.
  • Loading branch information
jjos2372 committed May 24, 2021
2 parents e673529 + 34f2590 commit f486e9c
Show file tree
Hide file tree
Showing 34 changed files with 380 additions and 306 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Expand Up @@ -45,6 +45,7 @@ jobs:
tag: ${{ github.ref }}
overwrite: true
prerelease: true
draft: true
body: |
This is BRS version ${{github.ref}}
Expand Down
25 changes: 15 additions & 10 deletions conf/brs-default.properties
Expand Up @@ -41,12 +41,10 @@ P2P.UPnP = yes
P2P.myPlatform = PC

# A list of peer addresses / host names, separated by '; ' used for faster P2P networking bootstrap.
# TODO: document what is taken if not set

P2P.BootstrapPeers = node.burst.gittam.de; 80.122.157.25; 138.201.247.112; 35.194.43.230; 24.179.36.64; 136.243.54.19; 160.16.52.180; [2a02:c207:2016:1984:0:0:0:1]; wallet.smit.pro; wallet.logg.coffee; 37.205.11.73; 47.95.232.75; 93.73.103.148; wallet.burst.cryptoguru.org; 51.15.95.163; antigo.hopto.org; 61.171.0.50; burst.megash.it; wi3jodsj.dynu.net; 176.31.105.109; 24.51.189.190; burstwallet2.ddns.net; burstsecurity.com; 81.83.5.50; bloodreaver.no-ip.biz; burstnode.devtrue.net; 185.203.117.157; 138.201.159.96; 52.65.42.199; 159.69.21.174; home.schmiemann.online; 221.241.92.2; peer.wallet.burstcoin.ml; [2a03:3b40:100:0:0:0:1:52]; tompkins.ddns.net; 188.68.41.245; wallet.creepminer.net; burstpool.cloud; 173.249.1.215; 91.143.92.133:18123; 80.71.133.195; redfox.org; 146.247.237.139; 77.70.109.7; 117.48.195.3; 144.76.92.28; bangalore.burstsecurity.com; wallet.burstcoin.asia; aa.storj.eu; 195.201.124.43; wallet.daggeringcats.com; 84.113.147.25; 81.169.131.111; 5.39.93.90; 198.100.149.133; 148.251.78.147; 212.32.255.2; 95.216.142.146; 84.72.183.85; 75.100.126.227; 35.207.44.92; 107.150.6.121; burst.sagichdir.net; [2a07:5741:0:b12:0:0:0:1]; 108.238.244.144; 51.15.219.28; 81.217.76.37; bibenwei.com; 82.192.26.82; logg.coffee; burst-fi.megash.it; 87.227.172.104; 45.76.6.179; chorca.com; 87.98.244.116; 5.189.177.212; 207.38.188.197; 83.87.55.43; 151.248.189.93; 45.32.114.77; 95.165.132.145; 91.143.92.133; 85.217.171.59; 47.33.52.184; www.ollb.de; [2001:19f0:4400:6c35:5400:1ff:fe54:840]; 83.170.94.221; kartoffel.space:8000; 185.203.116.80; 39.106.178.146; 62.210.254.125; 80.65.49.246; 88.198.32.19; carless.ddns.net; 89.166.9.172; 45.77.250.34; 144.76.45.125; 95.216.0.50; 185.185.27.163; 75.100.126.22875.100.126.229; [2a07:5741:0:f8c:0:0:0:1]; 5.103.129.103; 213.32.102.141; 63.251.20.214
P2P.BootstrapPeers = 212.98.92.236;177; 108.61.251.202; 177.153.50.43; 157.90.168.219; 212.98.92.236; 162.55.177.176; 190.15.195.118; 24.96.113.8; 88.64.234.237; 137.135.203.145; 70.108.6.237; 144.91.84.164; 213.32.102.141; 5.196.65.184; 89.163.239.219; 165.227.36.71

# These peers will always be sent rebroadcast transactions. They are also automatically added to P2P.BootstrapPeers, so no need for duplicates.
P2P.rebroadcastTo = 77.66.65.240; 78.46.245.194; 94.130.190.156; 75.100.126.230; 75.100.126.226; 212.98.92.236;
P2P.rebroadcastTo = 77.66.65.240; 172.67.142.5; 216.128.181.211; 77.68.73.180

# Connect to this many bootstrap connection peers before using the peer database to get connected faster. Please be aware, that higher != better (3-5 are usually good values) Set to 0 or comment out to disable.
P2P.NumBootstrapConnections = 3
Expand All @@ -57,6 +55,9 @@ P2P.BlacklistedPeers =
# Maintain active connections with at least that many peers. Also more != better (you want good peers, not just many)
P2P.MaxConnections = 20

# Maximum number of blocks sent to other peers in a single request
P2P.MaxBlocks = 720

# Use Peers Database? (Only if not in Offline mode)
P2P.usePeersDb = yes
# Save known peers in the PeersDB? (only if P2P.usePeersDB is true)
Expand Down Expand Up @@ -156,15 +157,14 @@ JETTY.API.GZIPFilter.methods = "GET, POST"
JETTY.API.GZIPFilter.bufferSize = 8192
JETTY.API.GZIPFilter.minGzipSize = 0

# Developers or maintenance only! Enable API requests used for
# blockchain and database manipulation. If this is enabled and your
# wallet is public, you are very vulnerable.
API.Debug = off

# Hosts or subnets from which to allow http/json API requests, if enabled.
# List delimited by ';', IPv4/IPv6 possible, default: localhost
API.allowed = 127.0.0.1; localhost; [0:0:0:0:0:0:0:1];

# Key list to access the admin API requests, uncomment and replace with your own keys
# delimited by ';' if more than one key should be available
#API.adminKeyList = e673529588638d2129af1e0528a1642cf2e0c180

# Does the API accept additional/redundant parameters in an API call?
# default is no (Wallet accepts only params specified for given call)
# enable this if you have a sloppy client interacting, but please be aware that this
Expand Down Expand Up @@ -198,9 +198,14 @@ API.SSL = off
# Enforce requests that require POST to only be accepted when submitted as POST.
API.ServerEnforcePOST = yes

# keystore file and password, required if uiSSL or apiSSL are enabled.
# Your keystore file and password, required if uiSSL or apiSSL are enabled.
API.SSL_keyStorePath = keystore
API.SSL_keyStorePassword = password
# If you use https://certbot.eff.org/ to issue your certificate, provide below the path for your keys.
# BRS will automatically create the keystore file using the password above and will reload it weekly.
# Make sure you configure certbot to renew your certificate automatically so you don't need to worry about it.
# Note, you need 'openssl' on your path for this to work, most Linux distributions have it already.
# API.SSL_letsencryptPath = /etc/letsencrypt/live/yourdomain.com

#### DATABASE ####

Expand Down
2 changes: 1 addition & 1 deletion html/ui/html/modals/send_money.html
Expand Up @@ -71,7 +71,7 @@ <h4 class="modal-title" data-i18n="send_burst">Send BURST</h4>
<label for="send_money_message" data-i18n="message">MESSAGE</label>
<textarea class="form-control" id="send_money_message" name="message" rows="4" tabindex="7"></textarea>
<div style="margin-top:3px">
<label for="send_money_encrypt_message" style="font-weight:normal;color:#666"><input type="checkbox" name="encrypt_message" id="send_money_encrypt_message" value="1" data-default="checked" /> <span data-i18n="encrypt_message">Encrypt Message</span></label>
<label for="send_money_encrypt_message" style="font-weight:normal;color:#666"><input type="checkbox" name="encrypt_message" id="send_money_encrypt_message" data-default="checked" /> <span data-i18n="encrypt_message">Encrypt Message</span></label>
</div>
</div>
<div class="row">
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -6,7 +6,7 @@

<groupId>burstcoin</groupId>
<artifactId>burstcoin</artifactId>
<version>3.0.0</version>
<version>3.0.1</version>
<name>Burstcoin Reference Software</name>
<url>https://github.com/burst-apps-team/burstcoin</url>

Expand Down
4 changes: 3 additions & 1 deletion src/brs/BlockchainProcessorImpl.java
Expand Up @@ -779,10 +779,12 @@ public List<Block> popOffTo(int height) {

@Override
public void fullReset() {
blockDb.deleteAll(false);
dbCacheManager.flushCache();
downloadCache.resetCache();
blockDb.deleteAll(false);
addGenesisBlock();
dbCacheManager.flushCache();
downloadCache.resetCache();
}

void setGetMoreBlocks(boolean getMoreBlocks) {
Expand Down
8 changes: 6 additions & 2 deletions src/brs/Burst.java
Expand Up @@ -30,6 +30,7 @@
import brs.util.LoggerConfigurator;
import brs.util.ThreadPool;
import brs.util.Time;
import burst.kit.util.BurstKitUtils;
import io.grpc.Server;

import org.apache.commons.cli.CommandLine;
Expand All @@ -46,7 +47,7 @@

public final class Burst {

public static final Version VERSION = Version.parse("v3.0.0");
public static final Version VERSION = Version.parse("v3.0.1");

public static final String APPLICATION = "BRS";

Expand Down Expand Up @@ -109,7 +110,7 @@ private static PropertyService loadProperties(String confFolder) {
} catch (IOException e) {
logger.info("Custom user properties file {} not loaded", PROPERTIES_NAME);
}

return new PropertyServiceImpl(properties);
}

Expand Down Expand Up @@ -175,6 +176,9 @@ private static void loadWallet(PropertyService propertyService) {

try {
long startTime = System.currentTimeMillis();

// Additional valid prefix
BurstKitUtils.addAddressPrefix(propertyService.getBoolean(Props.DEV_TESTNET) ? "TS" : "S");

final TimeService timeService = new TimeServiceImpl();

Expand Down
16 changes: 15 additions & 1 deletion src/brs/BurstGUI.java
Expand Up @@ -92,6 +92,20 @@ public BurstGUI() {
}
if(lafc!=null) {
try {
UIManager.put( "control", new Color( 128, 128, 128) );
UIManager.put( "info", new Color(128,128,128) );
UIManager.put( "nimbusBase", new Color( 18, 30, 49) );
UIManager.put( "nimbusAlertYellow", new Color( 248, 187, 0) );
UIManager.put( "nimbusDisabledText", new Color( 128, 128, 128) );
UIManager.put( "nimbusFocus", new Color(115,164,209) );
UIManager.put( "nimbusGreen", new Color(176,179,50) );
UIManager.put( "nimbusInfoBlue", new Color( 66, 139, 221) );
UIManager.put( "nimbusLightBackground", new Color( 18, 30, 49) );
UIManager.put( "nimbusOrange", new Color(191,98,4) );
UIManager.put( "nimbusRed", new Color(169,46,34) );
UIManager.put( "nimbusSelectedText", new Color( 255, 255, 255) );
UIManager.put( "nimbusSelectionBackground", new Color( 104, 93, 156) );
UIManager.put( "text", new Color( 230, 230, 230) );
LookAndFeel laf = (LookAndFeel) lafc.getConstructor().newInstance();
UIManager.setLookAndFeel(laf);
} catch (Exception e) {
Expand Down Expand Up @@ -231,7 +245,7 @@ private TrayIcon createTrayIcon() {
toolBar.add(openPhoenixButton);
toolBar.add(openClassicButton);
toolBar.add(editConfButton);
if(Burst.getPropertyService().getBoolean(Props.API_DEBUG) || Burst.getPropertyService().getBoolean(Props.DEV_TESTNET)) {
if(Burst.getPropertyService().getBoolean(Props.DEV_TESTNET)) {
toolBar.add(popOff10Button);
toolBar.add(popOff100Button);
// toolBar.add(popOffMaxButton);
Expand Down
10 changes: 8 additions & 2 deletions src/brs/TransactionType.java
Expand Up @@ -230,8 +230,8 @@ public final boolean applyUnconfirmed(Transaction transaction, Account senderAcc
}
accountService.addToUnconfirmedBalanceNQT(senderAccount, -totalAmountNQT);
if (!applyAttachmentUnconfirmed(transaction, senderAccount)) {
if (logger.isTraceEnabled()) {
logger.trace("!applyAttachmentUnconfirmed({}, {})", transaction, senderAccount.getId());
if (logger.isDebugEnabled()) {
logger.debug("!applyAttachmentUnconfirmed({}, {})", transaction, senderAccount.getId());
}
accountService.addToUnconfirmedBalanceNQT(senderAccount, totalAmountNQT);
return false;
Expand Down Expand Up @@ -1963,6 +1963,12 @@ public String getDescription() {
Attachment.CommitmentAdd parseAttachment(JsonObject attachmentData) {
return new Attachment.CommitmentAdd(attachmentData);
}

protected Long calculateAttachmentTotalAmountNQT(Transaction transaction) {
CommitmentAdd commitmentAdd = (CommitmentAdd) transaction.getAttachment();
Long totalAmountNQT = commitmentAdd.getAmountNQT();
return totalAmountNQT;
}

@Override
boolean applyAttachmentUnconfirmed(Transaction transaction, Account senderAccount) {
Expand Down
42 changes: 33 additions & 9 deletions src/brs/db/sql/Db.java
Expand Up @@ -43,6 +43,8 @@ public final class Db {

private static DBCacheManagerImpl dbCacheManager;

private static Flyway flyway;

public static void init(PropertyService propertyService, DBCacheManagerImpl dbCacheManager) {
Db.dbCacheManager = dbCacheManager;

Expand Down Expand Up @@ -76,13 +78,11 @@ public static void init(PropertyService propertyService, DBCacheManagerImpl dbCa
FluentConfiguration flywayBuilder = Flyway.configure()
.dataSource(dbUrl, dbUsername, dbPassword)
.baselineOnMigrate(true);
boolean runFlyway = false;

switch (dialect) {
case MYSQL:
case MARIADB:
flywayBuilder.locations("classpath:/db/migration_mariadb");
runFlyway = true;
config.setAutoCommit(true);
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "512");
Expand Down Expand Up @@ -120,7 +120,6 @@ protected synchronized void initialize() throws SQLException {
case H2:
Class.forName("org.h2.Driver");
flywayBuilder.locations("classpath:/db/migration_h2");
runFlyway = true;
config.setAutoCommit(true);
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
Expand All @@ -132,17 +131,24 @@ protected synchronized void initialize() throws SQLException {
break;
}

cp = new HikariDataSource(config);
cp = new HikariDataSource(config);

if (runFlyway) {
logger.info("Running flyway migration");
Flyway flyway = flywayBuilder.load();
flyway.migrate();
}
logger.info("Running flyway migration");
flyway = flywayBuilder.load();
flyway.migrate();
} catch (Exception e) {
throw new RuntimeException(e.toString(), e);
}
}

public static void clean() {
try {
flyway.clean();
flyway.migrate();
} catch (Exception e) {
logger.error(e.getMessage());
}
}

private Db() {
} // never
Expand Down Expand Up @@ -185,6 +191,24 @@ public static void shutdown() {
cp.close();
}
}

public static void backup(String filename) {
if (dialect == SQLDialect.H2) {
logger.info("Database backup to {} started, it might take a while.", filename);
try ( Connection con = cp.getConnection(); Statement stmt = con.createStatement() ) {
stmt.execute("BACKUP TO '" + filename + "'");
}
catch (SQLException e) {
logger.info(e.toString(), e);
}
finally {
logger.info("Database backup completed, file {}.", filename);
}
}
else {
logger.error("Backup not yet implemented for {}", dialect.toString());
}
}

private static Connection getPooledConnection() throws SQLException {
return cp.getConnection();
Expand Down
28 changes: 1 addition & 27 deletions src/brs/db/sql/SqlBlockDb.java
Expand Up @@ -9,14 +9,10 @@
import org.jooq.DeleteQuery;
import org.jooq.Record;
import org.jooq.SelectQuery;
import org.jooq.impl.TableImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;

import static brs.schema.Tables.BLOCK;
Expand Down Expand Up @@ -181,29 +177,7 @@ public void deleteAll(boolean force) {
return;
}
logger.info("Deleting blockchain...");
Db.useDSLContext(ctx -> {
List<TableImpl> tables = new ArrayList<>(Arrays.asList(brs.schema.Tables.ACCOUNT,
brs.schema.Tables.ACCOUNT_ASSET, brs.schema.Tables.ALIAS, brs.schema.Tables.ALIAS_OFFER,
brs.schema.Tables.ASK_ORDER, brs.schema.Tables.ASSET, brs.schema.Tables.ASSET_TRANSFER,
brs.schema.Tables.AT, brs.schema.Tables.AT_STATE, brs.schema.Tables.BID_ORDER,
brs.schema.Tables.BLOCK, brs.schema.Tables.ESCROW, brs.schema.Tables.ESCROW_DECISION,
brs.schema.Tables.GOODS, brs.schema.Tables.PEER, brs.schema.Tables.PURCHASE,
brs.schema.Tables.PURCHASE_FEEDBACK, brs.schema.Tables.PURCHASE_PUBLIC_FEEDBACK,
brs.schema.Tables.REWARD_RECIP_ASSIGN, brs.schema.Tables.SUBSCRIPTION,
brs.schema.Tables.TRADE, brs.schema.Tables.TRANSACTION,
brs.schema.Tables.UNCONFIRMED_TRANSACTION));
for (TableImpl<?> table : tables) {
try {
ctx.truncate(table).execute();
} catch (org.jooq.exception.DataAccessException e) {
if (force) {
logger.trace("exception during truncate {0}", table, e);
} else {
throw e;
}
}
}
});
Db.clean();
}

@Override
Expand Down

0 comments on commit f486e9c

Please sign in to comment.