Generated
+97
-61
@@ -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,17 +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/redox-os/event.git#bb96d9cd6dd01d4118deae84722a522b8328fa9f"
|
||||
source = "git+https://github.com/redox-os/event.git#68f4c7e55615ecede98f2085c81801a3dc4b74e0"
|
||||
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]]
|
||||
@@ -266,21 +278,22 @@ 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)",
|
||||
"redox_syscall 0.1.37 (git+https://github.com/redox-os/syscall.git)",
|
||||
"smoltcp 0.4.0 (git+https://github.com/m-labs/smoltcp.git)",
|
||||
]
|
||||
|
||||
[[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 +301,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 +311,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 +324,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 +342,10 @@ 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"
|
||||
source = "git+https://github.com/m-labs/smoltcp.git#c2d18ec071a2cd68aee2724ce13eefa6ccf1f0c1"
|
||||
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 +353,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 +425,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,48 +443,69 @@ 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/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"
|
||||
@@ -480,7 +513,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"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 +525,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"
|
||||
|
||||
@@ -2,15 +2,24 @@
|
||||
name = "redox_netstack"
|
||||
version = "0.1.0"
|
||||
|
||||
[[bin]]
|
||||
name = "dnsd"
|
||||
path = "src/dnsd/main.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "smolnetd"
|
||||
path = "src/smolnetd/main.rs"
|
||||
|
||||
[lib]
|
||||
name = "redox_netstack"
|
||||
path = "src/lib/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
netutils = { git = "https://github.com/redox-os/netutils.git" }
|
||||
redox_event = { git = "https://github.com/redox-os/event.git" }
|
||||
redox_syscall = { git = "https://github.com/redox-os/syscall.git" }
|
||||
byteorder = { version = "1.0", default-features = false }
|
||||
dns-parser = "0.7.1"
|
||||
|
||||
[dependencies.log]
|
||||
version = "0.3"
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
#![feature(nll)]
|
||||
|
||||
extern crate dns_parser;
|
||||
extern crate event;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate redox_netstack;
|
||||
extern crate syscall;
|
||||
|
||||
use event::EventQueue;
|
||||
use redox_netstack::error::{Error, Result};
|
||||
use redox_netstack::logger;
|
||||
use scheme::Dnsd;
|
||||
use std::cell::RefCell;
|
||||
use std::fs::File;
|
||||
use std::os::unix::io::{FromRawFd, RawFd};
|
||||
use std::process;
|
||||
use std::rc::Rc;
|
||||
|
||||
mod scheme;
|
||||
|
||||
fn run() -> Result<()> {
|
||||
use syscall::flag::*;
|
||||
|
||||
let dns_fd = syscall::open(":dns", O_RDWR | O_CREAT | O_NONBLOCK)
|
||||
.map_err(|e| Error::from_syscall_error(e, "failed to open :dns"))?
|
||||
as RawFd;
|
||||
|
||||
let time_path = format!("time:{}", syscall::CLOCK_MONOTONIC);
|
||||
let time_fd = syscall::open(&time_path, syscall::O_RDWR)
|
||||
.map_err(|e| Error::from_syscall_error(e, "failed to open time:"))?
|
||||
as RawFd;
|
||||
|
||||
let (dns_file, time_file) = unsafe { (File::from_raw_fd(dns_fd), File::from_raw_fd(time_fd)) };
|
||||
|
||||
let dnsd = Rc::new(RefCell::new(Dnsd::new(dns_file, time_file)));
|
||||
|
||||
let mut event_queue = EventQueue::<(), Error>::new()
|
||||
.map_err(|e| Error::from_io_error(e, "failed to create event queue"))?;
|
||||
|
||||
let dnsd_ = Rc::clone(&dnsd);
|
||||
|
||||
event_queue
|
||||
.add(dns_fd, move |_| dnsd_.borrow_mut().on_dns_file_event())
|
||||
.map_err(|e| Error::from_io_error(e, "failed to listen to time events"))?;
|
||||
|
||||
let dnsd_ = Rc::clone(&dnsd);
|
||||
|
||||
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())
|
||||
.map_err(|e| Error::from_io_error(e, "failed to listen to time events"))?;
|
||||
|
||||
event_queue.trigger_all(0)?;
|
||||
|
||||
event_queue.run()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
if unsafe { syscall::clone(0).unwrap() } == 0 {
|
||||
logger::init_logger();
|
||||
if let Err(err) = run() {
|
||||
error!("dnsd: {}", err);
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,457 @@
|
||||
use redox_netstack::error::{Error, Result};
|
||||
use event::{subscribe_to_fd, unsubscribe_from_fd};
|
||||
use std::borrow::ToOwned;
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::collections::VecDeque;
|
||||
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::data::TimeSpec;
|
||||
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 },
|
||||
Timeout,
|
||||
Failed,
|
||||
}
|
||||
|
||||
enum Domain {
|
||||
Resolved {
|
||||
data: Rc<[u8]>,
|
||||
},
|
||||
Requested {
|
||||
waiting_fds: BTreeSet<usize>,
|
||||
socket_fd: RawFd,
|
||||
},
|
||||
}
|
||||
|
||||
enum DnsParsingResult {
|
||||
WakeUpFiles(BTreeSet<usize>),
|
||||
FailFiles(BTreeSet<usize>),
|
||||
}
|
||||
|
||||
struct Domains {
|
||||
domains: BTreeMap<Rc<str>, Domain>,
|
||||
requests: BTreeMap<RawFd, Rc<str>>,
|
||||
resolved_timeouts: VecDeque<(TimeSpec, Rc<str>)>,
|
||||
requested_timeouts: VecDeque<(TimeSpec, Rc<str>)>,
|
||||
}
|
||||
|
||||
impl Domains {
|
||||
fn new() -> Domains {
|
||||
Domains {
|
||||
domains: BTreeMap::new(),
|
||||
requests: BTreeMap::new(),
|
||||
resolved_timeouts: VecDeque::new(),
|
||||
requested_timeouts: VecDeque::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 = builder.build().ok()?;
|
||||
let udp_fd = syscall::open(
|
||||
"udp:8.8.8.8:53",
|
||||
syscall::O_RDWR | syscall::O_CREAT | syscall::O_NONBLOCK,
|
||||
).ok()? as RawFd;
|
||||
if syscall::write(udp_fd as usize, &packet) != Ok(packet.len()) {
|
||||
syscall::close(udp_fd as usize).ok()?;
|
||||
return None;
|
||||
}
|
||||
subscribe_to_fd(udp_fd).ok()?;
|
||||
self.requests.insert(udp_fd, domain.to_owned().into());
|
||||
Some(udp_fd)
|
||||
}
|
||||
|
||||
fn on_time_event(&mut self, cur_time: &TimeSpec) -> BTreeSet<usize> {
|
||||
while let Some((timeout, domain)) = self.resolved_timeouts.pop_front() {
|
||||
if timeout.tv_sec > cur_time.tv_sec
|
||||
|| (timeout.tv_sec == cur_time.tv_sec && timeout.tv_nsec > cur_time.tv_nsec)
|
||||
{
|
||||
self.resolved_timeouts.push_front((timeout, domain));
|
||||
break;
|
||||
}
|
||||
trace!("Timing out resolved domain {:?}", domain);
|
||||
match self.domains.entry(domain) {
|
||||
Entry::Vacant(_) => {}
|
||||
Entry::Occupied(e) => {
|
||||
if let Domain::Resolved { .. } = *e.get() {
|
||||
e.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut fds_to_wakeup = BTreeSet::new();
|
||||
|
||||
while let Some((timeout, domain)) = self.requested_timeouts.pop_front() {
|
||||
if timeout.tv_sec > cur_time.tv_sec
|
||||
|| (timeout.tv_sec == cur_time.tv_sec && timeout.tv_nsec > cur_time.tv_nsec)
|
||||
{
|
||||
self.requested_timeouts.push_front((timeout, domain));
|
||||
break;
|
||||
}
|
||||
trace!("Timing out requested domain {:?}", domain);
|
||||
match self.domains.entry(domain) {
|
||||
Entry::Vacant(_) => {}
|
||||
Entry::Occupied(e) => {
|
||||
if let Domain::Requested { .. } = *e.get() {
|
||||
if let Domain::Requested {
|
||||
mut waiting_fds,
|
||||
socket_fd,
|
||||
} = e.remove()
|
||||
{
|
||||
fds_to_wakeup.append(&mut waiting_fds);
|
||||
let _ = unsubscribe_from_fd(socket_fd);
|
||||
let _ = syscall::close(socket_fd as usize);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fds_to_wakeup
|
||||
}
|
||||
|
||||
fn on_fd_event(&mut self, fd: RawFd, cur_time: &TimeSpec) -> Option<DnsParsingResult> {
|
||||
let e = match self.requests.entry(fd) {
|
||||
Entry::Vacant(_) => {
|
||||
return None;
|
||||
}
|
||||
Entry::Occupied(e) => e,
|
||||
};
|
||||
let mut buf = [0u8; 4096];
|
||||
let readed = syscall::read(fd as usize, &mut buf).ok()?;
|
||||
if readed == 0 {
|
||||
return None;
|
||||
}
|
||||
let pkt = DNSPacket::parse(&buf).ok()?;
|
||||
if pkt.header.response_code != ResponseCode::NoError || pkt.answers.len() == 0 {
|
||||
if let Some(query) = pkt.questions.iter().next() {
|
||||
if query.qname.to_string().to_lowercase() == e.get().as_ref() {
|
||||
unsubscribe_from_fd(fd).ok()?;
|
||||
syscall::close(fd as usize).ok()?;
|
||||
let domain = e.remove();
|
||||
self.requested_timeouts
|
||||
.retain(|&(_, ref d)| d.as_ref() != domain.as_ref());
|
||||
if let Entry::Occupied(mut e) = self.domains.entry(domain) {
|
||||
let domain_data = e.remove();
|
||||
return if let Domain::Requested { waiting_fds, .. } = domain_data {
|
||||
Some(DnsParsingResult::FailFiles(waiting_fds))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
return None;
|
||||
}
|
||||
let mut result = String::new();
|
||||
for answer in pkt.answers {
|
||||
if answer.name.to_string().to_lowercase() != e.get().as_ref() {
|
||||
continue;
|
||||
}
|
||||
if let RRData::A(ip) = answer.data {
|
||||
result += &format!("{}\n", ip);
|
||||
}
|
||||
}
|
||||
if result.is_empty() {
|
||||
return None;
|
||||
}
|
||||
let data = Rc::from(result.into_bytes());
|
||||
unsubscribe_from_fd(fd).ok()?;
|
||||
syscall::close(fd as usize).ok()?;
|
||||
let domain = e.remove();
|
||||
let mut domain_data = Domain::Resolved { data };
|
||||
trace!("On FD event {} {} resolved", fd, domain);
|
||||
|
||||
let mut resolved_timeout = *cur_time;
|
||||
resolved_timeout.tv_sec += Dnsd::RESOLVED_TIMEOUT_S;
|
||||
|
||||
self.resolved_timeouts
|
||||
.push_back((resolved_timeout, Rc::clone(&domain)));
|
||||
|
||||
self.requested_timeouts
|
||||
.retain(|&(_, ref d)| d.as_ref() != domain.as_ref());
|
||||
|
||||
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(DnsParsingResult::WakeUpFiles(waiting_fds))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn file_from_domain(&mut self, domain: &str, fd: usize, cur_time: &TimeSpec) -> DnsFile {
|
||||
if let Some(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();
|
||||
let domain = domain.to_owned().into();
|
||||
waiting_fds.insert(fd);
|
||||
self.domains.insert(
|
||||
Rc::clone(&domain),
|
||||
Domain::Requested {
|
||||
waiting_fds,
|
||||
socket_fd,
|
||||
},
|
||||
);
|
||||
let mut timeout = *cur_time;
|
||||
timeout.tv_sec += Dnsd::REQUEST_TIMEOUT_S;
|
||||
self.requested_timeouts.push_back((timeout, domain));
|
||||
}
|
||||
DnsFile::Waiting {
|
||||
domain: domain.to_owned(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn unwait_fd(&mut self, domain: &str, fd: usize) {
|
||||
if let Some(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: Domains,
|
||||
wait_map: BTreeMap<usize, SyscallPacket>,
|
||||
next_fd: usize,
|
||||
}
|
||||
|
||||
impl Dnsd {
|
||||
const RESOLVED_TIMEOUT_S: i64 = 5 * 60;
|
||||
const REQUEST_TIMEOUT_S: i64 = 30;
|
||||
const TIME_EVENT_TIMEOUT_S: i64 = 5;
|
||||
|
||||
pub fn new(dns_file: File, time_file: File) -> Dnsd {
|
||||
Dnsd {
|
||||
dns_file,
|
||||
time_file,
|
||||
files: BTreeMap::new(),
|
||||
domains: Domains::new(),
|
||||
wait_map: BTreeMap::new(),
|
||||
next_fd: 1,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn on_time_event(&mut self) -> Result<Option<()>> {
|
||||
let mut time = TimeSpec::default();
|
||||
if self.time_file.read(&mut time)? < mem::size_of::<TimeSpec>() {
|
||||
return Err(Error::from_syscall_error(
|
||||
syscall::Error::new(syscall::EBADF),
|
||||
"Can't read current time",
|
||||
));
|
||||
}
|
||||
|
||||
let fds_to_wakeup = self.domains.on_time_event(&time);
|
||||
if !fds_to_wakeup.is_empty() {
|
||||
for fd in &fds_to_wakeup {
|
||||
if let Some(file) = self.files.get_mut(&fd) {
|
||||
*file = DnsFile::Timeout;
|
||||
}
|
||||
}
|
||||
self.wakeup_fds(fds_to_wakeup);
|
||||
}
|
||||
|
||||
time.tv_sec += Dnsd::TIME_EVENT_TIMEOUT_S;
|
||||
self.time_file
|
||||
.write_all(&time)
|
||||
.map_err(|e| Error::from_io_error(e, "Failed to write to time file"))?;
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
pub fn on_dns_file_event(&mut self) -> Result<Option<()>> {
|
||||
loop {
|
||||
let mut packet = SyscallPacket::default();
|
||||
if self.dns_file.read(&mut packet)? == 0 {
|
||||
break;
|
||||
}
|
||||
let a = packet.a;
|
||||
self.handle(&mut packet);
|
||||
if packet.a != (-syscall::EWOULDBLOCK) as usize {
|
||||
self.dns_file.write_all(&packet)?;
|
||||
} else {
|
||||
packet.a = a;
|
||||
self.handle_block(packet)?;
|
||||
}
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
pub fn on_unknown_fd_event(&mut self, fd: RawFd) -> Result<Option<()>> {
|
||||
let mut cur_time = TimeSpec::default();
|
||||
syscall::clock_gettime(syscall::CLOCK_MONOTONIC, &mut cur_time)
|
||||
.map_err(|e| Error::from_syscall_error(e, "Can't get time"))?;
|
||||
|
||||
match self.domains.on_fd_event(fd, &cur_time) {
|
||||
Some(DnsParsingResult::FailFiles(fds_to_fail)) => {
|
||||
for fd in &fds_to_fail {
|
||||
if let Some(file) = self.files.get_mut(&fd) {
|
||||
*file = DnsFile::Failed;
|
||||
}
|
||||
}
|
||||
self.wakeup_fds(fds_to_fail);
|
||||
}
|
||||
Some(DnsParsingResult::WakeUpFiles(fds_to_wakeup)) => {
|
||||
self.wakeup_fds(fds_to_wakeup);
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn wakeup_fds(&mut self, fds_to_wakeup: BTreeSet<usize>) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_block(&mut self, packet: SyscallPacket) -> Result<()> {
|
||||
let fd = packet.b;
|
||||
self.wait_map.insert(fd, packet);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn validate_domain(domain: &str) -> bool {
|
||||
if domain.len() > 256 {
|
||||
return false;
|
||||
}
|
||||
|
||||
for part in domain.split('.') {
|
||||
if part.len() >= 63 {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
impl SchemeMut for Dnsd {
|
||||
fn open(&mut self, url: &[u8], _flags: usize, _uid: u32, _gid: u32) -> SyscallResult<usize> {
|
||||
let domain = str::from_utf8(url)
|
||||
.or_else(|_| Err(SyscallError::new(syscall::EINVAL)))?
|
||||
.to_lowercase();
|
||||
if domain.is_empty() || !Dnsd::validate_domain(&domain) {
|
||||
return Err(SyscallError::new(syscall::EINVAL));
|
||||
}
|
||||
let fd = self.next_fd;
|
||||
self.next_fd += 1;
|
||||
let mut cur_time = TimeSpec::default();
|
||||
syscall::clock_gettime(syscall::CLOCK_MONOTONIC, &mut cur_time)?;
|
||||
let dns_file = self.domains.file_from_domain(&domain, fd, &cur_time);
|
||||
self.files.insert(fd, dns_file);
|
||||
trace!("Open {} {}", &domain, fd);
|
||||
Ok(fd)
|
||||
}
|
||||
|
||||
fn close(&mut self, fd: usize) -> SyscallResult<usize> {
|
||||
trace!("Close {}", fd);
|
||||
let 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)
|
||||
}
|
||||
|
||||
fn write(&mut self, _fd: usize, _buf: &[u8]) -> SyscallResult<usize> {
|
||||
Err(SyscallError::new(syscall::EINVAL))
|
||||
}
|
||||
|
||||
fn read(&mut self, fd: usize, buf: &mut [u8]) -> SyscallResult<usize> {
|
||||
trace!("Read {}", fd);
|
||||
let file = self.files
|
||||
.get_mut(&fd)
|
||||
.ok_or_else(|| SyscallError::new(syscall::EBADF))?;
|
||||
|
||||
let mut cur_time = TimeSpec::default();
|
||||
syscall::clock_gettime(syscall::CLOCK_MONOTONIC, &mut cur_time)?;
|
||||
|
||||
if let DnsFile::Waiting { ref domain } = *file {
|
||||
*file = self.domains.file_from_domain(domain, fd, &cur_time);
|
||||
}
|
||||
|
||||
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)),
|
||||
DnsFile::Timeout => Err(SyscallError::new(syscall::ETIMEDOUT)),
|
||||
DnsFile::Failed => Err(SyscallError::new(syscall::ENODATA)),
|
||||
}
|
||||
}
|
||||
|
||||
fn fevent(&mut self, _fd: usize, _events: usize) -> SyscallResult<usize> {
|
||||
Ok(0)
|
||||
}
|
||||
|
||||
fn fsync(&mut self, _fd: usize) -> SyscallResult<usize> {
|
||||
Ok(0)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
extern crate log;
|
||||
extern crate syscall;
|
||||
|
||||
pub mod logger;
|
||||
pub mod error;
|
||||
+14
-26
@@ -4,6 +4,7 @@ extern crate event;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate netutils;
|
||||
extern crate redox_netstack;
|
||||
extern crate smoltcp;
|
||||
extern crate syscall;
|
||||
extern crate byteorder;
|
||||
@@ -14,14 +15,13 @@ use std::os::unix::io::{FromRawFd, RawFd};
|
||||
use std::process;
|
||||
use std::rc::Rc;
|
||||
|
||||
use error::{Error, Result};
|
||||
use redox_netstack::error::{Error, Result};
|
||||
use redox_netstack::logger;
|
||||
use event::EventQueue;
|
||||
use scheme::Smolnetd;
|
||||
|
||||
mod buffer_pool;
|
||||
mod device;
|
||||
mod error;
|
||||
mod logger;
|
||||
mod port_set;
|
||||
mod scheme;
|
||||
|
||||
@@ -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)?;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ use syscall;
|
||||
|
||||
use buffer_pool::{Buffer, BufferPool};
|
||||
use device::NetworkDevice;
|
||||
use error::{Error, Result};
|
||||
use redox_netstack::error::{Error, Result};
|
||||
use self::ip::IpScheme;
|
||||
use self::tcp::TcpScheme;
|
||||
use self::udp::UdpScheme;
|
||||
|
||||
@@ -13,7 +13,7 @@ use syscall::data::TimeSpec;
|
||||
use syscall::{Error as SyscallError, Packet as SyscallPacket, Result as SyscallResult, SchemeMut};
|
||||
use syscall;
|
||||
|
||||
use error::{Error, Result};
|
||||
use redox_netstack::error::{Error, Result};
|
||||
use super::{post_fevent, SocketSet};
|
||||
|
||||
pub struct NullFile {
|
||||
|
||||
Reference in New Issue
Block a user