Implement the dns: schema.

This commit is contained in:
Egor Karavaev
2018-01-19 22:37:13 +03:00
parent 5fba322823
commit e6dfb7f5b2
5 changed files with 341 additions and 121 deletions
Generated
+106 -64
View File
@@ -14,7 +14,7 @@ dependencies = [
[[package]]
name = "bitflags"
version = "0.7.0"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -41,6 +41,15 @@ dependencies = [
"scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "dns-parser"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "either"
version = "1.4.0"
@@ -53,19 +62,17 @@ source = "git+https://github.com/redox-os/libextra.git#f38608acd9cc00e1c8bd41a1a
[[package]]
name = "fuchsia-zircon"
version = "0.2.1"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.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.2.0"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gcc"
@@ -74,7 +81,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "httparse"
version = "1.2.3"
version = "1.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -83,12 +90,12 @@ version = "0.10.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"httparse 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"httparse 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
"traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -136,7 +143,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libc"
version = "0.2.34"
version = "0.2.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -144,12 +151,12 @@ name = "log"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"log 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "log"
version = "0.4.0"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -157,8 +164,8 @@ dependencies = [
[[package]]
name = "managed"
version = "0.4.0"
source = "git+https://github.com/m-labs/rust-managed.git?rev=629a6786a1cf1692015f464ed16c04eafa5cb8d1#629a6786a1cf1692015f464ed16c04eafa5cb8d1"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "matches"
@@ -182,11 +189,11 @@ dependencies = [
"extra 0.1.0 (git+https://github.com/redox-os/libextra.git)",
"hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper-rustls 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"ntpclient 0.0.1 (git+https://github.com/willem66745/ntpclient-rust)",
"pbr 1.0.0 (git+https://github.com/a8m/pb)",
"redox_event 0.1.0 (git+https://github.com/redox-os/event.git)",
"redox_syscall 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -196,26 +203,26 @@ version = "0.0.1"
source = "git+https://github.com/willem66745/ntpclient-rust#7e3bdf60eb940825789a8da5181025320e3050b0"
dependencies = [
"byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "num_cpus"
version = "1.7.0"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "pbr"
version = "1.0.0"
source = "git+https://github.com/a8m/pb#c63c36895b2989c721e6db70dd4cb9c8dfe52e76"
source = "git+https://github.com/a8m/pb#d077b49ac6ea18ef63a9bb9f0f0b58abc29580f3"
dependencies = [
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -224,13 +231,18 @@ name = "percent-encoding"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "quick-error"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rand"
version = "0.3.18"
version = "0.3.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
"fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -248,9 +260,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"coco 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "redox_event"
version = "0.1.0"
source = "git+https://github.com/batonius/event.git?branch=default_callback#494aefad323a8f683c074b8b8e10dfa933f50efe"
dependencies = [
"redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -258,29 +278,29 @@ name = "redox_event"
version = "0.1.0"
source = "git+https://github.com/redox-os/event.git#bb96d9cd6dd01d4118deae84722a522b8328fa9f"
dependencies = [
"redox_syscall 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "redox_netstack"
version = "0.1.0"
dependencies = [
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"dns-parser 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"netutils 0.1.0 (git+https://github.com/redox-os/netutils.git)",
"redox_event 0.1.0 (git+https://github.com/redox-os/event.git)",
"redox_syscall 0.1.32 (git+https://github.com/redox-os/syscall.git)",
"smoltcp 0.4.0 (git+https://github.com/m-labs/smoltcp.git)",
"redox_event 0.1.0 (git+https://github.com/batonius/event.git?branch=default_callback)",
"redox_syscall 0.1.37 (git+https://github.com/redox-os/syscall.git)",
"smoltcp 0.4.0",
]
[[package]]
name = "redox_syscall"
version = "0.1.32"
source = "git+https://github.com/redox-os/syscall.git#3c765737a5e9146ffb241c67050c1be9bf28aab7"
version = "0.1.37"
source = "git+https://github.com/redox-os/syscall.git#7dc00e7ea4162f8886412d936f14ea5b7d834d41"
[[package]]
name = "redox_syscall"
version = "0.1.32"
version = "0.1.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -288,7 +308,7 @@ name = "redox_termios"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"redox_syscall 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -298,7 +318,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"untrusted 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -311,7 +331,7 @@ dependencies = [
"base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"ring 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
"untrusted 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"webpki 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -329,10 +349,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "smoltcp"
version = "0.4.0"
source = "git+https://github.com/m-labs/smoltcp.git#da8e7dceb8c0f1f475224fb9897b402fc1ec89a1"
dependencies = [
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"managed 0.4.0 (git+https://github.com/m-labs/rust-managed.git?rev=629a6786a1cf1692015f464ed16c04eafa5cb8d1)",
"managed 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -340,20 +359,19 @@ name = "termion"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "time"
version = "0.1.38"
version = "0.1.39"
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)",
"libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -413,7 +431,7 @@ version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"ring 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
"untrusted 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -431,56 +449,77 @@ name = "winapi"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "winapi"
version = "0.3.4"
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-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata]
"checksum arg_parser 0.1.0 (git+https://github.com/redox-os/arg-parser.git)" = "<none>"
"checksum base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "96434f987501f0ed4eb336a411e0631ecd1afa11574fe148587adc4ff96143c9"
"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
"checksum bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c30d3802dfb7281680d6285f2ccdaa8c2d8fee41f93805dba5c4cf50dc23cf"
"checksum byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855"
"checksum byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "652805b7e73fada9d85e9a6682a4abd490cb52d96aeecc12e33a0de34dfd0d23"
"checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de"
"checksum coco 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c06169f5beb7e31c7c67ebf5540b8b472d23e3eade3b2ec7d1f5b504a85f91bd"
"checksum dns-parser 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f7020f6760aea312d43d23cb83bf6c0c49f162541db8b02bf95209ac51dc253d"
"checksum either 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "740178ddf48b1a9e878e6d6509a1442a2d42fd2928aae8e7a6f8a36fb01981b3"
"checksum extra 0.1.0 (git+https://github.com/redox-os/libextra.git)" = "<none>"
"checksum fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f6c0581a4e363262e52b87f59ee2afe3415361c6ec35e665924eb08afe8ff159"
"checksum fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "43f3795b4bae048dc6123a6b972cadde2e676f9ded08aef6bb77f5f157684a82"
"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 gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb"
"checksum httparse 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "af2f2dd97457e8fb1ae7c5a420db346af389926e36f43768b96f101546b04a07"
"checksum httparse 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2f407128745b78abc95c0ffbe4e5d37427fdc0d45470710cfef8c44522a2e37"
"checksum hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)" = "368cb56b2740ebf4230520e2b90ebb0461e69034d85d1945febd9b3971426db2"
"checksum hyper-rustls 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "04535774f79684c99528944ebdb89756c945c027e55ce52faa245879d836c8fb"
"checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d"
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
"checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a"
"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73"
"checksum libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)" = "36fbc8a8929c632868295d0178dd8f63fc423fd7537ad0738372bd010b3ac9b0"
"checksum libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "1e5d97d6708edaa407429faa671b942dc0f2727222fb6b6539bf1db936e4b121"
"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
"checksum log 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3a89a0c46ba789b8a247d4c567aed4d7c68e624672d238b45cc3ec20dc9f940"
"checksum managed 0.4.0 (git+https://github.com/m-labs/rust-managed.git?rev=629a6786a1cf1692015f464ed16c04eafa5cb8d1)" = "<none>"
"checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2"
"checksum managed 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "43e2737ecabe4ae36a68061398bf27d2bfd0763f4c3c837a398478459494c4b7"
"checksum matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "100aabe6b8ff4e4a7e32c1c13523379802df0772b82466207ac25b013f193376"
"checksum mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0"
"checksum netutils 0.1.0 (git+https://github.com/redox-os/netutils.git)" = "<none>"
"checksum ntpclient 0.0.1 (git+https://github.com/willem66745/ntpclient-rust)" = "<none>"
"checksum num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "514f0d73e64be53ff320680ca671b64fe3fb91da01e1ae2ddc99eb51d453b20d"
"checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30"
"checksum pbr 1.0.0 (git+https://github.com/a8m/pb)" = "<none>"
"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
"checksum rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)" = "6475140dfd8655aeb72e1fd4b7a1cc1c202be65d71669476e392fe62532b9edd"
"checksum quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eda5fe9b71976e62bc81b781206aaa076401769b2143379d3eb2118388babac4"
"checksum rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)" = "512870020642bb8c221bf68baa1b2573da814f6ccfe5c9699b1c303047abe9b1"
"checksum rayon 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a77c51c07654ddd93f6cb543c7a849863b03abc7e82591afda6dc8ad4ac3ac4a"
"checksum rayon-core 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e64b609139d83da75902f88fd6c01820046840a18471e4dfcd5ac7c0f46bea53"
"checksum redox_event 0.1.0 (git+https://github.com/batonius/event.git?branch=default_callback)" = "<none>"
"checksum redox_event 0.1.0 (git+https://github.com/redox-os/event.git)" = "<none>"
"checksum redox_syscall 0.1.32 (git+https://github.com/redox-os/syscall.git)" = "<none>"
"checksum redox_syscall 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "ab105df655884ede59d45b7070c8a65002d921461ee813a024558ca16030eea0"
"checksum redox_syscall 0.1.37 (git+https://github.com/redox-os/syscall.git)" = "<none>"
"checksum redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "0d92eecebad22b767915e4d529f89f28ee96dbbf5a4810d2b844373f136417fd"
"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
"checksum ring 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1f2a6dc7fc06a05e6de183c5b97058582e9da2de0c136eafe49609769c507724"
"checksum rustls 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17727f4b991294da2c84d75a43c003151ff58072212768800f66c56ee46dca43"
"checksum safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e27a8b19b835f7aea908818e871f5cc3a5a186550c30773be987e155e8163d8f"
"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
"checksum smoltcp 0.4.0 (git+https://github.com/m-labs/smoltcp.git)" = "<none>"
"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
"checksum time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)" = "d5d788d3aa77bc0ef3e9621256885555368b47bd495c13dd2e7413c89f845520"
"checksum time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "a15375f1df02096fb3317256ce2cee6a1f42fc84ea5ad5fc8c421cfe40c73098"
"checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079"
"checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887"
"checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33"
@@ -492,4 +531,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum webpki 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e499345fc4c6b7c79a5b8756d4592c4305510a13512e79efafe00dfbd67bbac6"
"checksum webpki-roots 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5bfb3f50499f21ad2317f442845e3b5805b007f1e728f59885c99e61b8c181a7"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
"checksum winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "04e3bd221fcbe8a271359c04f21a76db7d0c6028862d1bb5512d85e1e2eb5bb3"
"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-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+4 -1
View File
@@ -27,7 +27,10 @@ default-features = false
features = ["release_max_level_off"]
[dependencies.smoltcp]
git = "https://github.com/m-labs/smoltcp.git"
path = "../smoltcp"
# git = "https://github.com/m-labs/smoltcp.git"
# git = "https://github.com/batonius/smoltcp.git"
branch = "unspecified_src"
default-features = false
features = ["std", "socket-raw", "proto-ipv4", "socket-udp", "socket-tcp", "socket-icmp"]
+3 -3
View File
@@ -46,8 +46,7 @@ fn run() -> Result<()> {
let dnsd_ = Rc::clone(&dnsd);
event_queue
.set_default_callback(move |fd, _| dnsd_.borrow_mut().on_unknown_fd_event(fd));
event_queue.set_default_callback(move |fd, _| dnsd_.borrow_mut().on_unknown_fd_event(fd));
event_queue
.add(time_fd, move |_| dnsd.borrow_mut().on_time_event())
@@ -59,7 +58,8 @@ fn run() -> Result<()> {
}
fn main() {
if unsafe { syscall::clone(0).unwrap() } == 0 {
// if unsafe { syscall::clone(0).unwrap() } == 0
{
logger::init_logger();
if let Err(err) = run() {
error!("dnsd: {}", err);
+217 -30
View File
@@ -1,28 +1,185 @@
use redox_netstack::error::{Error, Result};
use std::collections::BTreeMap;
use event::{subscribe_to_fd, unsubscribe_from_fd};
use std::borrow::ToOwned;
use std::collections::{BTreeMap, BTreeSet};
use std::collections::btree_map::Entry;
use std::fs::File;
use std::io::{Read, Write};
use std::mem;
use std::os::unix::io::RawFd;
use std::str;
use std::rc::Rc;
use syscall::{Error as SyscallError, Packet as SyscallPacket, Result as SyscallResult, SchemeMut};
use syscall;
use dns_parser::{Builder, Packet as DNSPacket, RRData, ResponseCode};
use dns_parser::{QueryClass, QueryType};
enum DnsFile {
Resolved { data: Rc<[u8]>, pos: usize },
Waiting { domain: String },
}
enum Domain {
Resolved { data: Rc<[u8]> },
Requested { waiting_fds: Vec<usize> },
Resolved {
data: Rc<[u8]>,
},
Requested {
waiting_fds: BTreeSet<usize>,
socket_fd: RawFd,
},
}
struct Domains {
domains: BTreeMap<String, Domain>,
requests: BTreeMap<RawFd, String>,
}
impl Domains {
fn new() -> Domains {
Domains {
domains: BTreeMap::new(),
requests: BTreeMap::new(),
}
}
fn request_domain(&mut self, domain: &str) -> Option<RawFd> {
trace!("Requesting domain {}", domain);
let mut builder = Builder::new_query(1, true);
builder.add_question(domain, QueryType::A, QueryClass::IN);
let packet = match builder.build() {
Ok(packet) => packet,
_ => return None,
};
let udp_fd = match syscall::open(
"udp:8.8.8.8:53",
syscall::O_RDWR | syscall::O_CREAT | syscall::O_NONBLOCK,
) {
Ok(fd) => fd as RawFd,
_ => return None,
};
if syscall::write(udp_fd as usize, &packet) != Ok(packet.len()) {
syscall::close(udp_fd as usize);
return None;
}
trace!("Requesting domain {} fd {}", domain, udp_fd);
subscribe_to_fd(udp_fd);
self.requests.insert(udp_fd, domain.to_owned());
Some(udp_fd)
}
fn on_fd_event(&mut self, fd: RawFd) -> Option<BTreeSet<usize>> {
trace!("On FD event {}", fd);
let e = match self.requests.entry(fd) {
Entry::Vacant(_) => {
return None;
}
Entry::Occupied(e) => e,
};
let mut buf = [0u8; 4096];
let readed = match syscall::read(fd as usize, &mut buf) {
Ok(readed) => readed,
_ => {
return None;
}
};
let pkt = match DNSPacket::parse(&buf) {
Ok(pkt) => pkt,
_ => {
return None;
}
};
if pkt.header.response_code != ResponseCode::NoError || pkt.answers.len() == 0 {
return None;
}
let mut result = String::new();
for answer in pkt.answers {
match answer.data {
RRData::A(ip) => {
result += &format!("{}\n", ip);
}
_ => {} // ignore
}
}
if result.is_empty() {
return None;
}
let data = Rc::from(result.into_bytes());
syscall::close(fd as usize);
unsubscribe_from_fd(fd);
let domain = e.remove();
let mut domain_data = Domain::Resolved { data };
trace!("On FD event {} {} resolved", fd, domain);
match self.domains.entry(domain) {
Entry::Vacant(e) => {
e.insert(domain_data);
None
}
Entry::Occupied(mut e) => {
mem::swap(e.get_mut(), &mut domain_data);
if let Domain::Requested { waiting_fds, .. } = domain_data {
Some(waiting_fds)
} else {
None
}
}
}
}
fn file_from_domain(&mut self, domain: &str, fd: usize) -> DnsFile {
if let Some(mut domain_data) = self.domains.get_mut(domain) {
match *domain_data {
Domain::Resolved { ref data } => DnsFile::Resolved {
data: Rc::clone(data),
pos: 0,
},
Domain::Requested {
ref mut waiting_fds,
..
} => {
waiting_fds.insert(fd);
DnsFile::Waiting {
domain: domain.to_owned(),
}
}
}
} else {
if let Some(socket_fd) = self.request_domain(domain) {
let mut waiting_fds = BTreeSet::new();
waiting_fds.insert(fd);
self.domains.insert(
domain.to_owned(),
Domain::Requested {
waiting_fds,
socket_fd,
},
);
}
DnsFile::Waiting {
domain: domain.to_owned(),
}
}
}
fn unwait_fd(&mut self, domain: &str, fd: usize) {
if let Some(mut domain_data) = self.domains.get_mut(domain) {
if let Domain::Requested {
ref mut waiting_fds,
..
} = *domain_data
{
waiting_fds.remove(&fd);
}
}
}
}
pub struct Dnsd {
dns_file: File,
time_file: File,
files: BTreeMap<usize, DnsFile>,
domains: BTreeMap<String, Domain>,
domains: Domains,
wait_map: BTreeMap<usize, SyscallPacket>,
next_fd: usize,
}
@@ -32,7 +189,8 @@ impl Dnsd {
dns_file,
time_file,
files: BTreeMap::new(),
domains: BTreeMap::new(),
domains: Domains::new(),
wait_map: BTreeMap::new(),
next_fd: 1,
}
}
@@ -60,48 +218,56 @@ impl Dnsd {
}
pub fn on_unknown_fd_event(&mut self, fd: RawFd) -> Result<Option<()>> {
trace!("Unknown fd event {}", fd);
if let Some(fds_to_wakeup) = self.domains.on_fd_event(fd) {
let mut syscall_packets = vec![];
for fd in &fds_to_wakeup {
if let Some(packet) = self.wait_map.remove(&fd) {
syscall_packets.push(packet);
}
}
for mut packet in syscall_packets.drain(..) {
self.handle(&mut packet);
let _ = self.dns_file.write_all(&packet);
}
}
Ok(None)
}
fn handle_block(&mut self, mut packet: SyscallPacket) -> Result<()> {
fn handle_block(&mut self, packet: SyscallPacket) -> Result<()> {
let fd = packet.b;
self.wait_map.insert(fd, packet);
Ok(())
}
fn request_domain(&mut self, domain: &str, fd: usize) {}
}
impl SchemeMut for Dnsd {
fn open(&mut self, url: &[u8], flags: usize, _uid: u32, _gid: u32) -> SyscallResult<usize> {
let domain : String = str::from_utf8(url)
.or_else(|_| Err(SyscallError::new(syscall::EINVAL)))?
.into();
trace!("Open");
let domain = str::from_utf8(url).or_else(|_| Err(SyscallError::new(syscall::EINVAL)))?;
trace!("Open {}", &domain);
if domain.is_empty() {
return Err(SyscallError::new(syscall::EINVAL));
}
let fd = self.next_fd;
self.next_fd += 1;
let dns_file = if let Some(mut domain_data) = self.domains.get_mut(&domain) {
match *domain_data {
Domain::Resolved { ref data } => DnsFile::Resolved {
data: Rc::clone(data),
pos: 0,
},
Domain::Requested {
ref mut waiting_fds,
} => {
waiting_fds.push(fd);
DnsFile::Waiting { domain }
}
}
} else {
self.request_domain(&domain, fd);
DnsFile::Waiting { domain }
};
let dns_file = self.domains.file_from_domain(domain, fd);
self.files.insert(fd, dns_file);
trace!("Open {} {}", &domain, fd);
Ok(fd)
}
fn close(&mut self, fd: usize) -> SyscallResult<usize> {
trace!("Close {}", fd);
let mut file = self.files
.get_mut(&fd)
.ok_or_else(|| SyscallError::new(syscall::EBADF))?;
if let DnsFile::Waiting { ref domain } = *file {
self.domains.unwait_fd(domain, fd);
}
self.files.remove(&fd);
Ok(0)
}
@@ -111,9 +277,30 @@ impl SchemeMut for Dnsd {
}
fn read(&mut self, fd: usize, buf: &mut [u8]) -> SyscallResult<usize> {
let file = self.files.get_mut(&fd)
trace!("Read {}", fd);
let mut file = self.files
.get_mut(&fd)
.ok_or_else(|| SyscallError::new(syscall::EBADF))?;
Ok(0)
if let DnsFile::Waiting { ref domain } = *file {
*file = self.domains.file_from_domain(domain, fd)
}
match *file {
DnsFile::Resolved {
ref data,
ref mut pos,
} => {
let mut i = 0;
while i < buf.len() && *pos < data.len() {
buf[i] = data[*pos];
i += 1;
*pos += 1;
}
Ok(i)
}
DnsFile::Waiting { .. } => Err(SyscallError::new(syscall::EWOULDBLOCK)),
}
}
fn fevent(&mut self, fd: usize, events: usize) -> SyscallResult<usize> {
+11 -23
View File
@@ -88,9 +88,7 @@ fn run() -> Result<()> {
.add(network_fd, move |_| {
smolnetd_.borrow_mut().on_network_scheme_event()
})
.map_err(|e| {
Error::from_io_error(e, "failed to listen to network events")
})?;
.map_err(|e| Error::from_io_error(e, "failed to listen to network events"))?;
let smolnetd_ = Rc::clone(&smolnetd);
@@ -101,24 +99,18 @@ fn run() -> Result<()> {
let smolnetd_ = Rc::clone(&smolnetd);
event_queue
.add(
udp_fd,
move |_| smolnetd_.borrow_mut().on_udp_scheme_event(),
)
.map_err(|e| {
Error::from_io_error(e, "failed to listen to udp events")
})?;
.add(udp_fd, move |_| {
smolnetd_.borrow_mut().on_udp_scheme_event()
})
.map_err(|e| Error::from_io_error(e, "failed to listen to udp events"))?;
let smolnetd_ = Rc::clone(&smolnetd);
event_queue
.add(
tcp_fd,
move |_| smolnetd_.borrow_mut().on_tcp_scheme_event(),
)
.map_err(|e| {
Error::from_io_error(e, "failed to listen to tcp events")
})?;
.add(tcp_fd, move |_| {
smolnetd_.borrow_mut().on_tcp_scheme_event()
})
.map_err(|e| Error::from_io_error(e, "failed to listen to tcp events"))?;
let smolnetd_ = Rc::clone(&smolnetd);
@@ -126,15 +118,11 @@ fn run() -> Result<()> {
.add(icmp_fd, move |_| {
smolnetd_.borrow_mut().on_icmp_scheme_event()
})
.map_err(|e| {
Error::from_io_error(e, "failed to listen to icmp events")
})?;
.map_err(|e| Error::from_io_error(e, "failed to listen to icmp events"))?;
event_queue
.add(time_fd, move |_| smolnetd.borrow_mut().on_time_event())
.map_err(|e| {
Error::from_io_error(e, "failed to listen to time events")
})?;
.map_err(|e| Error::from_io_error(e, "failed to listen to time events"))?;
event_queue.trigger_all(0)?;