dat-daemon-protocol

Dat daemon protocol buffer

Usage no npm install needed!

<script type="module">
  import datDaemonProtocol from 'https://cdn.skypack.dev/dat-daemon-protocol';
</script>

README

/**
 * Protocol buffers (https://github.com/mafintosh/protocol-buffers) for dat-daemon
 * Instruction to give to the daemon
 */
message Instruction {
  enum Action {
    ADD = 0;
    REMOVE = 1;
    START = 2;
    PAUSE = 3;
    STATISTICS = 4;
    LIST = 5;
  }

  required Action action = 1;
  optional string key = 2;
  optional string directory = 3;
  optional Options options = 4;
}

message Options {
  optional bool sparse = 1 [default = false];
  // Network options
  optional bool upload = 2 [default = true];
  optional bool download = 3 [default = true];
  optional int32 port = 4;
  optional bool utp = 5 [default = true];
  optional bool tcp = 6 [default = true];
  optional bool importFiles = 7 [default = false];
  // Missing: watch, version, exit see https://github.com/soyuka/dat-daemon/pull/6
}

/**
 * Answer given after processing an Instruction
 */
message Answer {
  required string message = 1;
  optional Statistics statistics = 2;
  optional int32 failure = 3 [default = 0];
}

/**
 * When the Instruction was Statistics, you'll get this
 */
message Statistics {
  required int64 files = 1;
  required int64 connected = 2;
  required int64 byteLength = 3;
  required int64 version = 4;
  required float downloadSpeed = 5;
  required float uploadSpeed = 6;
  required float totalPeers = 7;
  required float completePeers = 8;
}

/**
 * Internal storage of the List in leveldb
 */
message Dat {
  required string key = 1;
  required string directory = 2;
  optional Options options = 3;
}

message List {
  repeated Dat list = 1;
}