diff --git a/.gitignore b/.gitignore index 091f723..93ba99d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .gradle .idea build +out *.iml *.ipr *.iws diff --git a/build.gradle b/build.gradle index 7472e07..14239a9 100644 --- a/build.gradle +++ b/build.gradle @@ -54,12 +54,22 @@ dependencies { /*==== You probably don't have to edit below this line =======*/ protobuf { - // Configure the protoc executable - protoc { + // Configure the protoc executable + protoc { // Download from repositories - //artifact = 'com.google.protobuf:protoc:3.0.0-alpha-3' - artifact = 'com.google.protobuf:protoc:3.+' - } + artifact = 'com.google.protobuf:protoc:3.+' + } +} + +idea { + module { + // add protobuf generated sources to generated source dir. + sourceDirs += file(protobuf.generatedFilesBaseDir) + generatedSourceDirs += file(protobuf.generatedFilesBaseDir) + + // Don't exclude build directory + excludeDirs -= file(buildDir) + } } // Used to generate initial maven-dir layout diff --git a/src/main/java/Demo.java b/src/main/java/Demo.java index 1a84326..879501f 100644 --- a/src/main/java/Demo.java +++ b/src/main/java/Demo.java @@ -1,8 +1,33 @@ +import com.google.protobuf.ByteString; +import meerkat.bulletinboard.BulletinBoard; +import meerkat.comm.BulletinBoardMessageProtos; + +import java.io.IOException; + +import static meerkat.comm.BulletinBoardMessageProtos.*; + /** * Created by talm on 10/26/15. */ public class Demo { - static void main(String args[]) { + public static void main(String args[]) { System.out.println("Nothing to see yet"); + + BulletinBoardMessage msg; + + BulletinBoardMessage.Unsigned msgContents = BulletinBoardMessage.Unsigned.newBuilder() + .addTags("test") + .setData(ByteString.copyFromUtf8("some data")) + .build(); + + msg = BulletinBoardMessage.newBuilder() + .setMsg(msgContents) + .build(); + + try { + msg.writeTo(System.err); + } catch (IOException e) { + // Ignore + } } } diff --git a/src/main/proto/meerkat/comm/BulletinBoardMessage.proto b/src/main/proto/meerkat/comm/BulletinBoardMessage.proto deleted file mode 100644 index 0c6f4b1..0000000 --- a/src/main/proto/meerkat/comm/BulletinBoardMessage.proto +++ /dev/null @@ -1,6 +0,0 @@ -package meerkat.comm; - -message BulleinBoardMessage { - repeated int32 tags = 1; -} - diff --git a/src/main/proto/meerkat/comm/bulletin_board_message.proto b/src/main/proto/meerkat/comm/bulletin_board_message.proto new file mode 100644 index 0000000..35163c0 --- /dev/null +++ b/src/main/proto/meerkat/comm/bulletin_board_message.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; + +package meerkat.comm; + +import 'meerkat/crypto/signature.proto'; + +option java_outer_classname = "BulletinBoardMessageProtos"; + +message BulletinBoardMessage { + message Unsigned { + // Optional tags describing message + repeated string tags = 1; + + // The actual content of the message + bytes data = 2; + } + + Unsigned msg = 1; + + // Signature of message (and tags) + meerkat.crypto.Signature sig = 2; +} + diff --git a/src/main/proto/meerkat/crypto/signature.proto b/src/main/proto/meerkat/crypto/signature.proto new file mode 100644 index 0000000..61df002 --- /dev/null +++ b/src/main/proto/meerkat/crypto/signature.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; + +package meerkat.crypto; + +option java_outer_classname = "SignatureProtos"; + +message Signature { + enum Type { + ECDSA = 0; + DSA = 1; + } + Type type = 1; + + bytes data = 2; +}