Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

Commit

Permalink
let's do separated fbs again
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegn committed Oct 19, 2018
1 parent d103f2f commit 1382ca3
Showing 6 changed files with 165 additions and 180 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ install:
cd $TRAVIS_BUILD_DIR
- |
export PATH=$PATH:$TRAVIS_BUILD_DIR/third_party/flatbuffers/
flatc --ts -o v8env/src --no-fb-import --gen-mutable msg.fbs
./scripts/fbs.sh
- |
nvm install 10
npm i -g yarn
24 changes: 1 addition & 23 deletions build.rs
Original file line number Diff line number Diff line change
@@ -4,27 +4,5 @@ use std::process::Command;
fn main() {
let crate_root = env::var("CARGO_MANIFEST_DIR").unwrap();

println!("cargo:rerun-if-changed=msg.fbs");

Command::new("flatc")
.arg("--rust")
.arg("-I")
.arg(format!("{}/src/ops", crate_root))
.arg("-o")
.arg(format!("{}/src", crate_root))
.arg(format!("{}/msg.fbs", crate_root))
.spawn()
.unwrap();

Command::new("flatc")
.arg("--ts")
.arg("--no-fb-import")
.arg("--gen-mutable")
.arg("-I")
.arg(format!("{}/src/ops", crate_root))
.arg("-o")
.arg(format!("{}/v8env/src", crate_root))
.arg(format!("{}/msg.fbs", crate_root))
.spawn()
.unwrap();
Command::new("./scripts/fbs.sh").spawn().unwrap();
}
157 changes: 2 additions & 155 deletions msg.fbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include "src/ops/dns.fbs";

union Any {
TimerStart,
TimerReady,
@@ -211,159 +213,4 @@ table DataDropCollection {
collection: string;
}

enum DnsRecordType: byte {
A = 0,
AAAA,
ANY,
AXFR,
CAA,
CNAME,
IXFR,
MX,
NS,
NULL,
OPT,
PTR,
SOA,
SRV,
TLSA,
TXT,
}

enum DnsResponseCode: byte {
NoError = 0,
FormErr,
ServFail,
NXDomain,
NotImp,
Refused,
YXDomain,
YXRRSet,
NXRRSet,
NotAuth,
NotZone,
BADVERS,
BADSIG,
BADKEY,
BADTIME,
BADMODE,
BADNAME,
BADALG,
BADTRUNC,
BADCOOKIE,
}

enum DnsOpCode: byte {
Query = 0,
Status,
Notify,
Update,
}

enum DnsMessageType: byte {
Query = 0,
Response,
}

enum DnsClass: byte {
IN = 0,
CH,
HS,
NONE,
ANY,
// OPT(u16) ?
}

union DnsRecordData {
DnsA,
DnsAaaa,
// DnsCAA,
DnsCname,
DnsMx,
// DnsNULL,
DnsNs,
// DnsOPT,
DnsPtr,
DnsSoa,
DnsSrv,
// DnsTLSA,
DnsTxt,
// TODO: more.
}

table DnsA {
ip: string;
}
table DnsAaaa {
ip: string;
}

table DnsCname {
name: string;
}
table DnsMx {
preference: ushort;
exchange: string;
}
table DnsNs {
name: string;
}
table DnsPtr {
name: string;
}
table DnsSoa {
mname: string;
rname: string;
serial: uint;
refresh: int;
retry: int;
expire: int;
minimum: uint;
}
table DnsSrv {
priority: ushort;
weight: ushort;
port: ushort;
target: string;
}

table DnsTxtData {
data: [ubyte];
}

table DnsTxt {
data: [DnsTxtData];
}

table DnsRequest {
id: uint;
message_type: DnsMessageType;
queries: [DnsQuery];
}

table DnsQuery {
name: string;
rr_type: DnsRecordType;
dns_class: DnsClass;
}

table DnsRecord {
name: string;
rr_type: DnsRecordType;
rdata: DnsRecordData;
dns_class: DnsClass;
ttl: uint;
}

table DnsResponse {
id: uint;
op_code: DnsOpCode;
message_type: DnsMessageType;
authoritative: bool;
truncated: bool;
response_code: DnsResponseCode;
answers: [DnsRecord];
queries: [DnsQuery];
}

root_type Base;
6 changes: 6 additions & 0 deletions scripts/fbs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

set -e

flatc --rust -o src --gen-all msg.fbs
flatc --ts -o v8env/src --no-fb-import --gen-mutable --no-ts-reexport --gen-all msg.fbs
154 changes: 154 additions & 0 deletions src/ops/dns.fbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
enum DnsRecordType: byte {
A = 0,
AAAA,
ANY,
AXFR,
CAA,
CNAME,
IXFR,
MX,
NS,
NULL,
OPT,
PTR,
SOA,
SRV,
TLSA,
TXT,
}

enum DnsResponseCode: byte {
NoError = 0,
FormErr,
ServFail,
NXDomain,
NotImp,
Refused,
YXDomain,
YXRRSet,
NXRRSet,
NotAuth,
NotZone,
BADVERS,
BADSIG,
BADKEY,
BADTIME,
BADMODE,
BADNAME,
BADALG,
BADTRUNC,
BADCOOKIE,
}

enum DnsOpCode: byte {
Query = 0,
Status,
Notify,
Update,
}

enum DnsMessageType: byte {
Query = 0,
Response,
}

enum DnsClass: byte {
IN = 0,
CH,
HS,
NONE,
ANY,
// OPT(u16) ?
}

union DnsRecordData {
DnsA,
DnsAaaa,
// DnsCAA,
DnsCname,
DnsMx,
// DnsNULL,
DnsNs,
// DnsOPT,
DnsPtr,
DnsSoa,
DnsSrv,
// DnsTLSA,
DnsTxt,
// TODO: more.
}

table DnsA {
ip: string;
}
table DnsAaaa {
ip: string;
}

table DnsCname {
name: string;
}
table DnsMx {
preference: ushort;
exchange: string;
}
table DnsNs {
name: string;
}
table DnsPtr {
name: string;
}
table DnsSoa {
mname: string;
rname: string;
serial: uint;
refresh: int;
retry: int;
expire: int;
minimum: uint;
}
table DnsSrv {
priority: ushort;
weight: ushort;
port: ushort;
target: string;
}

table DnsTxtData {
data: [ubyte];
}

table DnsTxt {
data: [DnsTxtData];
}

table DnsRequest {
id: uint;
message_type: DnsMessageType;
queries: [DnsQuery];
}

table DnsQuery {
name: string;
rr_type: DnsRecordType;
dns_class: DnsClass;
}

table DnsRecord {
name: string;
rr_type: DnsRecordType;
rdata: DnsRecordData;
dns_class: DnsClass;
ttl: uint;
}

table DnsResponse {
id: uint;
op_code: DnsOpCode;
message_type: DnsMessageType;
authoritative: bool;
truncated: bool;
response_code: DnsResponseCode;
answers: [DnsRecord];
queries: [DnsQuery];
}
2 changes: 1 addition & 1 deletion src/ops/dns.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ extern crate trust_dns as dns;
extern crate trust_dns_proto as dns_proto;
use self::dns::client::ClientHandle; // necessary for trait to be in scope

use std::sync::{Mutex, RwLock};
use std::sync::Mutex;

use libfly::*;
use runtime::{JsRuntime, Op, EVENT_LOOP_HANDLE};

0 comments on commit 1382ca3

Please sign in to comment.