diff options
| author | Max Audron <audron@cocaine.farm> | 2021-01-04 18:38:31 +0100 |
|---|---|---|
| committer | Max Audron <audron@cocaine.farm> | 2021-01-04 18:38:31 +0100 |
| commit | 0b7c6cf0b129799110d3ef0118e1f2b5697a2068 (patch) | |
| tree | 9bbb49c7af7feb6fc1aff497e0d577fe31ef11ed | |
| parent | WIP: function api (diff) | |
| parent | add example program: quasselproxy (diff) | |
Merge branch 'client'
Diffstat (limited to '')
40 files changed, 1379 insertions, 2133 deletions
@@ -1,2 +1,4 @@ +Cargo.lock /target **/*.rs.bk +examples/testserver diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index dc9844f..0000000 --- a/Cargo.lock +++ /dev/null @@ -1,1229 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "adler32" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "aho-corasick" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "arc-swap" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "async-trait" -version = "0.1.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "hermit-abi 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "autocfg" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "backtrace" -version = "0.3.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "backtrace-sys 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "backtrace-sys" -version = "0.1.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.52 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "base-x" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "bitflags" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "bumpalo" -version = "3.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "byteorder" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "bytes" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "bytes" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "cc" -version = "1.0.52" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "core-foundation" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "core-foundation-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "core-foundation-sys" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "crc32fast" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "discard" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "either" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "env_logger" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "failure" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "backtrace 0.3.46 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "failure_derive" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "flate2" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "fnv" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "futures" -version = "0.1.29" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "futures" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-channel 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-executor 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-io 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-task 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-channel" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-core 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-core" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "futures-executor" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-core 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-task 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-io" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "futures-macro" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro-hack 0.5.15 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-sink" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "futures-task" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "futures-util" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-channel 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-io 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-macro 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-task 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-hack 0.5.15 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-nested 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "getrandom" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", - "wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "hermit-abi" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "iovec" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "itoa" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "libc" -version = "0.2.69" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "libquassel" -version = "0.1.0" -dependencies = [ - "async-trait 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "native-tls 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "pretty_env_logger 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-test 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-tls 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "log" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "memchr" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "miniz_oxide" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "mio" -version = "0.6.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "mio-named-pipes" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", - "miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "mio-uds" -version = "0.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "miow" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "miow" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "socket2 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "native-tls" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.10.29 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.55 (registry+https://github.com/rust-lang/crates.io-index)", - "schannel 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", - "security-framework 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "security-framework-sys 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "net2" -version = "0.2.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "num_cpus" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "hermit-abi 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "openssl" -version = "0.10.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.55 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "openssl-probe" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "openssl-sys" -version = "0.9.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.52 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "pin-project-lite" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "pkg-config" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "ppv-lite86" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "pretty_env_logger" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "proc-macro-hack" -version = "0.5.15" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "proc-macro-nested" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "proc-macro2" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "quote" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "redox_syscall" -version = "0.1.56" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "regex" -version = "1.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "aho-corasick 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.17 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "regex-syntax" -version = "0.6.17" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "remove_dir_all" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "ryu" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "schannel" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "security-framework" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "core-foundation 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "core-foundation-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", - "security-framework-sys 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "security-framework-sys" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "core-foundation-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "serde" -version = "1.0.106" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "serde_derive" -version = "1.0.106" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_json" -version = "1.0.52" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "sha1" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "signal-hook-registry" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "arc-swap 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "slab" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "socket2" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "standback" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "stdweb" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-derive 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-internal-macros 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-internal-runtime 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-derive" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-internal-macros" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "base-x 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.52 (registry+https://github.com/rust-lang/crates.io-index)", - "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-internal-runtime" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "syn" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "synstructure" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tempfile" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", - "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "termcolor" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "thread_local" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "time" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", - "standback 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "time-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "time-macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro-hack 0.5.15 (registry+https://github.com/rust-lang/crates.io-index)", - "time-macros-impl 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "time-macros-impl" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro-hack 0.5.15 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "standback 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", - "mio-named-pipes 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-project-lite 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "signal-hook-registry 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-macros 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-io" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-macros" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-test" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-tls" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "native-tls 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "tokio-util" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-project-lite 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "unicode-xid" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "vcpkg" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "version_check" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "wasm-bindgen" -version = "0.2.62" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.62" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bumpalo 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.62" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro-support 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.62" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.62" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "ws2_32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[metadata] -"checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" -"checksum aho-corasick 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)" = "8716408b8bc624ed7f65d223ddb9ac2d044c0547b6fa4b0d554f3a9540496ada" -"checksum arc-swap 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b585a98a234c46fc563103e9278c9391fde1f4e6850334da895d27edb9580f62" -"checksum async-trait 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)" = "da71fef07bc806586090247e971229289f64c210a278ee5ae419314eb386b31d" -"checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -"checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" -"checksum backtrace 0.3.46 (registry+https://github.com/rust-lang/crates.io-index)" = "b1e692897359247cc6bb902933361652380af0f1b7651ae5c5013407f30e109e" -"checksum backtrace-sys 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "78848718ee1255a2485d1309ad9cdecfc2e7d0362dd11c6829364c6b35ae1bc7" -"checksum base-x 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1b20b618342cf9891c292c4f5ac2cde7287cc5c87e87e9c769d617793607dec1" -"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -"checksum bumpalo 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "12ae9db68ad7fac5fe51304d20f016c911539251075a214f8e663babefa35187" -"checksum byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" -"checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -"checksum bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1" -"checksum cc 1.0.52 (registry+https://github.com/rust-lang/crates.io-index)" = "c3d87b23d6a92cd03af510a5ade527033f6aa6fa92161e2d5863a907d4c5e31d" -"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum core-foundation 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" -"checksum core-foundation-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" -"checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" -"checksum discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" -"checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" -"checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" -"checksum failure 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b8529c2421efa3066a5cbd8063d2244603824daccb6936b079010bb2aa89464b" -"checksum failure_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "030a733c8287d6213886dd487564ff5c8f6aae10278b3588ed177f9d18f8d231" -"checksum flate2 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "2cfff41391129e0a856d6d822600b8d71179d46879e310417eb9c762eb178b42" -"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" -"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" -"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" -"checksum futures 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5c329ae8753502fb44ae4fc2b622fa2a94652c41e795143765ba0927f92ab780" -"checksum futures-channel 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0c77d04ce8edd9cb903932b608268b3fffec4163dc053b3b402bf47eac1f1a8" -"checksum futures-core 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f25592f769825e89b92358db00d26f965761e094951ac44d3663ef25b7ac464a" -"checksum futures-executor 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f674f3e1bcb15b37284a90cedf55afdba482ab061c407a9c0ebbd0f3109741ba" -"checksum futures-io 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a638959aa96152c7a4cddf50fcb1e3fede0583b27157c26e67d6f99904090dc6" -"checksum futures-macro 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9a5081aa3de1f7542a794a397cde100ed903b0630152d0973479018fd85423a7" -"checksum futures-sink 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3466821b4bc114d95b087b850a724c6f83115e929bc88f1fa98a3304a944c8a6" -"checksum futures-task 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7b0a34e53cf6cdcd0178aa573aed466b646eb3db769570841fda0c7ede375a27" -"checksum futures-util 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "22766cf25d64306bedf0384da004d05c9974ab104fcc4528f1236181c18004c5" -"checksum getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" -"checksum hermit-abi 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8a0d737e0f947a1864e93d33fdef4af8445a00d1ed8dc0c8ddb73139ea6abf15" -"checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -"checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -"checksum itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" -"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -"checksum libc 0.2.69 (registry+https://github.com/rust-lang/crates.io-index)" = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005" -"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -"checksum memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" -"checksum miniz_oxide 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "aa679ff6578b1cddee93d7e82e263b94a575e0bfced07284eb0c037c1d2416a5" -"checksum mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)" = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f" -"checksum mio-named-pipes 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f5e374eff525ce1c5b7687c4cef63943e7686524a387933ad27ca7ec43779cb3" -"checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" -"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" -"checksum miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "396aa0f2003d7df8395cb93e09871561ccc3e785f0acb369170e8cc74ddf9226" -"checksum native-tls 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "2b0d88c06fe90d5ee94048ba40409ef1d9315d86f6f38c2efdaad4fb50c58b2d" -"checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" -"checksum num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" -"checksum openssl 0.10.29 (registry+https://github.com/rust-lang/crates.io-index)" = "cee6d85f4cb4c4f59a6a85d5b68a233d280c82e29e822913b9c8b129fbf20bdd" -"checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" -"checksum openssl-sys 0.9.55 (registry+https://github.com/rust-lang/crates.io-index)" = "7717097d810a0f2e2323f9e5d11e71608355e24828410b55b9d4f18aa5f9a5d8" -"checksum pin-project-lite 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "237844750cfbb86f67afe27eee600dfbbcb6188d734139b534cbfbf4f96792ae" -"checksum pin-utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -"checksum pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" -"checksum ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" -"checksum pretty_env_logger 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "926d36b9553851b8b0005f1275891b392ee4d2d833852c417ed025477350fb9d" -"checksum proc-macro-hack 0.5.15 (registry+https://github.com/rust-lang/crates.io-index)" = "0d659fe7c6d27f25e9d80a1a094c223f5246f6a6596453e09d7229bf42750b63" -"checksum proc-macro-nested 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8e946095f9d3ed29ec38de908c22f95d9ac008e424c7bcae54c75a79c527c694" -"checksum proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)" = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3" -"checksum quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" -"checksum quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" -"checksum rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -"checksum rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" -"checksum regex 1.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a6020f034922e3194c711b82a627453881bc4682166cabb07134a10c26ba7692" -"checksum regex-syntax 0.6.17 (registry+https://github.com/rust-lang/crates.io-index)" = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae" -"checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" -"checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" -"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum ryu 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ed3d612bc64430efeb3f7ee6ef26d590dce0c43249217bddc62112540c7941e1" -"checksum schannel 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "039c25b130bd8c1321ee2d7de7fde2659fa9c2744e4bb29711cfc852ea53cd19" -"checksum security-framework 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3f331b9025654145cd425b9ded0caf8f5ae0df80d418b326e2dc1c3dc5eb0620" -"checksum security-framework-sys 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "17bf11d99252f512695eb468de5516e5cf75455521e69dfe343f3b74e4748405" -"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)" = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399" -"checksum serde_derive 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)" = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c" -"checksum serde_json 1.0.52 (registry+https://github.com/rust-lang/crates.io-index)" = "a7894c8ed05b7a3a279aeb79025fdec1d3158080b75b98a08faf2806bb799edd" -"checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" -"checksum signal-hook-registry 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41" -"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" -"checksum socket2 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)" = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918" -"checksum standback 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "47e4b8c631c998468961a9ea159f064c5c8499b95b5e4a34b77849d45949d540" -"checksum stdweb 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" -"checksum stdweb-derive 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" -"checksum stdweb-internal-macros 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" -"checksum stdweb-internal-runtime 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" -"checksum syn 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "410a7488c0a728c7ceb4ad59b9567eb4053d02e8cc7f5c0e0eeeb39518369213" -"checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" -"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" -"checksum termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" -"checksum thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" -"checksum time 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "a6b5580a7510e7f3c6f199c1cd448515063f7056f026fe42e930c11d97c83e83" -"checksum time-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9ae9b6e9f095bc105e183e3cd493d72579be3181ad4004fceb01adbe9eecab2d" -"checksum time-macros-impl 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e5c3be1edfad6027c69f5491cf4cb310d1a71ecd6af742788c6ff8bced86b8fa" -"checksum tokio 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)" = "7d9c43f1bb96970e153bcbae39a65e249ccb942bd9d36dbdf086024920417c9c" -"checksum tokio-io 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" -"checksum tokio-macros 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f0c3acc6aa564495a0f2e1d59fab677cd7f81a19994cfc7f3ad0e64301560389" -"checksum tokio-test 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ed0049c119b6d505c4447f5c64873636c7af6c75ab0d45fd9f618d82acb8016d" -"checksum tokio-tls 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7bde02a3a5291395f59b06ec6945a3077602fac2b07eeeaf0dee2122f3619828" -"checksum tokio-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "571da51182ec208780505a32528fc5512a8fe1443ab960b3f2f3ef093cd16930" -"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" -"checksum vcpkg 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3fc439f2794e98976c88a2a2dafce96b930fe8010b0a256b3c2199a773933168" -"checksum version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" -"checksum wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" -"checksum wasm-bindgen 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "e3c7d40d09cdbf0f4895ae58cf57d92e1e57a9dd8ed2e8390514b54a47cc5551" -"checksum wasm-bindgen-backend 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "c3972e137ebf830900db522d6c8fd74d1900dcfc733462e9a12e942b00b4ac94" -"checksum wasm-bindgen-macro 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "2cd85aa2c579e8892442954685f0d801f9129de24fa2136b2c6a539c76b65776" -"checksum wasm-bindgen-macro-support 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "8eb197bd3a47553334907ffd2f16507b4f4f01bbec3ac921a7719e0decdfe72a" -"checksum wasm-bindgen-shared 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "a91c2916119c17a8e316507afaaa2dd94b47646048014bbdf6bef098c1bb58ad" -"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" -"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" -"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" @@ -1,7 +1,11 @@ [package] name = "libquassel" +description = "Native rust implementation of the Quassel protocol and library functions" version = "0.1.0" authors = ["Max Audron <audron@cocaine.farm>"] +license = "ISC" +homepage = "https://gitlab.com/cocainefarm/libquassel" +repository = "https://gitlab.com/cocainefarm/libquassel" edition = "2018" autobins = true @@ -15,29 +19,42 @@ either = "1.5" time = "0.2" async-trait = "0.1" -bytes = { version = "0.5" } +default-macro = { path = "../default-macro" } + +bytes = { version = "1.0" } flate2 = { version = "1.0", features = ["tokio"], optional = true } -tokio = { version = "0.2", features = ["full"], optional = true } -tokio-util = { version = "0.2", features = ["codec"], optional = true } -tokio-tls = { version = "0.3", optional = true } -native-tls = { version = "0.2", optional = true } +tokio = { version = "1.0", features = [], optional = true } +tokio-util = { version = "0.6", features = ["codec"], optional = true } futures-util = { version = "0.3", features = ["std"], optional = true } futures = { version = "0.3", optional = true } -pretty_env_logger = { version = "0.4", optional = true } [features] framing = ["tokio", "tokio-util", "flate2"] -client = ["tokio", "tokio-util", "tokio-tls", "native-tls", "futures", "futures-util", "framing", "pretty_env_logger"] + +# Enable all the quassel features +all-quassel-features = ["long-message-id", "long-time", "rich-messages", "sender-prefixes"] + +# Serialize message IDs as i64 +long-message-id = [] +# Serialize Message Time as i64 +long-time = [] +# Add avatar url and real name to messages +rich-messages = [] +# Show prefixes for senders in backlog +sender-prefixes = [] + default = [] +[package.metadata.docs.rs] +# document all features +all-features = true +# defines the configuration attribute `docsrs` +rustdoc-args = ["--cfg", "docsrs"] + [dev-dependencies] -futures = { version = "0.3" } -flate2 = { version = "1.0", features = ["tokio"] } -tokio = { version = "0.2", features = ["full"] } -tokio-util = { version = "0.2", features = ["codec"] } -tokio-test = { version = "0.2" } - -[[bin]] -name = "quassel-client" -required-features = ["client"] +# futures = { version = "0.3" } +# flate2 = { version = "1.0", features = ["tokio"] } +# tokio = { version = "0.3", features = ["full"] } +# tokio-util = { version = "0.5", features = ["codec"] } +# tokio-test = { version = "0.3" } @@ -0,0 +1,5 @@ +Copyright 2020 Max Audron <audron@cocaine.farm> + +Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..cd5065f --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# libquassel +Native rust implementation of the Quassel protocol and library functions diff --git a/examples/quasselproxy/.gitignore b/examples/quasselproxy/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/examples/quasselproxy/.gitignore @@ -0,0 +1 @@ +/target diff --git a/examples/quasselproxy/Cargo.toml b/examples/quasselproxy/Cargo.toml new file mode 100644 index 0000000..c7d78a8 --- /dev/null +++ b/examples/quasselproxy/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "quasselproxy" +version = "0.1.0" +authors = ["Max Audron <audron@cocaine.farm>"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +tracing = "0.1" +tracing-subscriber = "0.2" +tracing-futures = "0.2" +byteorder = "1.3.2" +failure = "0.1" +either = "1.5" +time = "0.2" +libquassel = { path = "../../", features = ["framing", "all-quassel-features"] } + +bytes = { version = "1.0" } +flate2 = { version = "1.0", features = ["tokio"] } +tokio = { version = "1.0", features = ["full"]} +tokio-util = { version = "0.6", features = ["codec"] } +tokio-rustls = { version = "0.22" } +webpki-roots = { version = "0.21" } +futures-util = { version = "0.3", features = ["std"] } +futures = { version = "0.3" } +log = "*" +pretty_env_logger = { version = "0.4" } diff --git a/examples/quasselproxy/src/main.rs b/examples/quasselproxy/src/main.rs new file mode 100644 index 0000000..16c0fa9 --- /dev/null +++ b/examples/quasselproxy/src/main.rs @@ -0,0 +1,251 @@ +use failure::Error; + +use std::result::Result; +use std::vec::Vec; + +use core::marker::Unpin; +use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}; +use tokio::net::TcpListener; +use tokio::net::TcpStream; +use tokio_util::codec::Framed; + +use futures::{ + stream::{SplitSink, SplitStream}, + SinkExt, StreamExt, +}; + +use libquassel::{ + frame::QuasselCodec, + message::{ConnAck, HandshakeMessage}, +}; + +use log::{debug, error, info, trace}; + +#[tokio::main] +async fn main() -> Result<(), Error> { + pretty_env_logger::init(); + + let host = std::env::args().nth(1).expect("no host given"); + let host: Vec<&str> = host.split(':').collect(); + let username = std::env::args().nth(2).expect("no username given"); + let password = std::env::args().nth(3).expect("no password given"); + + let server = Server::new( + "test", + ServerSettings { + tls: false, + compression: false, + host: host[0].to_string(), + port: host[1].parse().unwrap(), + username, + password, + }, + ); + + // + // Start Server Connection + // + + let mut s_server = + TcpStream::connect(format!("{}:{}", server.settings.host, server.settings.port)).await?; + + info!(target: "init", "Establishing Connection"); + let connack = Server::init( + &mut s_server, + server.settings.tls, + server.settings.compression, + ) + .await?; + + debug!(target: "init", "{:?}", connack); + + let codec = QuasselCodec::builder().compression(false).new_codec(); + let framed = Framed::new(s_server, codec); + let (s_sink, s_stream) = framed.split(); + + // + // Accept first listerner + // + + let listener = TcpListener::bind("0.0.0.0:4243").await.unwrap(); + let (mut client, _) = listener.accept().await.unwrap(); + + // + // Setup Listener + // + + { + let (mut c_stream, mut c_sink) = client.split(); + + let mut init = [0; 12]; + let n = c_stream.peek(&mut init).await.unwrap(); + c_stream.read(&mut init[..n]).await.unwrap(); + let init = libquassel::message::Init::parse(&init); + debug!("{:?}", init); + + c_sink.write(&[0x0, 0x0, 0x0, 0x2]).await.unwrap(); + } + + let codec = QuasselCodec::builder().compression(false).new_codec(); + let framed = Framed::new(client, codec); + let (c_sink, c_stream) = framed.split(); + + // + // Start Processing + // + + let s_state = ClientState::Handshake; + let c_state = ClientState::Handshake; + + tokio::join!( + Server::run(s_stream, c_sink, s_state, "server -> client"), + Server::run(c_stream, s_sink, c_state, "client -> server") + ); + + Ok(()) +} + +#[derive(Clone, Debug)] +pub struct ServerSettings { + pub tls: bool, + pub compression: bool, + pub host: String, + pub port: u32, + pub username: String, + pub password: String, +} + +pub struct Server { + server_name: String, + settings: ServerSettings, +} + +impl std::fmt::Debug for Server { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut fmt = f.debug_struct("Server"); + fmt.field("settings", &self.settings); + fmt.field("name", &self.server_name).finish() + } +} + +#[derive(Clone, Debug)] +pub enum ClientState { + Handshake, + Connected, +} + +impl Server { + fn new(name: &str, settings: ServerSettings) -> Self { + Server { + server_name: name.to_string(), + settings, + } + } + + // Send the initialization message to the stream + async fn init( + stream: &mut (impl AsyncRead + AsyncWrite + Unpin), + tls: bool, + compression: bool, + ) -> Result<ConnAck, Error> { + use libquassel::Deserialize; + + // Buffer for our initialization + let mut init: Vec<u8> = vec![]; + + // The handshake message + let mut handshake: u32 = 0x42b33f00; + + // If TLS is enabled set the TLS bit on the handshake + if tls { + info!(target: "init", "Enabled TLS"); + handshake |= 0x01; + } + + // If COMPRESSION is enabled set the COMPRESSION bit on the handshake + if compression { + info!(target: "init", "Enabled Compression"); + handshake |= 0x02; + } + + // Select Protocol 2: Datastream + let mut proto: u32 = 0x00000002; + + // Flag proto as the last protocol + let fin: u32 = 0x80000000; + proto |= fin; + + // Add handshake and protocol to our buffer + init.extend(handshake.to_be_bytes().iter()); + init.extend(proto.to_be_bytes().iter()); + + // Send Buffer + stream.write(&init).await?; + + // Read Response + let mut buf = [0; 4]; + stream.read(&mut buf).await?; + + let (_, connack) = ConnAck::parse(&buf)?; + Ok(connack) + } + + pub async fn run( + mut stream: SplitStream<Framed<TcpStream, QuasselCodec>>, + mut sink: SplitSink<Framed<TcpStream, QuasselCodec>, Vec<u8>>, + mut state: ClientState, + direction: &str, + ) { + // Start event loop + while let Some(msg) = stream.next().await { + let msg = msg.unwrap(); + sink.send(msg.to_vec()).await.unwrap(); + match state { + ClientState::Handshake => Server::handle_login_message(&msg, &mut state, direction) + .await + .unwrap(), + ClientState::Connected => Server::handle_message(&msg, direction).await.unwrap(), + } + } + } + + #[tracing::instrument] + async fn handle_login_message( + buf: &[u8], + state: &mut ClientState, + direction: &str, + ) -> Result<(), Error> { + use libquassel::HandshakeDeserialize; + + trace!(target: "message", "Received bytes: {:x?}", buf); + match HandshakeMessage::parse(buf) { + Ok((_size, res)) => { + info!("{}: {:#?}", direction, res); + + match res { + HandshakeMessage::SessionInit(_) => *state = ClientState::Connected, + HandshakeMessage::ClientLogin(_) => *state = ClientState::Connected, + _ => {} + } + } + Err(e) => error!("failed to parse handshake message {}", e), + } + + Ok(()) + } + + #[tracing::instrument] + async fn handle_message(buf: &[u8], direction: &str) -> Result<(), Error> { + use libquassel::message::Message; + use libquassel::Deserialize; + + trace!(target: "message", "Received bytes: {:x?}", buf); + + match Message::parse(buf) { + Ok((_size, res)) => info!("{}: {:#?}", direction, res), + Err(e) => error!("failed to parse message {}", e), + } + + return Ok(()); + } +} diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..32a9786 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1 @@ +edition = "2018" diff --git a/src/bin/quassel-client.rs b/src/bin/quassel-client.rs deleted file mode 100644 index fa3fdf8..0000000 --- a/src/bin/quassel-client.rs +++ /dev/null @@ -1,97 +0,0 @@ -use failure::Error; - -extern crate libquassel; - -extern crate tokio; -extern crate pretty_env_logger; - -use libquassel::primitive::*; -use libquassel::message::*; -use libquassel::client::*; - -use tokio::io::{AsyncRead, AsyncWrite}; -use core::marker::Unpin; -use futures::SinkExt; -use std::future::Future; - -use log::*; - -#[tokio::main] -async fn main() -> Result<(), Error> { - pretty_env_logger::init(); - -// let mut client = client::Client::<tokio::net::TcpStream>::connect( -// "cocaine.farm", -// 4242, -// true, -// ).await.unwrap(); - - let username = std::env::args().nth(1).expect("no username given"); - let password = std::env::args().nth(2).expect("no password given"); - - let funcs = Funcs { - init: InitFuncs { - client_init_ack, - client_init_reject, - client_login_ack, - client_login_reject, - session_init - }, - message: MessageFuncs { - sync_message, - rpc_call, - init_request, - init_data, - heart_beat, - heart_beat_reply - } - }; - - let mut client = Client::<tokio_tls::TlsStream<tokio::net::TcpStream>>::connect_tls( - "cocaine.farm", - 4242, - true, - User { - name: username, - password, - }, - //funcs, - ).await.unwrap(); - - client.run().await; - - Ok(()) -} - -async fn client_init_ack<T: AsyncRead + AsyncWrite + Unpin, F: Future>(client: &mut Client<T, F>, item: VariantMap) { - use libquassel::{HandshakeSerialize, HandshakeDeserialize}; - - info!(target: "init", "Initialization successfull"); - info!(target: "login", "Starting Login"); - let login = ClientLogin {user: client.user.name.clone(), password: client.user.password.clone()}; - client.stream.send(login.serialize().unwrap()).await.unwrap(); -} - -async fn client_init_reject<T: AsyncRead + AsyncWrite + Unpin, F: Future>(client: Client<T, F>, item: VariantMap) { - error!(target: "init", "Initialization failed: {:?}", item); -} - -async fn client_login_ack<T: AsyncRead + AsyncWrite + Unpin, F: Future>(client: Client<T, F>, item: VariantMap) { - info!(target: "login", "Login successfull"); -} - -async fn client_login_reject<T: AsyncRead + AsyncWrite + Unpin, F: Future>(client: Client<T, F>, item: VariantMap) { - error!(target: "login", "Login failed: {:?}", item); -} - -async fn session_init<T: AsyncRead + AsyncWrite + Unpin, F: Future>(client: &mut Client<T, F>, item: VariantMap) { - info!(target: "login", "Session Initialization finished. Switching to Connected state"); - client.state = ClientState::Connected; -} - -async fn sync_message<T: AsyncRead + AsyncWrite + Unpin, F: Future>(client: Client<T, F>, item: SyncMessage) { unimplemented!() } -async fn rpc_call<T: AsyncRead + AsyncWrite + Unpin, F: Future>(client: Client<T, F>, item: RpcCall) { unimplemented!() } -async fn init_request<T: AsyncRead + AsyncWrite + Unpin, F: Future>(client: Client<T, F>, item: InitRequest) { unimplemented!() } -async fn init_data<T: AsyncRead + AsyncWrite + Unpin, F: Future>(client: Client<T, F>, item: InitData) { unimplemented!() } -async fn heart_beat<T: AsyncRead + AsyncWrite + Unpin, F: Future>(client: Client<T, F>, item: HeartBeat) { unimplemented!() } -async fn heart_beat_reply<T: AsyncRead + AsyncWrite + Unpin, F: Future>(client: Client<T, F>, item: HeartBeatReply) { unimplemented!() } diff --git a/src/client/mod.rs b/src/client/mod.rs deleted file mode 100644 index cded8c9..0000000 --- a/src/client/mod.rs +++ /dev/null @@ -1,291 +0,0 @@ -//use std::io::BufWriter; -use std::result::Result; -use std::vec::Vec; - -use tokio::io::{AsyncRead, AsyncWrite}; -use core::marker::Unpin; -use tokio::net::TcpStream; -use tokio::prelude::*; - -use native_tls::TlsConnector; - -use tokio_tls; -use tokio_tls::TlsStream; -use tokio_util::codec::Framed; -use futures_util::stream::StreamExt; -use futures::SinkExt; -use std::future::Future; - -use crate::frame::QuasselCodec; - -use failure::Error; - -use log::{trace, debug, info, error}; - -use crate::message::*; -use crate::primitive::*; - -extern crate log; - -pub struct Client<T, F> -where - F: Future, - T: 'static + AsyncRead + AsyncWrite + Unpin, -{ - pub stream: Framed<T, QuasselCodec>, - pub tls: bool, - pub compression: bool, - pub state: ClientState, - pub user: User, - pub funcs: Funcs<T, F>, -} - -pub struct User { - pub name: String, - pub password: String, -} - -pub enum ClientState { - Handshake, - Connected, -} - -impl <T: AsyncRead + AsyncWrite + Unpin, F: Future> Client<T, F> { - pub async fn run(&mut self) { - use crate::primitive::StringList; - use crate::message::ClientInit; - use crate::HandshakeSerialize; - - info!(target: "init", "Setting Features"); - - let mut features = StringList::new(); - features.push("SynchronizedMarkerLine".to_string()); - features.push("Authenticators".to_string()); - features.push("ExtendedFeatures".to_string()); - features.push("BufferActivitySync".to_string()); - let client_init = ClientInit { - client_version:String::from("Rust 0.0.0"), - client_date: String::from("1579009211"), - feature_list: features, - client_features: 0x00008000, - }; - - self.stream.send(client_init.serialize().unwrap()).await.unwrap(); - - // Start event loop - while let Some(msg) = self.stream.next().await { - let msg = msg.unwrap(); - match self.state { - ClientState::Handshake => handle_login_message(self, &msg).await.unwrap(), - ClientState::Connected => handle_message(self, &msg).await.unwrap(), - } - }; - } - - pub async fn connect( - address: &'static str, - port: u64, - compression: bool, - user: User, - funcs: Funcs<TcpStream, impl Future> - ) -> Result<Client<TcpStream, impl Future>, Error> { - let mut stream = TcpStream::connect(format!("{}:{}", address, port)).await?; - - info!(target: "init", "Establishing Connection"); - let connack = init(&mut stream, false, compression).await?; - - debug!(target: "init", "{:?}", connack); - - let codec = QuasselCodec::builder() - .compression(compression) - .new_codec(); - - let framed_stream = Framed::new(stream, codec); - - info!(target: "init", "Established Connection"); - - return Ok(Client { - stream: framed_stream, - tls: false, - compression, - state: ClientState::Handshake, - user, - funcs, - }); - } - - pub async fn connect_tls( - address: &'static str, - port: u64, - compression: bool, - user: User, - funcs: Funcs<TlsStream<TcpStream>, impl Future> - ) -> Result<Client<TlsStream<TcpStream>, impl Future>, Error> { - let mut stream: TcpStream = TcpStream::connect(format!("{}:{}", address, port)).await?; - - info!(target: "init", "Establishing Connection"); - let connack = init(&mut stream, true, compression).await?; - - debug!(target: "init", "{:?}", connack); - - let codec = QuasselCodec::builder() - .compression(compression) - .new_codec(); - - let tls_connector = tokio_tls::TlsConnector::from(TlsConnector::builder().build().unwrap()); - - let tls_stream = tls_connector.connect(address, stream).await?; - - let framed_stream = Framed::new(tls_stream, codec); - - info!(target: "init", "Established Connection"); - - return Ok(Client { - stream: framed_stream, - tls: true, - compression, - state: ClientState::Handshake, - user, - funcs, - }); - } - -} - -pub async fn handle_login_message<T: AsyncRead + AsyncWrite + Unpin, F: Future>(client: &mut Client<T, F>, buf: &[u8]) -> Result<(), Error> { - use crate::{HandshakeSerialize, HandshakeDeserialize}; - use crate::message::ClientLogin; - use crate::primitive::{VariantMap, Variant}; - - trace!(target: "message", "Received bytes: {:x?}", buf); - let (_, res) = VariantMap::parse(buf)?; - debug!(target: "init", "Received Messsage: {:#?}", res); - - let msgtype = match_variant!(&res["MsgType"], Variant::String); - match msgtype.as_str() { - "ClientInitAck" => { - info!(target: "init", "Initialization successfull"); - info!(target: "login", "Starting Login"); - let login = ClientLogin {user: client.user.name.clone(), password: client.user.password.clone()}; - client.stream.send(login.serialize()?).await?; - }, - "ClientInitReject" => { - error!(target: "init", "Initialization failed: {:?}", res); - }, - "ClientLoginAck" => { - info!(target: "login", "Login successfull"); - }, - "SessionInit" => { - info!(target: "login", "Session Initialization finished. Switching to Connected state"); - client.state = ClientState::Connected; - } - "ClientLoginReject" => { - error!(target: "login", "Login failed: {:?}", res); - }, - _ => { - error!(target: "client", "Error: WrongMsgType: {:#?}", res); - } - } - - return Ok(()); -} - -pub async fn handle_message<T: AsyncRead + AsyncWrite + Unpin, F: Future>(client: &mut Client<T, F>, buf: &[u8]) -> Result<(), Error> { - use crate::message::Message; - use crate::primitive::VariantList; - use crate::Deserialize; - use crate::Serialize; - - trace!(target: "message", "Received bytes: {:x?}", buf); - let (_, res) = Message::parse(buf)?; - debug!(target: "init", "Received Messsage: {:#?}", res); - - match res { - Message::SyncMessage(_) => {} - Message::RpcCall(_) => {} - Message::InitRequest(_) => {} - Message::InitData(_) => {} - Message::HeartBeat(_) => {} - Message::HeartBeatReply(_) => {} - } - - return Ok(()); -} - -pub struct Funcs<T, F> -where - T: 'static + AsyncRead + AsyncWrite + Unpin, - F: std::future::Future, -{ - pub init: InitFuncs<T, F>, - pub message: MessageFuncs<T, F>, -} - -pub struct InitFuncs<T, F> -where - T: 'static + AsyncRead + AsyncWrite + Unpin, - F: std::future::Future, -{ - pub client_init_ack: fn(&mut Client<T, F>, VariantMap) -> F, - pub client_init_reject: fn(Client<T, F>, VariantMap) -> F, - pub client_login_ack: fn(Client<T, F>, VariantMap) -> F, - pub client_login_reject: fn(Client<T, F>, VariantMap) -> F, - pub session_init: fn(&mut Client<T, F>, VariantMap) -> F, -} - -pub struct MessageFuncs<T, F> -where - T: 'static + AsyncRead + AsyncWrite + Unpin, - F: std::future::Future, -{ - pub sync_message: fn(Client<T, F>, SyncMessage) -> F, - pub rpc_call: fn(Client<T, F>, RpcCall) -> F, - pub init_request: fn(Client<T, F>, InitRequest) -> F, - pub init_data: fn(Client<T, F>, InitData) -> F, - pub heart_beat: fn(Client<T, F>, HeartBeat) -> F, - pub heart_beat_reply: fn(Client<T, F>, HeartBeatReply) -> F, -} - -// Send the initialization message to the stream -pub async fn init(stream: &mut TcpStream, tls: bool, compression: bool) -> Result<ConnAck, Error> { - use crate::Deserialize; - - // Buffer for our initialization - let mut init: Vec<u8> = vec![]; - - // The handshake message - let mut handshake: u32 = 0x42b33f00; - - // If TLS is enabled set the TLS bit on the handshake - if tls { - info!(target: "init", "Enabled TLS"); - handshake |= 0x01; - } - - // If COMPRESSION is enabled set the COMPRESSION bit on the handshake - if compression { - info!(target: "init", "Enabled Compression"); - handshake |= 0x02; - } - - // Select Protocol 2: Datastream - let mut proto: u32 = 0x00000002; - - // Flag proto as the last protocol - let fin: u32 = 0x80000000; - proto |= fin; - - // Add handshake and protocol to our buffer - init.extend(handshake.to_be_bytes().iter()); - init.extend(proto.to_be_bytes().iter()); - - // Send Buffer - stream.write(&init).await?; - - // Read Response - let mut buf = [0; 4]; - stream.read(&mut buf).await?; - - let (_, connack) = ConnAck::parse(&buf)?; - Ok(connack) -} diff --git a/src/frame/mod.rs b/src/frame/mod.rs index 709d3af..cbeddb0 100644 --- a/src/frame/mod.rs +++ b/src/frame/mod.rs @@ -195,8 +195,7 @@ impl Decoder for QuasselCodec { } } -impl Encoder for QuasselCodec { - type Item = Vec<u8>; +impl Encoder<Vec<u8>> for QuasselCodec { type Error = io::Error; fn encode(&mut self, data: Vec<u8>, dst: &mut BytesMut) -> Result<(), io::Error> { @@ -1,23 +1,32 @@ +#![feature(external_doc)] +#![feature(doc_cfg)] +#![doc(include = "../README.md")] +#[cfg_attr(docsrs, feature(doc_cfg))] #[macro_use] mod util; -#[cfg(feature = "client")] -pub mod client; - #[cfg(test)] pub mod tests; #[macro_use] extern crate failure; +/// Quassel Structures for serialization and deserialization pub mod message; + +/// Quassels QT based primitive types that make up the more complex messages pub mod primitive; +pub mod session; + #[allow(dead_code)] +/// Error Types pub mod error; #[allow(unused_variables, dead_code)] #[cfg(feature = "framing")] +#[cfg_attr(docsrs, doc(cfg(feature = "framing")))] +/// Framing impl to be used with [`tokio_util::codec::Framed`] pub mod frame; use failure::Error; diff --git a/src/message/handshake/clientinit.rs b/src/message/handshake/clientinit.rs index 17ec9a1..d21d6aa 100644 --- a/src/message/handshake/clientinit.rs +++ b/src/message/handshake/clientinit.rs @@ -1,6 +1,5 @@ -use crate::error::ProtocolError; use crate::primitive::{StringList, Variant, VariantMap}; -use crate::{HandshakeDeserialize, HandshakeSerialize}; +use crate::HandshakeSerialize; use failure::Error; @@ -32,7 +31,7 @@ use failure::Error; /// | -- | EcdsaCertfpKeys | ECDSA keys for CertFP in identities | /// | -- | LongMessageId | 64-bit IDs for messages | /// | -- | SyncedCoreInfo | CoreInfo dynamically updated using signals | -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct ClientInit { /// Version of the client pub client_version: String, @@ -68,24 +67,13 @@ impl HandshakeSerialize for ClientInit { } } -impl HandshakeDeserialize for ClientInit { - fn parse(b: &[u8]) -> Result<(usize, Self), Error> { - let (len, values): (usize, VariantMap) = HandshakeDeserialize::parse(b)?; - - let msgtype = match_variant!(&values["MsgType"], Variant::StringUTF8); - - if msgtype == "ClientInit" { - return Ok(( - len, - Self { - client_version: match_variant!(values["ClientVersion"], Variant::String), - client_date: match_variant!(values["ClientDate"], Variant::String), - feature_list: match_variant!(values["FeatureList"], Variant::StringList), - client_features: match_variant!(values["Features"], Variant::u32), - }, - )); - } else { - bail!(ProtocolError::WrongMsgType); +impl From<VariantMap> for ClientInit { + fn from(input: VariantMap) -> Self { + ClientInit { + client_version: match_variant!(input.get("ClientVersion").unwrap(), Variant::String), + client_date: match_variant!(input.get("ClientDate").unwrap(), Variant::String), + client_features: match_variant!(input.get("Features").unwrap(), Variant::u32), + feature_list: match_variant!(input.get("FeatureList").unwrap(), Variant::StringList), } } } diff --git a/src/message/handshake/clientinitack.rs b/src/message/handshake/clientinitack.rs index 637b989..f881113 100644 --- a/src/message/handshake/clientinitack.rs +++ b/src/message/handshake/clientinitack.rs @@ -1,11 +1,10 @@ -use crate::error::ProtocolError; -use crate::primitive::{StringList, Variant, VariantList, VariantMap}; -use crate::{HandshakeDeserialize, HandshakeSerialize}; +use crate::primitive::{Variant, VariantList, VariantMap}; +use crate::HandshakeSerialize; use failure::Error; /// ClientInitAck is received when the initialization was successfull -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct ClientInitAck { /// Flags of supported legacy features pub core_features: u32, @@ -16,7 +15,7 @@ pub struct ClientInitAck { /// List of VariantMaps of info on available authenticators pub authenticators: VariantList, /// List of supported extended features - pub feature_list: StringList, + pub feature_list: Vec<String>, } impl HandshakeSerialize for ClientInitAck { @@ -47,28 +46,21 @@ impl HandshakeSerialize for ClientInitAck { } } -impl HandshakeDeserialize for ClientInitAck { - fn parse(b: &[u8]) -> Result<(usize, Self), Error> { - let (len, values): (usize, VariantMap) = HandshakeDeserialize::parse(b)?; - - let msgtype = match_variant!(&values["MsgType"], Variant::StringUTF8); - - if msgtype == "ClientInitAck" { - return Ok(( - len, - Self { - core_features: 0x00008000, - core_configured: match_variant!(values["Configured"], Variant::bool), - storage_backends: match_variant!( - values["StorageBackends"], - Variant::VariantList - ), - authenticators: match_variant!(values["Authenticators"], Variant::VariantList), - feature_list: match_variant!(values["FeatureList"], Variant::StringList), - }, - )); - } else { - bail!(ProtocolError::WrongMsgType); +impl From<VariantMap> for ClientInitAck { + fn from(input: VariantMap) -> Self { + ClientInitAck { + // TODO make this compatible with older clients + core_features: 0, + core_configured: match_variant!(input.get("Configured").unwrap(), Variant::bool), + storage_backends: match_variant!( + input.get("StorageBackends").unwrap(), + Variant::VariantList + ), + authenticators: match_variant!( + input.get("Authenticators").unwrap(), + Variant::VariantList + ), + feature_list: match_variant!(input.get("FeatureList").unwrap(), Variant::StringList), } } } diff --git a/src/message/handshake/clientinitreject.rs b/src/message/handshake/clientinitreject.rs index 06960b7..d93413d 100644 --- a/src/message/handshake/clientinitreject.rs +++ b/src/message/handshake/clientinitreject.rs @@ -1,14 +1,13 @@ -use crate::error::ProtocolError; use crate::primitive::{Variant, VariantMap}; -use crate::{HandshakeDeserialize, HandshakeSerialize}; +use crate::HandshakeSerialize; use failure::Error; /// ClientInitReject is received when the initialization fails -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct ClientInitReject { /// String with an error message of what went wrong - pub error_string: String, + pub error: String, } impl HandshakeSerialize for ClientInitReject { @@ -20,27 +19,16 @@ impl HandshakeSerialize for ClientInitReject { ); values.insert( "ErrorString".to_string(), - Variant::String(self.error_string.clone()), + Variant::String(self.error.clone()), ); return HandshakeSerialize::serialize(&values); } } -impl HandshakeDeserialize for ClientInitReject { - fn parse(b: &[u8]) -> Result<(usize, Self), Error> { - let (len, values): (usize, VariantMap) = HandshakeDeserialize::parse(b)?; - - let msgtype = match_variant!(&values["MsgType"], Variant::StringUTF8); - - if msgtype == "ClientInitReject" { - return Ok(( - len, - Self { - error_string: match_variant!(values["ErrorString"], Variant::String), - }, - )); - } else { - bail!(ProtocolError::WrongMsgType); +impl From<VariantMap> for ClientInitReject { + fn from(input: VariantMap) -> Self { + ClientInitReject { + error: match_variant!(input.get("ErrorString").unwrap(), Variant::String), } } } diff --git a/src/message/handshake/clientlogin.rs b/src/message/handshake/clientlogin.rs index 769245b..dffd996 100644 --- a/src/message/handshake/clientlogin.rs +++ b/src/message/handshake/clientlogin.rs @@ -1,12 +1,11 @@ -use crate::error::ProtocolError; use crate::primitive::{Variant, VariantMap}; -use crate::{HandshakeDeserialize, HandshakeSerialize}; +use crate::HandshakeSerialize; use failure::Error; /// Login to the core with user data /// username and password are transmitted in plain text -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct ClientLogin { pub user: String, pub password: String, @@ -28,22 +27,11 @@ impl HandshakeSerialize for ClientLogin { } } -impl HandshakeDeserialize for ClientLogin { - fn parse(b: &[u8]) -> Result<(usize, Self), Error> { - let (len, values): (usize, VariantMap) = HandshakeDeserialize::parse(b)?; - - let msgtype = match_variant!(&values["MsgType"], Variant::StringUTF8); - - if msgtype == "ClientLogin" { - return Ok(( - len, - Self { - user: match_variant!(values["User"], Variant::String), - password: match_variant!(values["Password"], Variant::String), - }, - )); - } else { - bail!(ProtocolError::WrongMsgType); +impl From<VariantMap> for ClientLogin { + fn from(input: VariantMap) -> Self { + ClientLogin { + user: match_variant!(input.get("User").unwrap(), Variant::String), + password: match_variant!(input.get("Password").unwrap(), Variant::String), } } } diff --git a/src/message/handshake/clientloginack.rs b/src/message/handshake/clientloginack.rs index 674d307..e385a81 100644 --- a/src/message/handshake/clientloginack.rs +++ b/src/message/handshake/clientloginack.rs @@ -6,7 +6,7 @@ use failure::Error; /// ClientLoginAck is received after the client has successfully logged in /// it has no fields -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct ClientLoginAck; impl HandshakeSerialize for ClientLoginAck { diff --git a/src/message/handshake/clientloginreject.rs b/src/message/handshake/clientloginreject.rs index e8380d6..0c0fc85 100644 --- a/src/message/handshake/clientloginreject.rs +++ b/src/message/handshake/clientloginreject.rs @@ -1,14 +1,13 @@ -use crate::error::ProtocolError; use crate::primitive::{Variant, VariantMap}; -use crate::{HandshakeDeserialize, HandshakeSerialize}; +use crate::HandshakeSerialize; use failure::Error; /// ClientLoginReject is received after the client failed to login /// It contains an error message as String -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct ClientLoginReject { - error: String, + pub error: String, } impl HandshakeSerialize for ClientLoginReject { @@ -26,21 +25,10 @@ impl HandshakeSerialize for ClientLoginReject { } } -impl HandshakeDeserialize for ClientLoginReject { - fn parse(b: &[u8]) -> Result<(usize, Self), Error> { - let (len, values): (usize, VariantMap) = HandshakeDeserialize::parse(b)?; - - let msgtype = match_variant!(&values["MsgType"], Variant::StringUTF8); - - if msgtype == "ClientLogin" { - return Ok(( - len, - Self { - error: match_variant!(values["ErrorString"], Variant::String), - }, - )); - } else { - bail!(ProtocolError::WrongMsgType); +impl From<VariantMap> for ClientLoginReject { + fn from(input: VariantMap) -> Self { + ClientLoginReject { + error: match_variant!(input.get("ErrorString").unwrap(), Variant::String), } } } diff --git a/src/message/handshake/init.rs b/src/message/handshake/init.rs index e4c0fa9..b4604b6 100644 --- a/src/message/handshake/init.rs +++ b/src/message/handshake/init.rs @@ -2,6 +2,7 @@ use crate::Deserialize; use crate::Serialize; /// The first few bytes sent to the core to initialize the connection and setup if we want to use tls and compression +#[derive(Clone, Debug)] pub struct Init { pub tls: bool, pub compression: bool, @@ -37,7 +38,15 @@ impl Init { handshake |= 0x02; } - return handshake.serialize().unwrap(); + // Select Protocol 2: Datastream + + let mut init: Vec<u8> = vec![]; + + // Add handshake and protocol to our buffer + init.extend(handshake.serialize().unwrap()); + init.extend(crate::message::Protocol::Datastream.serialize()); + + return init; } pub fn parse(buf: &[u8]) -> Self { diff --git a/src/message/handshake/mod.rs b/src/message/handshake/mod.rs index 9b3bcee..9885012 100644 --- a/src/message/handshake/mod.rs +++ b/src/message/handshake/mod.rs @@ -21,3 +21,49 @@ pub use init::*; pub use protocol::*; pub use sessioninit::*; pub use types::*; + +use crate::primitive::{Variant, VariantMap}; +use crate::{HandshakeDeserialize, HandshakeSerialize}; + +#[derive(Debug, Clone)] +pub enum HandshakeMessage { + ClientInit(ClientInit), + ClientInitAck(ClientInitAck), + ClientInitReject(ClientInitReject), + ClientLogin(ClientLogin), + ClientLoginAck, + ClientLoginReject(ClientLoginReject), + SessionInit(SessionInit), +} + +impl HandshakeSerialize for HandshakeMessage { + fn serialize(&self) -> Result<Vec<u8>, failure::Error> { + match self { + HandshakeMessage::ClientInit(inner) => inner.serialize(), + HandshakeMessage::ClientInitAck(inner) => inner.serialize(), + HandshakeMessage::ClientInitReject(inner) => inner.serialize(), + HandshakeMessage::ClientLogin(inner) => inner.serialize(), + HandshakeMessage::ClientLoginAck => ClientLoginAck.serialize(), + HandshakeMessage::ClientLoginReject(inner) => inner.serialize(), + HandshakeMessage::SessionInit(inner) => inner.serialize(), + } + } +} + +impl HandshakeDeserialize for HandshakeMessage { + fn parse(b: &[u8]) -> Result<(usize, Self), failure::Error> { + let (size, res) = VariantMap::parse(b)?; + + let msgtype = match_variant!(&res["MsgType"], Variant::String); + match msgtype.as_str() { + "ClientInit" => Ok((size, HandshakeMessage::ClientInit(res.into()))), + "ClientInitAck" => Ok((size, HandshakeMessage::ClientInitAck(res.into()))), + "ClientInitReject" => Ok((size, HandshakeMessage::ClientInitReject(res.into()))), + "ClientLogin" => Ok((size, HandshakeMessage::ClientLogin(res.into()))), + "ClientLoginAck" => Ok((size, HandshakeMessage::ClientLoginAck)), + "ClientLoginReject" => Ok((size, HandshakeMessage::ClientLoginReject(res.into()))), + "SessionInit" => Ok((size, HandshakeMessage::SessionInit(res.into()))), + _ => unimplemented!(), + } + } +} diff --git a/src/message/handshake/sessioninit.rs b/src/message/handshake/sessioninit.rs index eca4c10..d1b4b90 100644 --- a/src/message/handshake/sessioninit.rs +++ b/src/message/handshake/sessioninit.rs @@ -1,61 +1,81 @@ -use crate::error::ProtocolError; -use crate::primitive::{Variant, VariantList, VariantMap}; -use crate::{HandshakeDeserialize, HandshakeSerialize}; +use crate::message::objects::Identity; +use crate::primitive::{BufferInfo, Variant, VariantMap}; +use crate::HandshakeSerialize; use failure::Error; /// SessionInit is received along with ClientLoginAck to initialize that user Session // TODO Replace with proper types -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct SessionInit { /// List of all configured identities - identities: VariantList, + pub identities: Vec<Identity>, /// List of all existing buffers - buffers: VariantList, + pub buffers: Vec<BufferInfo>, /// Ids of all networks - network_ids: VariantList, + pub network_ids: Vec<i32>, +} + +impl From<VariantMap> for SessionInit { + fn from(input: VariantMap) -> Self { + let state = match_variant!(input.get("SessionState").unwrap(), Variant::VariantMap); + SessionInit { + identities: match_variant!(state.get("Identities").unwrap(), Variant::VariantList) + .iter() + .map(|ident| Identity::from(match_variant!(ident, Variant::VariantMap))) + .collect(), + buffers: match_variant!(state.get("BufferInfos").unwrap(), Variant::VariantList) + .iter() + .map(|buffer| match buffer { + Variant::BufferInfo(buffer) => buffer.clone(), + _ => unimplemented!(), + }) + .collect(), + network_ids: match_variant!(state.get("NetworkIds").unwrap(), Variant::VariantList) + .iter() + .map(|network| match network { + Variant::i32(network) => network.clone(), + _ => unimplemented!(), + }) + .collect(), + } + } } impl HandshakeSerialize for SessionInit { fn serialize(&self) -> Result<Vec<u8>, Error> { - let mut values: VariantMap = VariantMap::with_capacity(1); + let mut values: VariantMap = VariantMap::with_capacity(4); values.insert( "MsgType".to_string(), Variant::String("SessionInit".to_string()), ); values.insert( "Identities".to_string(), - Variant::VariantList(self.identities.clone()), + Variant::VariantList( + self.identities + .iter() + .map(|ident| Variant::VariantMap(ident.clone().into())) + .collect(), + ), ); values.insert( "BufferInfos".to_string(), - Variant::VariantList(self.buffers.clone()), + Variant::VariantList( + self.buffers + .iter() + .map(|buffer| Variant::BufferInfo(buffer.clone())) + .collect(), + ), ); values.insert( "NetworkIds".to_string(), - Variant::VariantList(self.network_ids.clone()), + Variant::VariantList( + self.network_ids + .iter() + .map(|id| Variant::i32(id.clone())) + .collect(), + ), ); return HandshakeSerialize::serialize(&values); } } - -impl HandshakeDeserialize for SessionInit { - fn parse(b: &[u8]) -> Result<(usize, Self), Error> { - let (len, values): (usize, VariantMap) = HandshakeDeserialize::parse(b)?; - - let msgtype = match_variant!(&values["MsgType"], Variant::StringUTF8); - - if msgtype == "ClientLogin" { - return Ok(( - len, - Self { - identities: match_variant!(values["Identities"], Variant::VariantList), - buffers: match_variant!(values["BufferInfos"], Variant::VariantList), - network_ids: match_variant!(values["NetworkIds"], Variant::VariantList), - }, - )); - } else { - bail!(ProtocolError::WrongMsgType); - } - } -} diff --git a/src/message/signalproxy.rs b/src/message/signalproxy.rs deleted file mode 100644 index 22a498a..0000000 --- a/src/message/signalproxy.rs +++ /dev/null @@ -1,309 +0,0 @@ -use crate::primitive::{DateTime, Variant, VariantList}; -use crate::{Deserialize, Serialize}; - -#[derive(Clone, Debug, std::cmp::PartialEq)] -pub enum Message { - /// Bidirectional - SyncMessage(SyncMessage), - /// Bidirectional - RpcCall(RpcCall), - InitRequest(InitRequest), - InitData(InitData), - /// Bidirectional - HeartBeat(HeartBeat), - /// Bidirectional - HeartBeatReply(HeartBeatReply), -} - -impl Serialize for Message { - fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> { - match &self { - Message::SyncMessage(value) => value.serialize(), - Message::RpcCall(value) => value.serialize(), - Message::InitRequest(value) => value.serialize(), - Message::InitData(value) => value.serialize(), - Message::HeartBeat(value) => value.serialize(), - Message::HeartBeatReply(value) => value.serialize(), - } - } -} - -impl Deserialize for Message { - fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { - let (_, message_type) = i32::parse(&b[9..13])?; - - match MessageType::from(message_type) { - MessageType::SyncMessage => { - let (size, res) = SyncMessage::parse(&b)?; - - Ok((size, Message::SyncMessage(res))) - } - MessageType::RpcCall => { - let (size, res) = RpcCall::parse(&b)?; - - Ok((size, Message::RpcCall(res))) - } - MessageType::InitRequest => { - let (size, res) = InitRequest::parse(&b)?; - - Ok((size, Message::InitRequest(res))) - } - MessageType::InitData => { - let (size, res) = InitData::parse(&b)?; - - Ok((size, Message::InitData(res))) - } - MessageType::HeartBeat => { - let (size, res) = HeartBeat::parse(&b)?; - - Ok((size, Message::HeartBeat(res))) - } - MessageType::HeartBeatReply => { - let (size, res) = HeartBeatReply::parse(&b)?; - - Ok((size, Message::HeartBeatReply(res))) - } - } - } -} - -/// Type of an SignalProxy Message -/// The first element in the VariantList that is received -#[repr(i32)] -#[derive(Copy, Clone, Debug, std::cmp::PartialEq)] -pub enum MessageType { - /// Bidirectional - SyncMessage = 0x00000001, - /// Bidirectional - RpcCall = 0x00000002, - InitRequest = 0x00000003, - InitData = 0x00000004, - /// Bidirectional - HeartBeat = 0x00000005, - /// Bidirectional - HeartBeatReply = 0x00000006, -} - -impl From<i32> for MessageType { - fn from(val: i32) -> Self { - match val { - 0x00000001 => MessageType::SyncMessage, - 0x00000002 => MessageType::RpcCall, - 0x00000003 => MessageType::InitRequest, - 0x00000004 => MessageType::InitData, - 0x00000005 => MessageType::HeartBeat, - 0x00000006 => MessageType::HeartBeatReply, - _ => unimplemented!(), - } - } -} - -#[derive(Clone, Debug, std::cmp::PartialEq)] -pub struct SyncMessage { - class_name: String, - object_name: String, - slot_name: String, - params: VariantList, -} - -impl Serialize for SyncMessage { - fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> { - let mut res = VariantList::new(); - - res.push(Variant::i32(MessageType::SyncMessage as i32)); - res.push(Variant::StringUTF8(self.class_name.clone())); - res.push(Variant::StringUTF8(self.object_name.clone())); - res.push(Variant::StringUTF8(self.slot_name.clone())); - - res.append(&mut self.params.clone()); - - res.serialize() - } -} - -impl Deserialize for SyncMessage { - fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { - let (size, mut res) = VariantList::parse(&b)?; - - res.remove(0); - - Ok(( - size, - Self { - class_name: match_variant!(res.remove(0), Variant::StringUTF8), - object_name: match_variant!(res.remove(0), Variant::StringUTF8), - slot_name: match_variant!(res.remove(0), Variant::StringUTF8), - params: res, - }, - )) - } -} - -#[derive(Clone, Debug, std::cmp::PartialEq)] -pub struct RpcCall { - slot_name: String, - params: VariantList, -} - -impl Serialize for RpcCall { - fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> { - let mut res = VariantList::new(); - - res.push(Variant::i32(MessageType::RpcCall as i32)); - res.push(Variant::StringUTF8(self.slot_name.clone())); - - res.append(&mut self.params.clone()); - - res.serialize() - } -} - -impl Deserialize for RpcCall { - fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { - let (size, mut res) = VariantList::parse(&b)?; - - res.remove(0); - - Ok(( - size, - Self { - slot_name: match_variant!(res.remove(0), Variant::StringUTF8), - params: res, - }, - )) - } -} - -#[derive(Clone, Debug, std::cmp::PartialEq)] -pub struct InitRequest { - class_name: String, - object_name: String, -} - -impl Serialize for InitRequest { - fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> { - let mut res = VariantList::new(); - - res.push(Variant::i32(MessageType::InitRequest as i32)); - res.push(Variant::StringUTF8(self.class_name.clone())); - res.push(Variant::StringUTF8(self.object_name.clone())); - - res.serialize() - } -} - -impl Deserialize for InitRequest { - fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { - let (size, mut res) = VariantList::parse(&b)?; - - res.remove(0); - - Ok(( - size, - Self { - class_name: match_variant!(res.remove(0), Variant::StringUTF8), - object_name: match_variant!(res.remove(0), Variant::StringUTF8), - }, - )) - } -} - -#[derive(Clone, Debug, std::cmp::PartialEq)] -pub struct InitData { - class_name: String, - object_name: String, - init_data: VariantList, -} - -impl Serialize for InitData { - fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> { - let mut res = VariantList::new(); - - res.push(Variant::i32(MessageType::InitData as i32)); - res.push(Variant::StringUTF8(self.class_name.clone())); - res.push(Variant::StringUTF8(self.object_name.clone())); - - res.append(&mut self.init_data.clone()); - - res.serialize() - } -} - -impl Deserialize for InitData { - fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { - let (size, mut res) = VariantList::parse(&b)?; - - res.remove(0); - - Ok(( - size, - Self { - class_name: match_variant!(res.remove(0), Variant::StringUTF8), - object_name: match_variant!(res.remove(0), Variant::StringUTF8), - init_data: res, - }, - )) - } -} - -#[derive(Clone, Debug, std::cmp::PartialEq)] -pub struct HeartBeat { - timestamp: DateTime, -} - -impl Serialize for HeartBeat { - fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> { - let mut res = VariantList::new(); - - res.push(Variant::i32(MessageType::HeartBeat as i32)); - res.push(Variant::DateTime(self.timestamp.clone())); - - res.serialize() - } -} - -impl Deserialize for HeartBeat { - fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { - let (size, mut res) = VariantList::parse(&b)?; - - res.remove(0); - - Ok(( - size, - Self { - timestamp: match_variant!(res.remove(0), Variant::DateTime), - }, - )) - } -} - -#[derive(Clone, Debug, std::cmp::PartialEq)] -pub struct HeartBeatReply { - timestamp: DateTime, -} - -impl Serialize for HeartBeatReply { - fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> { - let mut res = VariantList::new(); - - res.push(Variant::i32(MessageType::HeartBeatReply as i32)); - res.push(Variant::DateTime(self.timestamp.clone())); - - res.serialize() - } -} - -impl Deserialize for HeartBeatReply { - fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { - let (size, mut res) = VariantList::parse(&b)?; - - res.remove(0); - - Ok(( - size, - Self { - timestamp: match_variant!(res.remove(0), Variant::DateTime), - }, - )) - } -} diff --git a/src/message/signalproxy/heartbeat.rs b/src/message/signalproxy/heartbeat.rs new file mode 100644 index 0000000..46bfd51 --- /dev/null +++ b/src/message/signalproxy/heartbeat.rs @@ -0,0 +1,65 @@ +use crate::message::MessageType; +use crate::primitive::{DateTime, Variant, VariantList}; +use crate::{Deserialize, Serialize}; + +#[derive(Clone, Debug, std::cmp::PartialEq)] +pub struct HeartBeat { + timestamp: DateTime, +} + +impl Serialize for HeartBeat { + fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> { + let mut res = VariantList::new(); + + res.push(Variant::i32(MessageType::HeartBeat as i32)); + res.push(Variant::DateTime(self.timestamp.clone())); + + res.serialize() + } +} + +impl Deserialize for HeartBeat { + fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { + let (size, mut res) = VariantList::parse(&b)?; + + res.remove(0); + + Ok(( + size, + Self { + timestamp: match_variant!(res.remove(0), Variant::DateTime), + }, + )) + } +} + +#[derive(Clone, Debug, std::cmp::PartialEq)] +pub struct HeartBeatReply { + timestamp: DateTime, +} + +impl Serialize for HeartBeatReply { + fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> { + let mut res = VariantList::new(); + + res.push(Variant::i32(MessageType::HeartBeatReply as i32)); + res.push(Variant::DateTime(self.timestamp.clone())); + + res.serialize() + } +} + +impl Deserialize for HeartBeatReply { + fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { + let (size, mut res) = VariantList::parse(&b)?; + + res.remove(0); + + Ok(( + size, + Self { + timestamp: match_variant!(res.remove(0), Variant::DateTime), + }, + )) + } +} diff --git a/src/message/signalproxy/initdata.rs b/src/message/signalproxy/initdata.rs new file mode 100644 index 0000000..e4fb077 --- /dev/null +++ b/src/message/signalproxy/initdata.rs @@ -0,0 +1,41 @@ +use crate::message::MessageType; +use crate::primitive::{Variant, VariantList}; +use crate::{Deserialize, Serialize}; + +#[derive(Clone, Debug, std::cmp::PartialEq)] +pub struct InitData { + class_name: String, + object_name: String, + init_data: VariantList, +} + +impl Serialize for InitData { + fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> { + let mut res = VariantList::new(); + + res.push(Variant::i32(MessageType::InitData as i32)); + res.push(Variant::StringUTF8(self.class_name.clone())); + res.push(Variant::StringUTF8(self.object_name.clone())); + + res.append(&mut self.init_data.clone()); + + res.serialize() + } +} + +impl Deserialize for InitData { + fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { + let (size, mut res) = VariantList::parse(&b)?; + + res.remove(0); + + Ok(( + size, + Self { + class_name: match_variant!(res.remove(0), Variant::StringUTF8), + object_name: match_variant!(res.remove(0), Variant::StringUTF8), + init_data: res, + }, + )) + } +} diff --git a/src/message/signalproxy/initrequest.rs b/src/message/signalproxy/initrequest.rs new file mode 100644 index 0000000..59eee2d --- /dev/null +++ b/src/message/signalproxy/initrequest.rs @@ -0,0 +1,37 @@ +use crate::message::MessageType; +use crate::primitive::{Variant, VariantList}; +use crate::{Deserialize, Serialize}; + +#[derive(Clone, Debug, std::cmp::PartialEq)] +pub struct InitRequest { + pub class_name: String, + pub object_name: String, +} + +impl Serialize for InitRequest { + fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> { + let mut res = VariantList::new(); + + res.push(Variant::i32(MessageType::InitRequest as i32)); + res.push(Variant::ByteArray(self.class_name.clone())); + res.push(Variant::ByteArray(self.object_name.clone())); + + res.serialize() + } +} + +impl Deserialize for InitRequest { + fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { + let (size, mut res) = VariantList::parse(&b)?; + + res.remove(0); + + Ok(( + size, + Self { + class_name: match_variant!(res.remove(0), Variant::StringUTF8), + object_name: match_variant!(res.remove(0), Variant::StringUTF8), + }, + )) + } +} diff --git a/src/message/signalproxy/mod.rs b/src/message/signalproxy/mod.rs new file mode 100644 index 0000000..4e99fb0 --- /dev/null +++ b/src/message/signalproxy/mod.rs @@ -0,0 +1,124 @@ +use crate::{Deserialize, Serialize}; + +mod heartbeat; +mod initdata; +mod initrequest; +pub mod objects; +mod rpccall; +mod syncmessage; + +pub use heartbeat::*; +pub use initdata::*; +pub use initrequest::*; +pub use rpccall::*; +pub use syncmessage::*; + +#[derive(Clone, Debug, std::cmp::PartialEq)] +pub enum Message { + /// Bidirectional + SyncMessage(SyncMessage), + /// Bidirectional + RpcCall(RpcCall), + InitRequest(InitRequest), + InitData(InitData), + /// Bidirectional + HeartBeat(HeartBeat), + /// Bidirectional + HeartBeatReply(HeartBeatReply), +} + +// impl Message { +// fn act(&self) { +// match &self { +// Message::SyncMessage(value) => value.serialize(), +// Message::RpcCall(value) => value.serialize(), +// Message::InitRequest(value) => value.serialize(), +// Message::InitData(value) => value.serialize(), +// Message::HeartBeat(value) => value.serialize(), +// Message::HeartBeatReply(value) => value.serialize(), +// } +// } +// } + +impl Serialize for Message { + fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> { + match &self { + Message::SyncMessage(value) => value.serialize(), + Message::RpcCall(value) => value.serialize(), + Message::InitRequest(value) => value.serialize(), + Message::InitData(value) => value.serialize(), + Message::HeartBeat(value) => value.serialize(), + Message::HeartBeatReply(value) => value.serialize(), + } + } +} + +impl Deserialize for Message { + fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { + let (_, message_type) = i32::parse(&b[9..13])?; + + match MessageType::from(message_type) { + MessageType::SyncMessage => { + let (size, res) = SyncMessage::parse(&b)?; + + Ok((size, Message::SyncMessage(res))) + } + MessageType::RpcCall => { + let (size, res) = RpcCall::parse(&b)?; + + Ok((size, Message::RpcCall(res))) + } + MessageType::InitRequest => { + let (size, res) = InitRequest::parse(&b)?; + + Ok((size, Message::InitRequest(res))) + } + MessageType::InitData => { + let (size, res) = InitData::parse(&b)?; + + Ok((size, Message::InitData(res))) + } + MessageType::HeartBeat => { + let (size, res) = HeartBeat::parse(&b)?; + + Ok((size, Message::HeartBeat(res))) + } + MessageType::HeartBeatReply => { + let (size, res) = HeartBeatReply::parse(&b)?; + + Ok((size, Message::HeartBeatReply(res))) + } + } + } +} + +/// Type of an SignalProxy Message +/// The first element in the VariantList that is received +#[repr(i32)] +#[derive(Copy, Clone, Debug, std::cmp::PartialEq)] +pub enum MessageType { + /// Bidirectional + SyncMessage = 0x00000001, + /// Bidirectional + RpcCall = 0x00000002, + InitRequest = 0x00000003, + InitData = 0x00000004, + /// Bidirectional + HeartBeat = 0x00000005, + /// Bidirectional + HeartBeatReply = 0x00000006, +} + +impl From<i32> for MessageType { + fn from(val: i32) -> Self { + match val { + 0x00000001 => MessageType::SyncMessage, + 0x00000002 => MessageType::RpcCall, + 0x00000003 => MessageType::InitRequest, + 0x00000004 => MessageType::InitData, + 0x00000005 => MessageType::HeartBeat, + 0x00000006 => MessageType::HeartBeatReply, + _ => unimplemented!(), + } + } +} diff --git a/src/message/signalproxy/objects/aliasmanager.rs b/src/message/signalproxy/objects/aliasmanager.rs new file mode 100644 index 0000000..828caaa --- /dev/null +++ b/src/message/signalproxy/objects/aliasmanager.rs @@ -0,0 +1,46 @@ +use crate::primitive::{Variant, VariantMap}; + +#[derive(Clone, Debug, std::cmp::PartialEq)] +pub struct AliasManager { + pub aliases: Vec<Alias>, +} + +#[derive(Clone, Debug, std::cmp::PartialEq)] +pub struct Alias { + name: String, + expansion: String, +} + +impl AliasManager { + /// Client to Server + /// + /// Replaces all properties of the object with the content of the + /// "properties" parameter. This parameter is in network representation. + /// + fn request_update(self: &mut Self, properties: VariantMap) { + self.update(properties); + } + + /// Server to Client + fn add_alias(self: &mut Self, name: String, expansion: String) { + self.aliases.push(Alias { name, expansion }); + } + + /// Server to Client + /// + /// Replaces all properties of the object with the content of the + /// "properties" parameter. This parameter is in network representation. + /// + fn update(self: &mut Self, properties: VariantMap) { + let mut alias: Vec<Alias> = Vec::new(); + + // for (i, name) in match_variant!(properties[&"Aliases".to_string()], Variant::String) { + // alias.push(Alias { + // name, + // expansion: match_variant!(properties["Aliases"], Variant::String)["expansions"][i], + // }) + // } + + self.aliases = alias + } +} diff --git a/src/message/signalproxy/objects/backlogmanager.rs b/src/message/signalproxy/objects/backlogmanager.rs new file mode 100644 index 0000000..86a7f61 --- /dev/null +++ b/src/message/signalproxy/objects/backlogmanager.rs @@ -0,0 +1,161 @@ +// interface BacklogManager { +// +// +// // C->S calls +// +// /** +// * Loads backlog for `bufferId`, starting at message `first`, up to `last` +// * (plus `additional` more messages after `last`) but at most `limit` +// * messages total. +// */ +// requestBacklog(bufferId: BufferId, first: MsgId, last: MsgId, limit: Int, additional: Int) +// /** +// * Same as `requestBacklog`, but only messages of a certain message `type` +// * with certain `flags` set. +// */ +// requestBacklogFiltered(bufferId: BufferId, first: MsgId, last: MsgId, limit: Int, additional: Int, type: Int, flags: Int) +// /** +// * Same as `requestBacklog`, but applied to all buffers. +// */ +// requestBacklogAll(first: MsgId, last: MsgId, limit: Int, additional: Int) +// /** +// * Same as `requestBacklogFiltered`, but applied to all buffers. +// */ +// requestBacklogAllFiltered(first: MsgId, last: MsgId, limit: Int, additional: Int, type: Int, flags: Int) +// +// +// // S->C calls +// +// /** +// * The response to `requestBacklog`, with the messages encoded as QVariants +// * in the `messages` parameter. +// */ +// receiveBacklog(bufferId: BufferId, first: MsgId, last: MsgId, limit: Int, additional: Int, messages: QVariantList) +// /** +// * The response to `requestBacklogFiltered`, with the messages encoded as +// * QVariants in the `messages` parameter. +// */ +// receiveBacklogFiltered(bufferId: BufferId, first: MsgId, last: MsgId, limit: Int, additional: Int, type: Int, flags: Int, messages: QVariantList) +// /** +// * The response to `requestBacklogAll`, with the messages encoded as +// * QVariants in the `messages` parameter. +// */ +// receiveBacklogAll(first: MsgId, last: MsgId, limit: Int, additional: Int, messages: QVariantList) +// /** +// * The response to `requestBacklogAllFiltered`, with the messages encoded as +// * QVariants in the `messages` parameter. +// */ +// receiveBacklogAllFiltered(first: MsgId, last: MsgId, limit: Int, additional: Int, type: Int, flags: Int, messages: QVariantList) +// } + +use crate::primitive::VariantList; + +/// Receive and Request Backlog +/// All "request" functions are Client to Server and all "receive" functions are Server to Client +#[derive(Clone, Debug, std::cmp::PartialEq)] +pub struct BacklogManager {} + +impl BacklogManager { + /// Loads backlog for `bufferId`, starting at message `first`, up to `last` + /// (plus `additional` more messages after `last`) but at most `limit` + /// messages total. + fn requestBacklog( + self: Self, + buffer_id: u32, + first: u32, + last: u32, + limit: u32, + additional: u32, + ) { + unimplemented!() + } + + /// Same as `requestBacklog`, but only messages of a certain message `type` + /// with certain `flags` set. + fn requestBacklogFiltered( + self: Self, + buffer_id: u32, + first: u32, + last: u32, + limit: u32, + additional: u32, + msgtype: u32, + flags: u32, + ) { + unimplemented!() + } + + /// Same as `requestBacklog`, but applied to all buffers. + fn requestBacklogAll(self: Self, first: u32, last: u32, limit: u32, additional: u32) { + unimplemented!() + } + + /// Same as `requestBacklogFiltered`, but applied to all buffers. + fn requestBacklogAllFiltered( + self: Self, + first: u32, + last: u32, + limit: u32, + additional: u32, + msgtype: u32, + flags: u32, + ) { + unimplemented!() + } + + /// The response to `requestBacklog`, with the messages encoded as Variants + /// in the `messages` parameter. + fn receiveBacklog( + self: Self, + buffer_id: u32, + first: u32, + last: u32, + limit: u32, + additional: u32, + messages: VariantList, + ) { + unimplemented!() + } + + /// The response to `requestBacklogFiltered`, with the messages encoded as + /// Variants in the `messages` parameter. + fn receiveBacklogFiltered( + self: Self, + buffer_id: u32, + first: u32, + last: u32, + limit: u32, + additional: u32, + msgtype: u32, + flags: u32, + messages: VariantList, + ) { + unimplemented!() + } + + /// Same as `receiveBacklog`, but applied to all buffers. + fn receiveBacklogAll( + self: Self, + first: u32, + last: u32, + limit: u32, + additional: u32, + messages: VariantList, + ) { + unimplemented!() + } + + /// Same as `receiveBacklogFiltered`, but applied to all buffers. + fn receiveBacklogAllFiltered( + self: Self, + first: u32, + last: u32, + limit: u32, + additional: u32, + msgtype: u32, + flags: u32, + messages: VariantList, + ) { + unimplemented!() + } +} diff --git a/src/message/signalproxy/objects/buffersyncer.rs b/src/message/signalproxy/objects/buffersyncer.rs new file mode 100644 index 0000000..7ee4ca5 --- /dev/null +++ b/src/message/signalproxy/objects/buffersyncer.rs @@ -0,0 +1,74 @@ +use crate::message::signalproxy::MessageType; +use std::collections::HashMap; + +// use default_macro::default; +// #[default(crate::message::signalproxy::objects::BufferSyncerClient)] +pub struct BufferSyncer { + pub activities: HashMap<u32, MessageType>, + pub highlight_counts: HashMap<u32, u32>, + pub last_seen_msg: HashMap<u32, u32>, + pub marker_line: HashMap<u32, u32>, +} + +pub trait BufferSyncerServer { + fn activities(self: &Self) -> &HashMap<u32, MessageType>; + fn activities_mut(self: &mut Self) -> &mut HashMap<u32, MessageType>; + + fn highlight_counts(self: &Self) -> &HashMap<u32, u32>; + fn highlight_counts_mut(self: &mut Self) -> &mut HashMap<u32, u32>; + + fn last_seen_msg(self: &Self) -> &HashMap<u32, u32>; + fn last_seen_msg_mut(self: &mut Self) -> &mut HashMap<u32, u32>; + + fn marker_line(self: &Self) -> &HashMap<u32, u32>; + fn marker_line_mut(self: &mut Self) -> &mut HashMap<u32, u32>; + + fn request_mark_buffer_as_read(buffer: u32); + fn request_merge_buffers_permanently(buffer1: u32, buffer2: u32); + fn request_purge_buffer_ids(); + fn request_remove_buffer(buffer: u32); + fn request_rename_buffer(buffer: u32, new_name: String); + + fn request_set_last_seen_msg(self: &mut Self, buffer: u32, msgid: u32) { + self.last_seen_msg_mut().insert(buffer, msgid); + } + + fn request_set_marker_line(self: &mut Self, buffer: u32, msgid: u32) { + self.marker_line_mut().insert(buffer, msgid); + } +} + +pub trait BufferSyncerClient { + fn activities(self: &Self) -> &HashMap<u32, MessageType>; + fn activities_mut(self: &mut Self) -> &mut HashMap<u32, MessageType>; + + fn highlight_counts(self: &Self) -> &HashMap<u32, u32>; + fn highlight_counts_mut(self: &mut Self) -> &mut HashMap<u32, u32>; + + fn last_seen_msg(self: &Self) -> &HashMap<u32, u32>; + fn last_seen_msg_mut(self: &mut Self) -> &mut HashMap<u32, u32>; + + fn marker_line(self: &Self) -> &HashMap<u32, u32>; + fn marker_line_mut(self: &mut Self) -> &mut HashMap<u32, u32>; + + fn mark_buffer_as_read(buffer: u32); + fn merge_buffers_permanently(buffer1: u32, buffer2: u32); + fn remove_buffer(buffer: u32); + fn rename_buffer(buffer: u32, new_name: String); + + fn set_buffer_activity(self: &mut Self, buffer: u32, activity: MessageType) { + self.activities_mut().insert(buffer, activity); + } + + fn set_highlight_count(self: &mut Self, buffer: u32, count: u32) { + self.highlight_counts_mut().insert(buffer, count); + } + + fn set_last_seen_msg(self: &mut Self, buffer: u32, msgid: u32) { + self.last_seen_msg_mut().insert(buffer, msgid); + } + + fn set_marker_line(self: &mut Self, buffer: u32, msgid: u32) { + self.marker_line_mut().insert(buffer, msgid); + } +} diff --git a/src/message/signalproxy/objects/identity.rs b/src/message/signalproxy/objects/identity.rs new file mode 100644 index 0000000..a710e5d --- /dev/null +++ b/src/message/signalproxy/objects/identity.rs @@ -0,0 +1,119 @@ +use crate::primitive::{Variant, VariantMap}; + +#[derive(Debug, Clone)] +pub struct Identity { + identity_id: i32, + identity_name: String, + real_name: String, + nicks: Vec<String>, + away_nick: String, + away_nick_enabled: bool, + away_reason: String, + away_reason_enabled: bool, + auto_away_enabled: bool, + auto_away_time: i32, + auto_away_reason: String, + auto_away_reason_enabled: bool, + detach_away_enabled: bool, + detach_away_reason: String, + detach_away_reason_enabled: bool, + ident: String, + kick_reason: String, + part_reason: String, + quit_reason: String, +} + +impl From<VariantMap> for Identity { + fn from(input: VariantMap) -> Self { + Identity { + identity_id: match_variant!(input.get("identityId").unwrap(), Variant::i32), + identity_name: match_variant!(input.get("identityName").unwrap(), Variant::String), + real_name: match_variant!(input.get("realName").unwrap(), Variant::String), + nicks: match_variant!(input.get("nicks").unwrap(), Variant::StringList), + away_nick: match_variant!(input.get("awayNick").unwrap(), Variant::String), + away_nick_enabled: match_variant!(input.get("awayNickEnabled").unwrap(), Variant::bool), + away_reason: match_variant!(input.get("awayReason").unwrap(), Variant::String), + away_reason_enabled: match_variant!( + input.get("awayReasonEnabled").unwrap(), + Variant::bool + ), + auto_away_enabled: match_variant!(input.get("autoAwayEnabled").unwrap(), Variant::bool), + auto_away_time: match_variant!(input.get("autoAwayTime").unwrap(), Variant::i32), + auto_away_reason: match_variant!(input.get("autoAwayReason").unwrap(), Variant::String), + auto_away_reason_enabled: match_variant!( + input.get("autoAwayReasonEnabled").unwrap(), + Variant::bool + ), + detach_away_enabled: match_variant!( + input.get("detachAwayEnabled").unwrap(), + Variant::bool + ), + detach_away_reason: match_variant!( + input.get("detachAwayReason").unwrap(), + Variant::String + ), + detach_away_reason_enabled: match_variant!( + input.get("detachAwayReasonEnabled").unwrap(), + Variant::bool + ), + ident: match_variant!(input.get("ident").unwrap(), Variant::String), + kick_reason: match_variant!(input.get("kickReason").unwrap(), Variant::String), + part_reason: match_variant!(input.get("partReason").unwrap(), Variant::String), + quit_reason: match_variant!(input.get("quitReason").unwrap(), Variant::String), + } + } +} + +impl Into<std::collections::HashMap<String, Variant>> for Identity { + fn into(self) -> VariantMap { + let mut res = VariantMap::with_capacity(19); + + res.insert("identityId".to_string(), Variant::i32(self.identity_id)); + res.insert( + "identityName".to_string(), + Variant::String(self.identity_name), + ); + res.insert("realName".to_string(), Variant::String(self.real_name)); + res.insert("nicks".to_string(), Variant::StringList(self.nicks)); + res.insert("awayNick".to_string(), Variant::String(self.away_nick)); + res.insert( + "awayNickEnabled".to_string(), + Variant::bool(self.away_nick_enabled), + ); + res.insert("awayReason".to_string(), Variant::String(self.away_reason)); + res.insert( + "awayReasonEnabled".to_string(), + Variant::bool(self.away_reason_enabled), + ); + res.insert( + "autoAwayEnabled".to_string(), + Variant::bool(self.auto_away_enabled), + ); + res.insert( + "autoAwayTime".to_string(), + Variant::i32(self.auto_away_time), + ); + res.insert( + "autoAwayReason".to_string(), + Variant::String(self.auto_away_reason), + ); + res.insert( + "detachAwayEnabled".to_string(), + Variant::bool(self.detach_away_enabled), + ); + res.insert( + "detachAwayReason".to_string(), + Variant::String(self.detach_away_reason), + ); + res.insert( + "detachAwayReasonEnabled".to_string(), + Variant::bool(self.detach_away_reason_enabled), + ); + res.insert("ident".to_string(), Variant::String(self.ident)); + res.insert("kickReason".to_string(), Variant::String(self.kick_reason)); + res.insert("partReason".to_string(), Variant::String(self.part_reason)); + res.insert("quitReason".to_string(), Variant::String(self.quit_reason)); + + res + } +} diff --git a/src/message/signalproxy/objects/mod.rs b/src/message/signalproxy/objects/mod.rs new file mode 100644 index 0000000..a84f6fa --- /dev/null +++ b/src/message/signalproxy/objects/mod.rs @@ -0,0 +1,12 @@ +// mod aliasmanager; +// mod backlogmanager; + +mod buffersyncer; +mod identity; + +pub use buffersyncer::*; +pub use identity::*; + +pub trait Act { + fn act(self: Self); +} diff --git a/src/message/signalproxy/rpccall.rs b/src/message/signalproxy/rpccall.rs new file mode 100644 index 0000000..2eac86d --- /dev/null +++ b/src/message/signalproxy/rpccall.rs @@ -0,0 +1,59 @@ +use crate::message::MessageType; +use crate::primitive::Message; +use crate::primitive::{Variant, VariantList}; +use crate::{Deserialize, Serialize}; + +#[derive(Clone, Debug, std::cmp::PartialEq)] +pub enum RpcCall { + DisplayMessage(DisplayMessage), +} + +#[derive(Clone, Debug, std::cmp::PartialEq)] +pub struct DisplayMessage { + pub message: Message, +} + +// #[derive(Clone, Debug, std::cmp::PartialEq)] +// pub struct RpcCall { +// pub slot_name: String, +// pub params: VariantList, +// } + +impl Serialize for RpcCall { + fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> { + let mut res = VariantList::new(); + + res.push(Variant::i32(MessageType::RpcCall as i32)); + + match self { + RpcCall::DisplayMessage(msg) => { + res.push(Variant::StringUTF8("2displayMsg(Message)".to_string())); + res.push(Variant::Message(msg.message.clone())); + } + } + + res.serialize() + } +} + +impl Deserialize for RpcCall { + fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { + let (size, mut res) = VariantList::parse(&b)?; + + res.remove(0); + + let rpc = match_variant!(res.remove(0), Variant::StringUTF8); + + match rpc.as_str() { + "2displayMsg(Message)" => { + return Ok(( + size, + RpcCall::DisplayMessage(DisplayMessage { + message: match_variant!(res.remove(0), Variant::Message), + }), + )) + } + _ => unimplemented!(), + } + } +} diff --git a/src/message/signalproxy/syncmessage.rs b/src/message/signalproxy/syncmessage.rs new file mode 100644 index 0000000..737f3e0 --- /dev/null +++ b/src/message/signalproxy/syncmessage.rs @@ -0,0 +1,46 @@ +use crate::message::MessageType; +use crate::primitive::{Variant, VariantList}; +use crate::{Deserialize, Serialize}; + +#[derive(Clone, Debug, std::cmp::PartialEq)] +pub struct SyncMessage { + class_name: String, + object_name: String, + slot_name: String, + params: VariantList, +} + +// impl Act for SyncMessage {} + +impl Serialize for SyncMessage { + fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> { + let mut res = VariantList::new(); + + res.push(Variant::i32(MessageType::SyncMessage as i32)); + res.push(Variant::StringUTF8(self.class_name.clone())); + res.push(Variant::StringUTF8(self.object_name.clone())); + res.push(Variant::StringUTF8(self.slot_name.clone())); + + res.append(&mut self.params.clone()); + + res.serialize() + } +} + +impl Deserialize for SyncMessage { + fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { + let (size, mut res) = VariantList::parse(&b)?; + + res.remove(0); + + Ok(( + size, + Self { + class_name: match_variant!(res.remove(0), Variant::StringUTF8), + object_name: match_variant!(res.remove(0), Variant::StringUTF8), + slot_name: match_variant!(res.remove(0), Variant::StringUTF8), + params: res, + }, + )) + } +} diff --git a/src/primitive/datetime.rs b/src/primitive/datetime.rs index cbcdd51..fadd6a5 100644 --- a/src/primitive/datetime.rs +++ b/src/primitive/datetime.rs @@ -76,10 +76,18 @@ impl Deserialize for OffsetDateTime { let zone = TimeSpec::from(zone as i8); + // Default to unix epoch when one of these is set to -1 + if julian_day == -1 || millis_of_day == -1 { + return Ok((pos, OffsetDateTime::unix_epoch())); + } + let offset: UtcOffset; match zone { TimeSpec::LocalUnknown | TimeSpec::LocalStandard | TimeSpec::LocalDST => { - offset = UtcOffset::current_local_offset() + offset = UtcOffset::try_current_local_offset().unwrap_or_else(|_| { + log::warn!("could not get local offset defaulting to utc"); + UtcOffset::UTC + }) } TimeSpec::UTC => offset = UtcOffset::UTC, TimeSpec::OffsetFromUTC => { diff --git a/src/primitive/message.rs b/src/primitive/message.rs index 64b132d..56bae22 100644 --- a/src/primitive/message.rs +++ b/src/primitive/message.rs @@ -15,9 +15,20 @@ extern crate bytes; #[derive(Clone, Debug, std::cmp::PartialEq)] pub struct Message { /// The unique, sequential id for the message + /// i32 by default i64 if long-message-id features is enabled + #[cfg(feature = "long-message-id")] + #[cfg_attr(docsrs, doc(cfg(feature = "long-message-id")))] + pub msg_id: i64, + #[cfg(not(feature = "long-message-id"))] + #[cfg_attr(docsrs, doc(cfg(not(feature = "long-message-id"))))] pub msg_id: i32, - /// The timestamp of the message in UNIX time (32-bit, seconds, 64-bit if LONGMESSAGE feature enabled) + /// The timestamp of the message in UNIX time (32-bit, seconds, 64-bit if long-time feature enabled) + #[cfg(feature = "long-time")] + #[cfg_attr(docsrs, doc(cfg(feature = "long-time")))] pub timestamp: i64, + #[cfg(not(feature = "long-time"))] + #[cfg_attr(docsrs, doc(cfg(not(feature = "long-time"))))] + pub timestamp: i32, /// The message type as it's own type serialized as i32 pub msg_type: MessageType, /// The flags @@ -27,14 +38,17 @@ pub struct Message { /// The sender as nick!ident@host pub sender: String, /// The prefix modes of the sender. - /// Only Some when the SenderPrefix features is enabled - pub sender_prefixes: Option<String>, + #[cfg(feature = "sender-prefixes")] + #[cfg_attr(docsrs, doc(cfg(feature = "sender-prefixes")))] + pub sender_prefixes: String, /// The realName of the sender - /// Only Some when the RichMessage features is enabled - pub real_name: Option<String>, + #[cfg(feature = "rich-messages")] + #[cfg_attr(docsrs, doc(cfg(feature = "rich-messages")))] + pub real_name: String, /// The avatarUrl of the sender, if available - /// Only Some when the RichMessage features is enabled - pub avatar_url: Option<String>, + #[cfg(feature = "rich-messages")] + #[cfg_attr(docsrs, doc(cfg(feature = "rich-messages")))] + pub avatar_url: String, /// The message content, already stripped from CTCP formatting, but containing mIRC format codes pub content: String, } @@ -43,35 +57,28 @@ impl Serialize for Message { fn serialize(&self) -> Result<Vec<u8>, Error> { let mut values: Vec<u8> = Vec::new(); + #[cfg(feature = "long-message-id")] + values.append(&mut i64::serialize(&self.msg_id)?); + #[cfg(not(feature = "long-message-id"))] values.append(&mut i32::serialize(&self.msg_id)?); - // TODO LONGMESSAGE feature - if false { - values.append(&mut i64::serialize(&self.timestamp)?); - } else { - values.append(&mut i32::serialize(&(self.timestamp as i32))?); - } + #[cfg(feature = "long-time")] + values.append(&mut i64::serialize(&self.timestamp)?); + #[cfg(not(feature = "long-time"))] + values.append(&mut i32::serialize(&(self.timestamp as i32))?); values.append(&mut i32::serialize(&(self.msg_type as i32))?); values.append(&mut i8::serialize(&(self.flags as i8))?); values.append(&mut BufferInfo::serialize(&self.buffer)?); values.append(&mut String::serialize_utf8(&self.sender)?); - // TODO SenderPrefixes feature - if false { - if let Some(x) = &self.sender_prefixes { - values.append(&mut String::serialize_utf8(&x)?); - } - } + #[cfg(feature = "sender-prefixes")] + values.append(&mut String::serialize_utf8(&self.sender_prefixes)?); - // TODO RichMessages feature - if false { - if let Some(x) = &self.real_name { - values.append(&mut String::serialize_utf8(&x)?); - } - if let Some(x) = &self.avatar_url { - values.append(&mut String::serialize_utf8(&x)?); - } + #[cfg(feature = "rich-messages")] + { + values.append(&mut String::serialize_utf8(&self.real_name)?); + values.append(&mut String::serialize_utf8(&self.avatar_url)?); } values.append(&mut String::serialize_utf8(&self.content)?); @@ -83,19 +90,27 @@ impl Serialize for Message { impl Deserialize for Message { fn parse(b: &[u8]) -> Result<(usize, Self), Error> { let mut pos = 0; + #[cfg(feature = "long-message-id")] + let (parsed, msg_id) = i64::parse(&b[pos..])?; + #[cfg(not(feature = "long-message-id"))] let (parsed, msg_id) = i32::parse(&b[pos..])?; pos += parsed; // TODO LONGMESSAGES feature let timestamp; - if false { + + #[cfg(feature = "long-time")] + { let (parsed, temp_timestamp) = i64::parse(&b[pos..])?; pos += parsed; timestamp = temp_timestamp; - } else { + } + + #[cfg(not(feature = "long-time"))] + { let (parsed, temp_timestamp) = i32::parse(&b[pos..])?; pos += parsed; - timestamp = temp_timestamp as i64; + timestamp = temp_timestamp; } let (parsed, msg_type) = i32::parse(&b[pos..])?; @@ -107,24 +122,27 @@ impl Deserialize for Message { let (parsed, sender) = String::parse_utf8(&b[pos..])?; pos += parsed; - // TODO SenderPrefixes feature - let mut sender_prefixes = None; - if false { + #[cfg(feature = "sender-prefixes")] + let sender_prefixes: String; + #[cfg(feature = "sender-prefixes")] + { let (parsed, temp) = String::parse_utf8(&b[pos..])?; - sender_prefixes = Some(temp); + sender_prefixes = temp; pos += parsed; } - // TODO SenderPrefixes feature - let mut real_name = None; - let mut avatar_url = None; - if false { + #[cfg(feature = "rich-messages")] + let real_name: String; + #[cfg(feature = "rich-messages")] + let avatar_url: String; + #[cfg(feature = "rich-messages")] + { let (parsed, temp) = String::parse_utf8(&b[pos..])?; - real_name = Some(temp); + real_name = temp; pos += parsed; let (parsed, temp) = String::parse_utf8(&b[pos..])?; - avatar_url = Some(temp); + avatar_url = temp; pos += parsed; } @@ -140,8 +158,11 @@ impl Deserialize for Message { flags, buffer, sender, + #[cfg(feature = "sender-prefixes")] sender_prefixes, + #[cfg(feature = "rich-messages")] real_name, + #[cfg(feature = "rich-messages")] avatar_url, content, }, diff --git a/src/primitive/string.rs b/src/primitive/string.rs index 86bcdec..dcd4f7c 100644 --- a/src/primitive/string.rs +++ b/src/primitive/string.rs @@ -7,8 +7,8 @@ use failure::Error; use log::trace; -use crate::{Deserialize, DeserializeUTF8, Serialize, SerializeUTF8}; use crate::util; +use crate::{Deserialize, DeserializeUTF8, Serialize, SerializeUTF8}; /// We Shadow the String type here as we can only use impl on types in our own scope. /// @@ -33,7 +33,6 @@ impl SerializeUTF8 for String { fn serialize_utf8(&self) -> Result<Vec<u8>, Error> { let mut res: Vec<u8> = Vec::new(); res.extend(self.clone().into_bytes()); - res.extend(vec![0x00]); util::prepend_byte_len(&mut res); return Ok(res); } @@ -64,6 +63,7 @@ impl Deserialize for String { } let res: String = String::from_utf16(&chars).unwrap(); + trace!("parsed string: {}", res); return Ok((pos, res)); } } @@ -81,6 +81,7 @@ impl DeserializeUTF8 for String { let ulen = len as usize; let mut res: String = String::from_utf8(b[4..(ulen + 4)].to_vec())?; + trace!("parsed string: {}", res); // If the last byte is zero remove it // Receiving a string as bytearray will sometimes have @@ -89,6 +90,8 @@ impl DeserializeUTF8 for String { let _ = res.pop(); } + trace!("parsed string after trunc: {}", res); + return Ok((ulen + 4, res)); } } diff --git a/src/primitive/variant.rs b/src/primitive/variant.rs index 9242d90..be2bebe 100644 --- a/src/primitive/variant.rs +++ b/src/primitive/variant.rs @@ -36,6 +36,7 @@ pub enum Variant { VariantList(VariantList), String(String), StringUTF8(String), + ByteArray(String), StringList(StringList), bool(bool), u64(u64), @@ -77,6 +78,11 @@ impl Serialize for Variant { res.extend(unknown.to_be_bytes().iter()); res.extend(v.serialize_utf8()?.iter()); } + Variant::ByteArray(v) => { + res.extend(primitive::QBYTEARRAY.to_be_bytes().iter()); + res.extend(unknown.to_be_bytes().iter()); + res.extend(v.serialize_utf8()?.iter()); + } Variant::StringList(v) => { res.extend(primitive::QSTRINGLIST.to_be_bytes().iter()); res.extend(unknown.to_be_bytes().iter()); @@ -201,8 +207,7 @@ impl Deserialize for Variant { return Ok((len + vlen, Variant::StringList(value.clone()))); } primitive::QDATETIME => { - trace!(target: "primitive::Variant", "Parsing Variant: Date"); - // let (vlen, value) = DateTime::parse(&b[len..])?; + trace!(target: "primitive::Variant", "Parsing Variant: DateTime"); let (vlen, value): (usize, DateTime) = Deserialize::parse(&b[len..])?; return Ok((len + vlen, Variant::DateTime(value.clone()))); } @@ -269,12 +274,26 @@ impl Deserialize for Variant { return Ok((len + user_type_len + vlen, Variant::VariantMap(value))); } // As i32 - "BufferId" | "IdentityId" | "NetworkId" | "MsgId" => { + "BufferId" | "IdentityId" | "NetworkId" => { trace!(target: "primitive::Variant", "UserType is i32"); let (vlen, value) = i32::parse(&b[(len + user_type_len)..])?; return Ok((len + user_type_len + vlen, Variant::i32(value))); } + #[cfg(not(feature = "long-message-id"))] + "MsgId" => { + trace!(target: "primitive::Variant", "UserType is i32"); + + let (vlen, value) = i32::parse(&b[(len + user_type_len)..])?; + return Ok((len + user_type_len + vlen, Variant::i32(value))); + } + #[cfg(feature = "long-message-id")] + "MsgId" => { + trace!(target: "primitive::Variant", "UserType is i64"); + + let (vlen, value) = i64::parse(&b[(len + user_type_len)..])?; + return Ok((len + user_type_len + vlen, Variant::i64(value))); + } // As i64 "PeerPtr" => { trace!(target: "primitive::Variant", "UserType is i64"); diff --git a/src/primitive/variantlist.rs b/src/primitive/variantlist.rs index 452b927..a802864 100644 --- a/src/primitive/variantlist.rs +++ b/src/primitive/variantlist.rs @@ -40,6 +40,7 @@ impl Deserialize for VariantList { for i in 0..len { trace!(target: "primitive::VariantList", "Parsing VariantList element: {:?}", i); let (vlen, val) = Variant::parse(&b[pos..])?; + trace!("parsed variant: {:?}", val); res.push(val); pos += vlen; } diff --git a/src/session/mod.rs b/src/session/mod.rs new file mode 100644 index 0000000..67045c9 --- /dev/null +++ b/src/session/mod.rs @@ -0,0 +1,2 @@ +/// The Session Trait is the main point of entry and implements the basic logic +pub trait Session {} |
