Updated Jabit version, improved configuration
This commit is contained in:
parent
67167906aa
commit
a1541dd51b
1
.gitignore
vendored
1
.gitignore
vendored
@ -13,6 +13,7 @@ config.properties
|
|||||||
### Gradle ###
|
### Gradle ###
|
||||||
.gradle
|
.gradle
|
||||||
build/
|
build/
|
||||||
|
classes/
|
||||||
|
|
||||||
# Ignore Gradle GUI config
|
# Ignore Gradle GUI config
|
||||||
gradle-app.setting
|
gradle-app.setting
|
||||||
|
@ -33,7 +33,7 @@ configurations {
|
|||||||
providedRuntime
|
providedRuntime
|
||||||
}
|
}
|
||||||
|
|
||||||
ext.jabitVersion = '1.0.0'
|
ext.jabitVersion = 'development-SNAPSHOT'
|
||||||
dependencies {
|
dependencies {
|
||||||
compile("org.springframework.boot:spring-boot-starter-hateoas")
|
compile("org.springframework.boot:spring-boot-starter-hateoas")
|
||||||
compile("org.springframework.boot:spring-boot-starter-jersey")
|
compile("org.springframework.boot:spring-boot-starter-jersey")
|
||||||
@ -44,7 +44,7 @@ dependencies {
|
|||||||
compile "ch.dissem.jabit:jabit-core:$jabitVersion"
|
compile "ch.dissem.jabit:jabit-core:$jabitVersion"
|
||||||
compile "ch.dissem.jabit:jabit-networking:$jabitVersion"
|
compile "ch.dissem.jabit:jabit-networking:$jabitVersion"
|
||||||
compile "ch.dissem.jabit:jabit-repositories:$jabitVersion"
|
compile "ch.dissem.jabit:jabit-repositories:$jabitVersion"
|
||||||
compile "ch.dissem.jabit:jabit-cryptography-bouncy:$jabitVersion"
|
compile "ch.dissem.jabit:jabit-cryptography-spongy:$jabitVersion"
|
||||||
compile "ch.dissem.jabit:jabit-extensions:$jabitVersion"
|
compile "ch.dissem.jabit:jabit-extensions:$jabitVersion"
|
||||||
|
|
||||||
compile 'com.h2database:h2:1.4.187'
|
compile 'com.h2database:h2:1.4.187'
|
||||||
|
@ -17,19 +17,23 @@
|
|||||||
package ch.dissem.bitmessage.server;
|
package ch.dissem.bitmessage.server;
|
||||||
|
|
||||||
import ch.dissem.bitmessage.BitmessageContext;
|
import ch.dissem.bitmessage.BitmessageContext;
|
||||||
import ch.dissem.bitmessage.cryptography.bc.BouncyCryptography;
|
import ch.dissem.bitmessage.cryptography.sc.SpongyCryptography;
|
||||||
import ch.dissem.bitmessage.entity.BitmessageAddress;
|
import ch.dissem.bitmessage.entity.BitmessageAddress;
|
||||||
import ch.dissem.bitmessage.networking.DefaultNetworkHandler;
|
import ch.dissem.bitmessage.entity.payload.Pubkey;
|
||||||
|
import ch.dissem.bitmessage.networking.nio.NioNetworkHandler;
|
||||||
import ch.dissem.bitmessage.ports.*;
|
import ch.dissem.bitmessage.ports.*;
|
||||||
import ch.dissem.bitmessage.repository.*;
|
import ch.dissem.bitmessage.repository.*;
|
||||||
import ch.dissem.bitmessage.server.repository.ServerProofOfWorkRepository;
|
import ch.dissem.bitmessage.server.repository.ServerProofOfWorkRepository;
|
||||||
import ch.dissem.bitmessage.utils.Singleton;
|
import ch.dissem.bitmessage.utils.Singleton;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import springfox.documentation.spi.DocumentationType;
|
import springfox.documentation.spi.DocumentationType;
|
||||||
import springfox.documentation.spring.web.plugins.Docket;
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static ch.dissem.bitmessage.server.Constants.*;
|
import static ch.dissem.bitmessage.server.Constants.*;
|
||||||
@ -37,6 +41,8 @@ import static java.util.stream.Collectors.toSet;
|
|||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class JabitServerConfig {
|
public class JabitServerConfig {
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(JabitServerConfig.class);
|
||||||
|
|
||||||
public static final int SHORTLIST_SIZE = 5;
|
public static final int SHORTLIST_SIZE = 5;
|
||||||
|
|
||||||
@Value("${bitmessage.port}")
|
@Value("${bitmessage.port}")
|
||||||
@ -46,9 +52,16 @@ public class JabitServerConfig {
|
|||||||
@Value("${bitmessage.connection.limit}")
|
@Value("${bitmessage.connection.limit}")
|
||||||
private int connectionLimit;
|
private int connectionLimit;
|
||||||
|
|
||||||
|
@Value("${database.url}")
|
||||||
|
private String dbUrl;
|
||||||
|
@Value("${database.user}")
|
||||||
|
private String dbUser;
|
||||||
|
@Value("${database.password}")
|
||||||
|
private String dbPassword;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public JdbcConfig jdbcConfig() {
|
public JdbcConfig jdbcConfig() {
|
||||||
return new JdbcConfig("jdbc:h2:file:./jabit;AUTO_SERVER=TRUE;DB_CLOSE_DELAY=10", "sa", null);
|
return new JdbcConfig(dbUrl, dbUser, dbPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ -73,17 +86,17 @@ public class JabitServerConfig {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public NodeRegistry nodeRegistry() {
|
public NodeRegistry nodeRegistry() {
|
||||||
return new MemoryNodeRegistry();
|
return new JdbcNodeRegistry(jdbcConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public NetworkHandler networkHandler() {
|
public NetworkHandler networkHandler() {
|
||||||
return new DefaultNetworkHandler();
|
return new NioNetworkHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Cryptography cryptography() {
|
public Cryptography cryptography() {
|
||||||
BouncyCryptography cryptography = new BouncyCryptography();
|
Cryptography cryptography = new SpongyCryptography();
|
||||||
Singleton.initialize(cryptography); // needed for admins and clients
|
Singleton.initialize(cryptography); // needed for admins and clients
|
||||||
return cryptography;
|
return cryptography;
|
||||||
}
|
}
|
||||||
@ -97,6 +110,7 @@ public class JabitServerConfig {
|
|||||||
public ServerProofOfWorkRepository serverProofOfWorkRepository() {
|
public ServerProofOfWorkRepository serverProofOfWorkRepository() {
|
||||||
return new ServerProofOfWorkRepository(jdbcConfig());
|
return new ServerProofOfWorkRepository(jdbcConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public CustomCommandHandler commandHandler() {
|
public CustomCommandHandler commandHandler() {
|
||||||
return new ProofOfWorkRequestHandler(serverProofOfWorkRepository(), clients());
|
return new ProofOfWorkRequestHandler(serverProofOfWorkRepository(), clients());
|
||||||
@ -173,4 +187,23 @@ public class JabitServerConfig {
|
|||||||
.select()
|
.select()
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public BitmessageAddress identity() {
|
||||||
|
List<BitmessageAddress> identities = bitmessageContext().addresses().getIdentities();
|
||||||
|
BitmessageAddress identity;
|
||||||
|
if (identities.isEmpty()) {
|
||||||
|
LOG.info("Creating new identity...");
|
||||||
|
identity = bitmessageContext().createIdentity(false, Pubkey.Feature.DOES_ACK);
|
||||||
|
LOG.info("Identity " + identity.getAddress() + " created.");
|
||||||
|
} else {
|
||||||
|
LOG.info("Identities:");
|
||||||
|
identities.stream().map(BitmessageAddress::getAddress).forEach(LOG::info);
|
||||||
|
identity = identities.get(0);
|
||||||
|
if (identities.size() > 1) {
|
||||||
|
LOG.info("Using " + identity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return identity;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,8 +131,8 @@ public class ProofOfWorkRequestHandler implements CustomCommandHandler, Internal
|
|||||||
final BitmessageAddress identity = new BitmessageAddress(new PrivateKey(
|
final BitmessageAddress identity = new BitmessageAddress(new PrivateKey(
|
||||||
false,
|
false,
|
||||||
context.getStreams()[0],
|
context.getStreams()[0],
|
||||||
context.getNetworkNonceTrialsPerByte(),
|
InternalContext.NETWORK_NONCE_TRIALS_PER_BYTE,
|
||||||
context.getNetworkExtraBytes()
|
InternalContext.NETWORK_EXTRA_BYTES
|
||||||
));
|
));
|
||||||
context.getAddressRepository().save(identity);
|
context.getAddressRepository().save(identity);
|
||||||
return identity;
|
return identity;
|
||||||
|
@ -4,3 +4,6 @@ logging.level.ch.dissem.*=WARN
|
|||||||
bitmessage.port=8444
|
bitmessage.port=8444
|
||||||
bitmessage.connection.ttl.hours=12
|
bitmessage.connection.ttl.hours=12
|
||||||
bitmessage.connection.limit=100
|
bitmessage.connection.limit=100
|
||||||
|
database.url=jdbc:h2:file:./jabit;AUTO_SERVER=TRUE;DB_CLOSE_DELAY=10
|
||||||
|
database.user=sa
|
||||||
|
database.password=
|
Loading…
Reference in New Issue
Block a user