diff --git a/Cargo.lock b/Cargo.lock index 1d07427..93efb5b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,6 +27,18 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "base64" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" + [[package]] name = "bitflags" version = "1.2.1" @@ -34,10 +46,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] -name = "byteorder" -version = "1.3.2" +name = "bumpalo" +version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" +checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" [[package]] name = "cc" @@ -79,6 +103,22 @@ dependencies = [ "bitflags", ] +[[package]] +name = "core-foundation" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" + [[package]] name = "crc32fast" version = "1.2.0" @@ -88,6 +128,15 @@ dependencies = [ "cfg-if 0.1.10", ] +[[package]] +name = "ct-logs" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1a816186fa68d9e426e3cb4ae4dff1fcd8e4a2c34b781bf7a822574a0d0aac8" +dependencies = [ + "sct", +] + [[package]] name = "deflate" version = "0.7.20" @@ -110,6 +159,98 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +[[package]] +name = "futures" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b3b0c040a1fe6529d30b3c5944b280c7f0dcb2930d2c3062bca967b602583d0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce79c6a52a299137a6013061e0cf0e688fce5d7f1bc60125f520912fdb29ec25" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "098cd1c6dda6ca01650f1a37a794245eb73181d0d4d4e955e2f3c37db7af1815" + +[[package]] +name = "futures-executor" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ee9ca2f7eb4475772cf39dd1cd06208dce2670ad38f4d9c7262b3e15f127068" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "365a1a1fb30ea1c03a830fdb2158f5236833ac81fa0ad12fe35b29cddc35cb04" + +[[package]] +name = "futures-macro" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f8719ca0e1f3c5e34f3efe4570ef2c0610ca6da85ae7990d472e9cbfba13664" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5629433c555de3d82861a7a4e3794a4c40040390907cfbfd7143a92a426c23" + +[[package]] +name = "futures-task" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba7aa51095076f3ba6d9a1f702f74bd05ec65f555d70d2033d55ba8d69f581bc" + +[[package]] +name = "futures-util" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "036a2107cdeb57f6d7322f1b6c363dad67cd63ca3b7d1b925bdf75bd5d96cda9" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "proc-macro-hack", + "proc-macro-nested", + "slab", +] + [[package]] name = "generator" version = "0.6.23" @@ -123,6 +264,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "getrandom" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi", +] + [[package]] name = "gl" version = "0.14.0" @@ -149,6 +301,15 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb24d4e1b92ceed0450bbf803ac894b597c5b8d0e16f175f7ef28c42024d8cbd" +[[package]] +name = "hermit-abi" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" +dependencies = [ + "libc", +] + [[package]] name = "inflate" version = "0.4.5" @@ -158,6 +319,15 @@ dependencies = [ "adler32", ] +[[package]] +name = "instant" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" +dependencies = [ + "cfg-if 1.0.0", +] + [[package]] name = "inter_quake_model" version = "0.1.0" @@ -178,6 +348,15 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" +[[package]] +name = "js-sys" +version = "0.3.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d99f9e3e84b8f67f846ef5b4cbbc3b1c29f6c759fcbce6f01aa0e73d932a24c" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "khronos_api" version = "3.1.0" @@ -192,9 +371,18 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.81" +version = "0.2.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb" +checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" + +[[package]] +name = "lock_api" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb" +dependencies = [ + "scopeguard", +] [[package]] name = "log" @@ -233,6 +421,43 @@ dependencies = [ "regex-automata", ] +[[package]] +name = "memchr" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" + +[[package]] +name = "mio" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf80d3e903b34e0bd7282b218398aec54e082c840d9baf8339e0080a0c542956" +dependencies = [ + "libc", + "log", + "miow", + "ntapi", + "winapi", +] + +[[package]] +name = "miow" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" +dependencies = [ + "winapi", +] + +[[package]] +name = "ntapi" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a31937dea023539c72ddae0e3571deadc1414b300483fa7aaec176168cfa9d2" +dependencies = [ + "winapi", +] + [[package]] name = "num" version = "0.1.42" @@ -250,7 +475,7 @@ version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" dependencies = [ - "autocfg", + "autocfg 0.1.7", "num-traits", ] @@ -260,20 +485,36 @@ version = "0.1.39" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76bd5272412d173d6bf9afdf98db8612bbabc9a7a830b7bfc9c188911716132e" dependencies = [ - "autocfg", + "autocfg 0.1.7", "num-integer", "num-traits", ] [[package]] name = "num-traits" -version = "0.2.10" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4c81ffc11c212fa327657cb19dd85eb7419e163b5b076bede2bdb5c974c07e4" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" dependencies = [ - "autocfg", + "autocfg 1.0.1", ] +[[package]] +name = "num_cpus" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" + [[package]] name = "opengl_rust" version = "0.1.0" @@ -281,6 +522,8 @@ dependencies = [ "anyhow", "byteorder", "float-ord", + "futures", + "futures-util", "gl", "glam", "inter_quake_model", @@ -288,24 +531,77 @@ dependencies = [ "maplit", "partial-min-max", "png", - "rand", + "quinn", + "rand 0.6.5", + "rcgen", + "rmp-serde", "sdl2", + "serde", + "tokio", "tracing", "tracing-subscriber", ] +[[package]] +name = "openssl-probe" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" + +[[package]] +name = "parking_lot" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ccb628cad4f84851442432c60ad8e1f607e29752d0bf072cbd0baf28aa34272" +dependencies = [ + "cfg-if 1.0.0", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + [[package]] name = "partial-min-max" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6448add382c60bbbc64f9dab41309a12ec530c05191601042f911356ac09758c" +[[package]] +name = "pem" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd56cbd21fea48d0c440b41cd69c589faacade08c992d9a54e471b79d0fd13eb" +dependencies = [ + "base64", + "once_cell", + "regex", +] + [[package]] name = "pin-project-lite" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c" +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "png" version = "0.15.3" @@ -318,6 +614,24 @@ dependencies = [ "inflate", ] +[[package]] +name = "ppv-lite86" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" + +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro-nested" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" + [[package]] name = "proc-macro2" version = "1.0.24" @@ -327,6 +641,45 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "quinn" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c82c0a393b300104f989f3db8b8637c0d11f7a32a9c214560b47849ba8f119aa" +dependencies = [ + "bytes", + "futures", + "lazy_static", + "libc", + "mio", + "quinn-proto", + "rustls", + "socket2", + "thiserror", + "tokio", + "tracing", + "webpki", +] + +[[package]] +name = "quinn-proto" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "047aa96ec7ee6acabad7a1318dff72e9aff8994316bf2166c9b94cbec78ca54c" +dependencies = [ + "bytes", + "ct-logs", + "rand 0.8.3", + "ring", + "rustls", + "rustls-native-certs", + "slab", + "thiserror", + "tinyvec", + "tracing", + "webpki", +] + [[package]] name = "quote" version = "1.0.8" @@ -342,11 +695,11 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" dependencies = [ - "autocfg", + "autocfg 0.1.7", "libc", - "rand_chacha", + "rand_chacha 0.1.1", "rand_core 0.4.2", - "rand_hc", + "rand_hc 0.1.0", "rand_isaac", "rand_jitter", "rand_os", @@ -355,16 +708,38 @@ dependencies = [ "winapi", ] +[[package]] +name = "rand" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" +dependencies = [ + "libc", + "rand_chacha 0.3.0", + "rand_core 0.6.2", + "rand_hc 0.3.0", +] + [[package]] name = "rand_chacha" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" dependencies = [ - "autocfg", + "autocfg 0.1.7", "rand_core 0.3.1", ] +[[package]] +name = "rand_chacha" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.2", +] + [[package]] name = "rand_core" version = "0.3.1" @@ -380,6 +755,15 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" +[[package]] +name = "rand_core" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" +dependencies = [ + "getrandom", +] + [[package]] name = "rand_hc" version = "0.1.0" @@ -389,6 +773,15 @@ dependencies = [ "rand_core 0.3.1", ] +[[package]] +name = "rand_hc" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" +dependencies = [ + "rand_core 0.6.2", +] + [[package]] name = "rand_isaac" version = "0.1.1" @@ -429,7 +822,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" dependencies = [ - "autocfg", + "autocfg 0.1.7", "rand_core 0.4.2", ] @@ -442,6 +835,18 @@ dependencies = [ "rand_core 0.3.1", ] +[[package]] +name = "rcgen" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48b4fc1b81d685fcd442a86da2e2c829d9e353142633a8159f42bf28e7e94428" +dependencies = [ + "chrono", + "pem", + "ring", + "yasna", +] + [[package]] name = "rdrand" version = "0.4.0" @@ -451,6 +856,12 @@ dependencies = [ "rand_core 0.3.1", ] +[[package]] +name = "redox_syscall" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" + [[package]] name = "regex" version = "1.4.2" @@ -476,6 +887,42 @@ version = "0.6.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi", +] + +[[package]] +name = "rmp" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f55e5fa1446c4d5dd1f5daeed2a4fe193071771a2636274d0d7a3b082aa7ad6" +dependencies = [ + "byteorder", + "num-traits", +] + +[[package]] +name = "rmp-serde" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "839395ef53057db96b84c9238ab29e1a13f2e5c8ec9f66bef853ab4197303924" +dependencies = [ + "byteorder", + "rmp", + "serde", +] + [[package]] name = "rustc_version" version = "0.2.3" @@ -485,18 +932,69 @@ dependencies = [ "semver", ] +[[package]] +name = "rustls" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" +dependencies = [ + "base64", + "log", + "ring", + "sct", + "webpki", +] + +[[package]] +name = "rustls-native-certs" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a07b7c1885bd8ed3831c289b7870b13ef46fe0e856d288c30d9cc17d75a2092" +dependencies = [ + "openssl-probe", + "rustls", + "schannel", + "security-framework", +] + [[package]] name = "ryu" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +[[package]] +name = "schannel" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" +dependencies = [ + "lazy_static", + "winapi", +] + [[package]] name = "scoped-tls" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "sct" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "sdl2" version = "0.32.2" @@ -507,7 +1005,7 @@ dependencies = [ "lazy_static", "libc", "num", - "rand", + "rand 0.6.5", "sdl2-sys", ] @@ -521,6 +1019,29 @@ dependencies = [ "libc", ] +[[package]] +name = "security-framework" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3670b1d2fdf6084d192bc71ead7aabe6c06aa2ea3fbd9cc3ac111fa5c2b1bd84" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3676258fd3cfe2c9a0ec99ce3038798d847ce3e4bb17746373eb9f0f1ac16339" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" version = "0.9.0" @@ -538,18 +1059,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.118" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800" +checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.118" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df" +checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" dependencies = [ "proc-macro2", "quote", @@ -577,6 +1098,21 @@ dependencies = [ "loom", ] +[[package]] +name = "signal-hook-registry" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527" + [[package]] name = "smallvec" version = "1.5.1" @@ -584,16 +1120,53 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae524f056d7d770e174287294f562e95044c68e88dec909a00d2094805db9d75" [[package]] -name = "syn" -version = "1.0.55" +name = "socket2" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a571a711dddd09019ccc628e1b17fe87c59b09d513c06c026877aa708334f37a" +checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "winapi", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "syn" +version = "1.0.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6498a9efc342871f91cc2d0d694c674368b4ceb40f62b65a7a08c3792935e702" dependencies = [ "proc-macro2", "quote", "unicode-xid", ] +[[package]] +name = "thiserror" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "thread_local" version = "1.0.1" @@ -614,6 +1187,52 @@ dependencies = [ "winapi", ] +[[package]] +name = "tinyvec" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b5220f05bb7de7f3f53c7c065e1199b3172696fe2db9f9c4d8ad9b4ee74c342" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "tokio" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83f0c8e7c0addab50b663055baf787d0af7f413a46e6e7fb9559a4e4db7137a5" +dependencies = [ + "autocfg 1.0.1", + "bytes", + "libc", + "memchr", + "mio", + "num_cpus", + "once_cell", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "tokio-macros", + "winapi", +] + +[[package]] +name = "tokio-macros" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caf7b11a536f46a809a8a9f0bb4237020f70ecbf115b842360afb127ea2fda57" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "tracing" version = "0.1.22" @@ -695,12 +1314,92 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + [[package]] name = "wasi" version = "0.10.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +[[package]] +name = "wasm-bindgen" +version = "0.2.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83240549659d187488f91f33c0f8547cbfef0b2088bc470c116d1d260ef623d9" +dependencies = [ + "cfg-if 1.0.0", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae70622411ca953215ca6d06d3ebeb1e915f0f6613e3b495122878d7ebec7dae" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e734d91443f177bfdb41969de821e15c516931c3c3db3d318fa1b68975d0f6f" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53739ff08c8a68b0fdbcd54c372b8ab800b1449ab3c9d706503bc7dd1621b2c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9a543ae66aa233d14bb765ed9af4a33e81b8b58d1584cf1b47ff8cd0b9e4489" + +[[package]] +name = "web-sys" +version = "0.3.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a905d57e488fec8861446d3393670fb50d27a262344013181c2cdf9fff5481be" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki" +version = "0.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "winapi" version = "0.3.8" @@ -728,3 +1427,12 @@ name = "xml-rs" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "541b12c998c5b56aa2b4e6f18f03664eef9a4fd0a246a55594efae6cc2d964b5" + +[[package]] +name = "yasna" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e262a29d0e61ccf2b6190d7050d4b237535fc76ce4c1210d9caa316f71dffa75" +dependencies = [ + "chrono", +] diff --git a/Cargo.toml b/Cargo.toml index c4e99a7..5ac0ee7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,14 +11,21 @@ edition = "2018" anyhow = "1.0.36" byteorder = "1.3.2" float-ord = "0.2.0" +futures = "0.3.8" +futures-util = "0.3.9" gl = "0.14.0" glam = "0.8.5" iota = "0.2.1" maplit = "1.0.2" partial-min-max = "0.4.0" png = "0.15.3" +quinn = "0.7.2" rand = "0.6.5" +rcgen = "0.8.11" +rmp-serde = "0.15.4" +serde = { version = "1.0.125", features = ["derive"] } sdl2 = "0.32.2" +tokio = { version = "1.5.0", features = ["full"] } tracing = "0.1.22" tracing-subscriber = "0.2.15" diff --git a/src/bin/quic_server.rs b/src/bin/quic_server.rs new file mode 100644 index 0000000..aacd205 --- /dev/null +++ b/src/bin/quic_server.rs @@ -0,0 +1,125 @@ +use std::{ + sync::Arc, +}; + +use futures::StreamExt; +use tokio::sync::Mutex; + +use opengl_rust::{ + network_protocol::*, + quinn_common::make_server_endpoint, +}; + +#[tokio::main] +async fn main () -> anyhow::Result <()> { + let server_addr = "127.0.0.1:5000".parse().unwrap(); + let (mut incoming, server_cert) = make_server_endpoint(server_addr)?; + + let state = NetworkedState { + positions: vec! [ + (32.0, 32.0), + ], + }; + let state = Arc::new (Mutex::new (state)); + // let connected_players = Arc::new (Mutex::new (vec! [])); + + // accept a single connection + let server_task = tokio::spawn (async move { + use opengl_rust::timestep::TimeStep; + + let incoming_conn = incoming.next().await.unwrap(); + let new_conn = incoming_conn.await.unwrap(); + println!( + "[server] connection accepted: addr={}", + new_conn.connection.remote_address() + ); + + let quinn::NewConnection { + connection, + mut datagrams, + .. + } = new_conn; + + let mut i = 0_u64; + + let cmd = Arc::new (Mutex::new (NetworkCommand::default ())); + let cmd_2 = Arc::clone (&cmd); + + // Read player commands + tokio::spawn (async move { + while let Some (Ok (datagram)) = datagrams.next ().await { + let cmd: NetworkCommand = rmp_serde::from_slice (&datagram)?; + let mut guard = cmd_2.lock ().await; + *guard = cmd; + } + + Ok::<_, anyhow::Error> (()) + }); + + let mut time_step = TimeStep::new (120, 1000); + let mut state = NetworkedState { + positions: vec! [ + (32.0, 32.0), + ], + }; + + loop { + let cmd = { + let guard = cmd.lock ().await; + guard.clone () + }; + let frames_to_do = time_step.step (); + for _ in 0..frames_to_do { + let speed = 0.25; + if cmd.left { + state.positions [0].0 -= speed; + } + if cmd.right { + state.positions [0].0 += speed; + } + if cmd.up { + state.positions [0].1 += speed; + } + if cmd.down { + state.positions [0].1 -= speed; + } + } + + let bytes = rmp_serde::to_vec (&state)?; + connection.send_datagram (bytes.into ())?; + + i += 1; + tokio::time::sleep (std::time::Duration::from_millis(16)).await; + } + + // Dropping all handles associated with a connection implicitly closes it + Ok::<_, anyhow::Error> (()) + }); + + tokio::fs::write ("quic_server.crt", &server_cert).await?; + + /* + let endpoint = make_client_endpoint("0.0.0.0:0".parse().unwrap(), &[&server_cert])?; + // connect to server + let quinn::NewConnection { + connection, + mut uni_streams, + .. + } = endpoint + .connect(&server_addr, "localhost") + .unwrap() + .await + .unwrap(); + println!("[client] connected: addr={}", connection.remote_address()); + + // Waiting for a stream will complete with an error when the server closes the connection + let _ = uni_streams.next().await; + + // Give the server has a chance to clean up + endpoint.wait_idle().await; + */ + + server_task.await??; + + Ok(()) +} diff --git a/src/bin/terrain.rs b/src/bin/terrain.rs index 30abd86..f329627 100644 --- a/src/bin/terrain.rs +++ b/src/bin/terrain.rs @@ -27,6 +27,8 @@ use tracing::{ use opengl_rust::{ glezz, gpu_buffers, + network_protocol::*, + quinn_common::make_client_endpoint, shader, timestep::TimeStep, }; @@ -69,7 +71,11 @@ impl ShaderLocations { } #[instrument (level = "trace", skip (ctx, state))] -fn draw_graphics (ctx: &GraphicsContext, state: &GameState) +fn draw_graphics ( + ctx: &GraphicsContext, + state: &GameState, + bumps: &[(f32, f32)], +) -> anyhow::Result <()> { let shader_locs = &ctx.shader_locations; @@ -94,7 +100,7 @@ fn draw_graphics (ctx: &GraphicsContext, state: &GameState) let view_mat = proj_mat * Mat4::from_translation (Vec3::from ((0.0, 0.0, -80.0))) * Mat4::from_rotation_x (-60.0 * 3.14159 / 180.0) * - Mat4::from_rotation_z ((state.logic_frames % spin_period) as f32 * 3.1415926535 * 2.0 / spin_period as f32) * + // Mat4::from_rotation_z ((state.logic_frames % spin_period) as f32 * 3.1415926535 * 2.0 / spin_period as f32) * Mat4::from_translation (Vec3::from ((-32.0, -32.0, -5.0))); let mvp = view_mat; @@ -115,10 +121,7 @@ fn draw_graphics (ctx: &GraphicsContext, state: &GameState) let ClientArrays { vertexes, indexes, - } = make_heightmap_arrays (&[ - (32.0, 48.0), - (32.0 + 16.0 * bump_theta.cos (), 32.0 + 16.0 * bump_theta.sin ()), - ]); + } = make_heightmap_arrays (bumps); upload_vertexes (&vertexes)?; @@ -241,7 +244,13 @@ fn upload_vertexes (vertexes: &[f32]) -> anyhow::Result <()> { Ok (()) } -fn main () -> anyhow::Result <()> { +#[tokio::main] +async fn main () -> anyhow::Result <()> { + use std::sync::Arc; + + use futures_util::StreamExt; + use tokio::sync::Mutex; + tracing_subscriber::fmt::fmt () .with_env_filter (tracing_subscriber::EnvFilter::from_default_env()) .with_span_events (tracing_subscriber::fmt::format::FmtSpan::CLOSE) @@ -314,26 +323,86 @@ fn main () -> anyhow::Result <()> { logic_frames: 0, }; + let server_cert = tokio::fs::read ("quic_server.crt").await?; + let server_addr = "127.0.0.1:5000".parse().unwrap(); + let endpoint = make_client_endpoint("0.0.0.0:0".parse().unwrap(), &[&server_cert])?; + // connect to server + let quinn::NewConnection { + connection, + mut datagrams, + .. + } = endpoint + .connect(&server_addr, "localhost") + .unwrap() + .await + .unwrap(); + println!("[client] connected: addr={}", connection.remote_address()); + + let networked_state = Arc::new (Mutex::new (NetworkedState::default ())); + let networked_state_2 = Arc::clone (&networked_state); + + tokio::spawn (async move { + while let Some (Ok (datagram)) = datagrams.next ().await { + let state = rmp_serde::from_slice (&datagram)?; + let mut guard = networked_state_2.lock ().await; + *guard = state; + } + + Ok::<_, anyhow::Error> (()) + }); + 'running: loop { let frames_to_do = time_step.step (); let _mouse = event_pump.mouse_state (); + let mut cmd = NetworkCommand::default (); + for event in event_pump.poll_iter() { match event { Event::Quit {..} | Event::KeyDown { keycode: Some (Keycode::Escape), .. } => { break 'running }, + Event::KeyDown { keycode: Some (keycode), .. } => { + match keycode { + Keycode::Left => cmd.left = true, + Keycode::Right => cmd.right = true, + Keycode::Up => cmd.up = true, + Keycode::Down => cmd.right = true, + _ => (), + } + }, _ => (), } } + let keyboard_state = event_pump.keyboard_state (); + if keyboard_state.is_scancode_pressed (Scancode::Left) { + cmd.left = true + } + if keyboard_state.is_scancode_pressed (Scancode::Right) { + cmd.right = true + } + if keyboard_state.is_scancode_pressed (Scancode::Up) { + cmd.up = true + } + if keyboard_state.is_scancode_pressed (Scancode::Down) { + cmd.down = true + } + + let bytes = rmp_serde::to_vec (&cmd)?; + connection.send_datagram (bytes.into ())?; + for _ in 0..frames_to_do { game_state.logic_frames += 1; } - draw_graphics (&graphics_ctx, &game_state)?; + let state = { + let guard = networked_state.lock ().await; + guard.clone () + }; + draw_graphics (&graphics_ctx, &game_state, &state.positions)?; graphics_frames += 1; std::thread::sleep (Duration::from_millis (15)); diff --git a/src/lib.rs b/src/lib.rs index 3375ddf..9713385 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,9 @@ pub mod file; pub mod glezz; pub mod gl_state; pub mod gpu_buffers; +pub mod network_protocol; pub mod physics; +pub mod quinn_common; pub mod renderable_model; pub mod shader; pub mod shader_closure; diff --git a/src/network_protocol.rs b/src/network_protocol.rs new file mode 100644 index 0000000..c22f3c1 --- /dev/null +++ b/src/network_protocol.rs @@ -0,0 +1,14 @@ +use serde::{Deserialize, Serialize}; + +#[derive (Clone, Default, Deserialize, Serialize)] +pub struct NetworkedState { + pub positions: Vec <(f32, f32)>, +} + +#[derive (Clone, Default, Deserialize, Serialize)] +pub struct NetworkCommand { + pub left: bool, + pub right: bool, + pub up: bool, + pub down: bool, +} diff --git a/src/quinn_common.rs b/src/quinn_common.rs new file mode 100644 index 0000000..1f64fc1 --- /dev/null +++ b/src/quinn_common.rs @@ -0,0 +1,73 @@ +use quinn::{ + Certificate, CertificateChain, ClientConfig, ClientConfigBuilder, Endpoint, Incoming, + PrivateKey, ServerConfig, ServerConfigBuilder, TransportConfig, +}; +use std::{error::Error, net::SocketAddr, sync::Arc}; + +/// Constructs a QUIC endpoint configured for use a client only. +/// +/// ## Args +/// +/// - server_certs: list of trusted certificates. +#[allow(unused)] +pub fn make_client_endpoint( + bind_addr: SocketAddr, + server_certs: &[&[u8]], +) -> anyhow::Result { + let client_cfg = configure_client(server_certs)?; + let mut endpoint_builder = Endpoint::builder(); + endpoint_builder.default_client_config(client_cfg); + let (endpoint, _incoming) = endpoint_builder.bind(&bind_addr)?; + Ok(endpoint) +} + +/// Constructs a QUIC endpoint configured to listen for incoming connections on a certain address +/// and port. +/// +/// ## Returns +/// +/// - a stream of incoming QUIC connections +/// - server certificate serialized into DER format +#[allow(unused)] +pub fn make_server_endpoint(bind_addr: SocketAddr) -> anyhow::Result<(Incoming, Vec)> { + let (server_config, server_cert) = configure_server()?; + let mut endpoint_builder = Endpoint::builder(); + endpoint_builder.listen(server_config); + let (_endpoint, incoming) = endpoint_builder.bind(&bind_addr)?; + Ok((incoming, server_cert)) +} + +/// Builds default quinn client config and trusts given certificates. +/// +/// ## Args +/// +/// - server_certs: a list of trusted certificates in DER format. +fn configure_client(server_certs: &[&[u8]]) -> anyhow::Result { + let mut cfg_builder = ClientConfigBuilder::default(); + for cert in server_certs { + cfg_builder.add_certificate_authority(Certificate::from_der(&cert)?)?; + } + Ok(cfg_builder.build()) +} + +/// Returns default server configuration along with its certificate. +#[allow(clippy::field_reassign_with_default)] // https://github.com/rust-lang/rust-clippy/issues/6527 +fn configure_server() -> anyhow::Result<(ServerConfig, Vec)> { + let cert = rcgen::generate_simple_self_signed(vec!["localhost".into()]).unwrap(); + let cert_der = cert.serialize_der().unwrap(); + let priv_key = cert.serialize_private_key_der(); + let priv_key = PrivateKey::from_der(&priv_key)?; + + let mut transport_config = TransportConfig::default(); + transport_config.max_concurrent_uni_streams(0).unwrap(); + let mut server_config = ServerConfig::default(); + server_config.transport = Arc::new(transport_config); + let mut cfg_builder = ServerConfigBuilder::new(server_config); + let cert = Certificate::from_der(&cert_der)?; + cfg_builder.certificate(CertificateChain::from_certs(vec![cert]), priv_key)?; + + Ok((cfg_builder.build(), cert_der)) +} + +#[allow(unused)] +pub const ALPN_QUIC_HTTP: &[&[u8]] = &[b"hq-29"];