Distributable JAR build
- connection manager should now be rock stable - does try to create new connections as long as there are less than eight active connections, which might result in more than eight outgoing connections, but this shouldn't be a problem - some minor improvements and bug fixes
This commit is contained in:
parent
1dc4582012
commit
6be8d51f6d
@ -1,4 +1,10 @@
|
|||||||
apply plugin: 'java'
|
plugins {
|
||||||
|
id "us.kirchmeier.capsule" version "1.0-rc1"
|
||||||
|
}
|
||||||
|
|
||||||
|
task fatCapsule(type: FatCapsule) {
|
||||||
|
applicationClass 'ch.dissem.bitmessage.demo.Main'
|
||||||
|
}
|
||||||
|
|
||||||
sourceCompatibility = 1.7
|
sourceCompatibility = 1.7
|
||||||
version = '0.0.1'
|
version = '0.0.1'
|
||||||
|
@ -20,8 +20,11 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "DEBUG");
|
if (System.getProperty("org.slf4j.simpleLogger.defaultLogLevel") == null)
|
||||||
|
System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "ERROR");
|
||||||
|
if (System.getProperty("org.slf4j.simpleLogger.logFile") == null)
|
||||||
System.setProperty("org.slf4j.simpleLogger.logFile", "./jabit.log");
|
System.setProperty("org.slf4j.simpleLogger.logFile", "./jabit.log");
|
||||||
|
|
||||||
new Application();
|
new Application();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import ch.dissem.bitmessage.entity.ObjectMessage;
|
|||||||
import ch.dissem.bitmessage.entity.Plaintext;
|
import ch.dissem.bitmessage.entity.Plaintext;
|
||||||
import ch.dissem.bitmessage.entity.payload.*;
|
import ch.dissem.bitmessage.entity.payload.*;
|
||||||
import ch.dissem.bitmessage.entity.payload.Pubkey.Feature;
|
import ch.dissem.bitmessage.entity.payload.Pubkey.Feature;
|
||||||
|
import ch.dissem.bitmessage.entity.valueobject.Label;
|
||||||
import ch.dissem.bitmessage.entity.valueobject.PrivateKey;
|
import ch.dissem.bitmessage.entity.valueobject.PrivateKey;
|
||||||
import ch.dissem.bitmessage.exception.DecryptionFailedException;
|
import ch.dissem.bitmessage.exception.DecryptionFailedException;
|
||||||
import ch.dissem.bitmessage.factory.Factory;
|
import ch.dissem.bitmessage.factory.Factory;
|
||||||
@ -114,6 +115,7 @@ public class BitmessageContext {
|
|||||||
0
|
0
|
||||||
);
|
);
|
||||||
msg.setStatus(SENT);
|
msg.setStatus(SENT);
|
||||||
|
msg.addLabels(ctx.getMessageRepository().getLabels(Label.Type.BROADCAST, Label.Type.SENT));
|
||||||
ctx.getMessageRepository().save(msg);
|
ctx.getMessageRepository().save(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,6 +150,7 @@ public class BitmessageContext {
|
|||||||
ctx.getExtraBytes(to)
|
ctx.getExtraBytes(to)
|
||||||
);
|
);
|
||||||
msg.setStatus(SENT);
|
msg.setStatus(SENT);
|
||||||
|
msg.addLabels(ctx.getMessageRepository().getLabels(Label.Type.SENT));
|
||||||
ctx.getMessageRepository().save(msg);
|
ctx.getMessageRepository().save(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ class DefaultMessageListener implements NetworkHandler.MessageListener {
|
|||||||
LOG.warn("Broadcast with IV " + object.getInventoryVector() + " was successfully decrypted, but signature check failed. Ignoring.");
|
LOG.warn("Broadcast with IV " + object.getInventoryVector() + " was successfully decrypted, but signature check failed. Ignoring.");
|
||||||
} else {
|
} else {
|
||||||
broadcast.getPlaintext().setStatus(RECEIVED);
|
broadcast.getPlaintext().setStatus(RECEIVED);
|
||||||
broadcast.getPlaintext().addLabels(ctx.getMessageRepository().getLabels(Label.Type.INBOX, Label.Type.UNREAD));
|
broadcast.getPlaintext().addLabels(ctx.getMessageRepository().getLabels(Label.Type.INBOX, Label.Type.BROADCAST, Label.Type.UNREAD));
|
||||||
broadcast.getPlaintext().setInventoryVector(object.getInventoryVector());
|
broadcast.getPlaintext().setInventoryVector(object.getInventoryVector());
|
||||||
ctx.getMessageRepository().save(broadcast.getPlaintext());
|
ctx.getMessageRepository().save(broadcast.getPlaintext());
|
||||||
listener.receive(broadcast.getPlaintext());
|
listener.receive(broadcast.getPlaintext());
|
||||||
|
@ -73,7 +73,8 @@ public class Label {
|
|||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
INBOX,
|
INBOX,
|
||||||
DRAFTS,
|
BROADCAST,
|
||||||
|
DRAFT,
|
||||||
SENT,
|
SENT,
|
||||||
UNREAD,
|
UNREAD,
|
||||||
TRASH
|
TRASH
|
||||||
|
@ -9,7 +9,6 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':domain')
|
compile project(':domain')
|
||||||
compile 'com.google.guava:guava-concurrent:r03'
|
|
||||||
testCompile 'org.slf4j:slf4j-simple:1.7.12'
|
testCompile 'org.slf4j:slf4j-simple:1.7.12'
|
||||||
testCompile 'junit:junit:4.11'
|
testCompile 'junit:junit:4.11'
|
||||||
}
|
}
|
@ -82,6 +82,7 @@ public class NetworkNode implements NetworkHandler, ContextHolder {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
while (!Thread.interrupted()) {
|
while (!Thread.interrupted()) {
|
||||||
|
try {
|
||||||
int active = 0;
|
int active = 0;
|
||||||
synchronized (connections) {
|
synchronized (connections) {
|
||||||
for (Iterator<Connection> iterator = connections.iterator(); iterator.hasNext(); ) {
|
for (Iterator<Connection> iterator = connections.iterator(); iterator.hasNext(); ) {
|
||||||
@ -101,13 +102,14 @@ public class NetworkNode implements NetworkHandler, ContextHolder {
|
|||||||
startConnection(new Connection(ctx, CLIENT, address, listener));
|
startConnection(new Connection(ctx, CLIENT, address, listener));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
Thread.sleep(30000);
|
Thread.sleep(30000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
LOG.debug(e.getMessage(), e);
|
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("Error in connection manager. Ignored.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LOG.debug("Connection manager shutting down.");
|
||||||
}
|
}
|
||||||
}, "connection-manager");
|
}, "connection-manager");
|
||||||
connectionManager.start();
|
connectionManager.start();
|
||||||
|
@ -67,7 +67,7 @@ public class JdbcMessageRepositoryTest {
|
|||||||
addressRepo.save(identity);
|
addressRepo.save(identity);
|
||||||
|
|
||||||
inbox = repo.getLabels(Label.Type.INBOX).get(0);
|
inbox = repo.getLabels(Label.Type.INBOX).get(0);
|
||||||
drafts = repo.getLabels(Label.Type.DRAFTS).get(0);
|
drafts = repo.getLabels(Label.Type.DRAFT).get(0);
|
||||||
|
|
||||||
addMessage(contactA, identity, Plaintext.Status.RECEIVED, inbox);
|
addMessage(contactA, identity, Plaintext.Status.RECEIVED, inbox);
|
||||||
addMessage(identity, contactA, Plaintext.Status.DRAFT, drafts);
|
addMessage(identity, contactA, Plaintext.Status.DRAFT, drafts);
|
||||||
|
Loading…
Reference in New Issue
Block a user