Make mastersrv compile with Rust 1.48.0

This commit is contained in:
heinrich5991 2022-05-20 16:29:01 +02:00
parent 6b65ccb945
commit ee8896d014
5 changed files with 56 additions and 80 deletions

View file

@ -13,9 +13,9 @@ dependencies = [
[[package]]
name = "arrayvec"
version = "0.7.2"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6"
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
dependencies = [
"serde",
]
@ -84,25 +84,15 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "3.1.14"
version = "2.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "535434c063ced786eb04aaf529308092c5ab60889e8fe24275d15de07b01fa97"
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
dependencies = [
"bitflags",
"clap_lex",
"indexmap",
"strsim",
"terminal_size",
"term_size",
"textwrap",
]
[[package]]
name = "clap_lex"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a37c35f1112dad5e6e0b1adaff798507497a18fceeb30cceb3bae7d1427b9213"
dependencies = [
"os_str_bytes",
"unicode-width",
]
[[package]]
@ -244,7 +234,7 @@ checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad"
dependencies = [
"cfg-if",
"libc",
"wasi 0.10.2+wasi-snapshot-preview1",
"wasi",
]
[[package]]
@ -314,9 +304,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
name = "http"
version = "0.2.7"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff8670570af52249509a86f5e3e18a08c60b177071826898fde8997cf5f6bfbb"
checksum = "31f4c6746584866f0feabcc69893c5b51beef3831656a968ed7ae254cdc4fd03"
dependencies = [
"bytes",
"fnv",
@ -493,15 +483,14 @@ dependencies = [
[[package]]
name = "mio"
version = "0.8.2"
version = "0.7.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52da4364ffb0e4fe33a9841a98a3f3014fb964045ce4f7a45a398243c8d6b0c9"
checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc"
dependencies = [
"libc",
"log",
"miow",
"ntapi",
"wasi 0.11.0+wasi-snapshot-preview1",
"winapi",
]
@ -533,18 +522,6 @@ dependencies = [
"libc",
]
[[package]]
name = "once_cell"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
[[package]]
name = "os_str_bytes"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
[[package]]
name = "percent-encoding"
version = "2.1.0"
@ -756,9 +733,9 @@ dependencies = [
[[package]]
name = "strsim"
version = "0.10.0"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "syn"
@ -771,6 +748,16 @@ dependencies = [
"unicode-xid",
]
[[package]]
name = "term_size"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e4129646ca0ed8f45d09b929036bafad5377103edd06e50bf574b353d2b08d9"
dependencies = [
"libc",
"winapi",
]
[[package]]
name = "termcolor"
version = "1.1.3"
@ -780,23 +767,14 @@ dependencies = [
"winapi-util",
]
[[package]]
name = "terminal_size"
version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df"
dependencies = [
"libc",
"winapi",
]
[[package]]
name = "textwrap"
version = "0.15.0"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
dependencies = [
"terminal_size",
"term_size",
"unicode-width",
]
[[package]]
@ -816,18 +794,16 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio"
version = "1.18.0"
version = "1.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f48b6d60512a392e34dbf7fd456249fd2de3c83669ab642e021903f4015185b"
checksum = "0c27a64b625de6d309e8c57716ba93021dccf1b3b5c97edd6d3dd2d2135afc0a"
dependencies = [
"bytes",
"libc",
"memchr",
"mio",
"num_cpus",
"once_cell",
"pin-project-lite",
"socket2",
"tokio-macros",
"winapi",
]
@ -957,6 +933,12 @@ dependencies = [
"tinyvec",
]
[[package]]
name = "unicode-width"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
[[package]]
name = "unicode-xid"
version = "0.2.2"
@ -1026,12 +1008,6 @@ version = "0.10.2+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "winapi"
version = "0.3.9"

View file

@ -5,12 +5,11 @@ authors = ["heinrich5991 <heinrich5991@gmail.com>"]
edition = "2018"
[dependencies]
arrayvec = { version = "0.7.2", features = ["serde"] }
arrayvec = { version = "0.5.2", features = ["serde"] }
base64 = "0.13.0"
bytes = "1.1.0"
clap = { version = "3.1.14", default-features = false, features = [
clap = { version = "2.34.0", default-features = false, features = [
"suggestions",
"std",
"wrap_help",
] }
csv = "1.1.6"

View file

@ -89,7 +89,7 @@ impl Protocol {
impl fmt::Display for Addr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut buf: ArrayString<128> = ArrayString::new();
let mut buf: ArrayString<[u8; 128]> = ArrayString::new();
write!(
&mut buf,
"{}://{}",
@ -109,7 +109,7 @@ impl FromStr for Addr {
fn from_str(s: &str) -> Result<Addr, InvalidAddr> {
let url = Url::parse(s).map_err(|_| InvalidAddr)?;
let protocol: Protocol = url.scheme().parse().map_err(|_| InvalidAddr)?;
let mut ip_port: ArrayString<64> = ArrayString::new();
let mut ip_port: ArrayString<[u8; 64]> = ArrayString::new();
write!(
&mut ip_port,
"{}:{}",
@ -131,7 +131,7 @@ impl serde::Serialize for Addr {
where
S: serde::Serializer,
{
let mut buf: ArrayString<128> = ArrayString::new();
let mut buf: ArrayString<[u8; 128]> = ArrayString::new();
write!(&mut buf, "{}", self).unwrap();
serializer.serialize_str(&buf)
}

View file

@ -4,7 +4,7 @@ use serde::Deserialize;
use std::net::IpAddr;
use std::path::Path;
pub type Location = ArrayString<12>;
pub type Location = ArrayString<[u8; 12]>;
#[derive(Deserialize)]
struct LocationRecord {

View file

@ -1,7 +1,8 @@
use arrayvec::ArrayString;
use arrayvec::ArrayVec;
use clap::value_t_or_exit;
use clap::App;
use clap::Arg;
use clap::Command;
use headers::HeaderMapExt as _;
use rand::random;
use serde::Deserialize;
@ -52,7 +53,7 @@ mod locations;
const SERVER_TIMEOUT_SECONDS: u64 = 30;
type ShortString = ArrayString<64>;
type ShortString = ArrayString<[u8; 64]>;
// TODO: delete action for server shutdown
@ -289,7 +290,7 @@ impl Challenger {
base64::encode_config_slice(&hash.finalize()[..16], base64::STANDARD, &mut buf);
ShortString::from(str::from_utf8(&buf[..len]).unwrap()).unwrap()
}
let mut buf: ArrayVec<u8, 128> = ArrayVec::new();
let mut buf: ArrayVec<[u8; 128]> = ArrayVec::new();
write!(&mut buf, "{}", addr).unwrap();
Challenge {
current: hash(&self.seed, &buf),
@ -854,47 +855,47 @@ impl<T> panic::RefUnwindSafe for AssertUnwindSafe<T> {}
async fn main() {
env_logger::init();
let mut command = Command::new("mastersrv")
let mut command = App::new("mastersrv")
.about("Collects game server info via an HTTP endpoint and aggregates them.")
.arg(Arg::new("listen")
.arg(Arg::with_name("listen")
.long("listen")
.value_name("ADDRESS")
.default_value("[::]:8080")
.help("Listen address for the HTTP endpoint.")
)
.arg(Arg::new("connecting-ip-header")
.arg(Arg::with_name("connecting-ip-header")
.long("connecting-ip-header")
.value_name("HEADER")
.help("HTTP header to use to determine the client IP address.")
)
.arg(Arg::new("locations")
.arg(Arg::with_name("locations")
.long("locations")
.value_name("LOCATIONS")
.help("IP to continent locations database filename (CSV file with network,continent_code header).")
)
.arg(Arg::new("write-addresses")
.arg(Arg::with_name("write-addresses")
.long("write-addresses")
.value_name("FILENAME")
.help("Dump all new-style addresses to a file each second.")
)
.arg(Arg::new("write-dump")
.arg(Arg::with_name("write-dump")
.long("write-dump")
.value_name("DUMP")
.help("Dump the internal state to a JSON file each second.")
)
.arg(Arg::new("read-write-dump")
.arg(Arg::with_name("read-write-dump")
.long("read-write-dump")
.value_name("DUMP")
.conflicts_with("write-dump")
.help("Dump the internal state to a JSON file each second, but also read it at the start.")
)
.arg(Arg::new("read-dump-dir")
.arg(Arg::with_name("read-dump-dir")
.long("read-dump-dir")
.takes_value(true)
.value_name("DUMP_DIR")
.help("Read dumps from other mastersrv instances from the specified directory (looking only at *.json files).")
)
.arg(Arg::new("out")
.arg(Arg::with_name("out")
.long("out")
.value_name("OUT")
.default_value("servers.json")
@ -903,7 +904,7 @@ async fn main() {
if cfg!(unix) {
command = command.arg(
Arg::new("listen-unix")
Arg::with_name("listen-unix")
.long("listen-unix")
.value_name("PATH")
.requires("connecting-ip-header")
@ -914,7 +915,7 @@ async fn main() {
let matches = command.get_matches();
let listen_address: SocketAddr = matches.value_of_t_or_exit("listen");
let listen_address = value_t_or_exit!(matches.value_of("listen"), SocketAddr);
let connecting_ip_header = matches
.value_of("connecting-ip-header")
.map(|s| s.to_owned());