From 1382ca3d9fca7e8f8d7e030b69f179fa765e80d7 Mon Sep 17 00:00:00 2001 From: Jerome Gravel-Niquet Date: Fri, 19 Oct 2018 11:49:00 -0400 Subject: [PATCH] let's do separated fbs again --- .travis.yml | 2 +- build.rs | 24 +------- msg.fbs | 157 +----------------------------------------------- scripts/fbs.sh | 6 ++ src/ops/dns.fbs | 154 +++++++++++++++++++++++++++++++++++++++++++++++ src/ops/dns.rs | 2 +- 6 files changed, 165 insertions(+), 180 deletions(-) create mode 100755 scripts/fbs.sh create mode 100644 src/ops/dns.fbs diff --git a/.travis.yml b/.travis.yml index 113102f..6ed9010 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/build.rs b/build.rs index 2160a56..65f2b3c 100644 --- a/build.rs +++ b/build.rs @@ -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(); } diff --git a/msg.fbs b/msg.fbs index efdfd10..1261dad 100644 --- a/msg.fbs +++ b/msg.fbs @@ -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; \ No newline at end of file diff --git a/scripts/fbs.sh b/scripts/fbs.sh new file mode 100755 index 0000000..af9c512 --- /dev/null +++ b/scripts/fbs.sh @@ -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 \ No newline at end of file diff --git a/src/ops/dns.fbs b/src/ops/dns.fbs new file mode 100644 index 0000000..eda6795 --- /dev/null +++ b/src/ops/dns.fbs @@ -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]; +} \ No newline at end of file diff --git a/src/ops/dns.rs b/src/ops/dns.rs index 2a6e351..5386b41 100644 --- a/src/ops/dns.rs +++ b/src/ops/dns.rs @@ -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};