Update dependencies + fix clippy warnings.

This commit is contained in:
Orne Brocaar 2022-09-26 12:58:01 +01:00
parent f17250c37f
commit bb188949df
46 changed files with 398 additions and 473 deletions

462
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@ RUN cd $PROJECT_PATH/ui && \
# ChirpStack build stage
FROM --platform=$BUILDPLATFORM rust:1.62.0-buster AS rust-build
FROM --platform=$BUILDPLATFORM rust:1.64.0-buster AS rust-build
ENV PROJECT_PATH=/chirpstack
RUN mkdir -p $PROJECT_PATH
@ -32,6 +32,7 @@ RUN apt-get update && \
clang \
libclang-dev \
jq \
protobuf-compiler \
gcc-arm-linux-gnueabihf \
g++-arm-linux-gnueabihf \
gcc-aarch64-linux-gnu \

View File

@ -1,4 +1,4 @@
FROM rust:1.62.0-buster
FROM rust:1.64.0-buster
ENV PROJECT_PATH=/chirpstack
RUN mkdir -p $PROJECT_PATH
@ -22,6 +22,7 @@ RUN apt-get update && \
libclang-dev \
golang-cfssl \
jq \
protobuf-compiler \
gcc-arm-linux-gnueabihf \
g++-arm-linux-gnueabihf \
gcc-aarch64-linux-gnu \
@ -33,7 +34,7 @@ RUN rustup component add rustfmt clippy
RUN rustup target add armv7-unknown-linux-gnueabihf
RUN rustup target add aarch64-unknown-linux-gnu
RUN cargo install diesel_cli --version 2.0.0-rc.1 --no-default-features --features postgres
RUN cargo install diesel_cli --version 2.0.0 --no-default-features --features postgres
RUN cargo install cargo-deb
RUN cargo install cargo-rpm
RUN cargo install cargo-bitbake

4
api/Dockerfile-rust vendored
View File

@ -1,8 +1,8 @@
FROM rust:1.56
FROM rust:1.64
ENV PROJECT_PATH=/chirpstack/api
RUN apt-get update && \
apt-get install -y make cmake git bash && \
apt-get install -y make cmake git bash protobuf-compiler && \
apt-get clean
RUN git clone https://github.com/googleapis/googleapis.git /googleapis

140
api/rust/Cargo.lock generated vendored
View File

@ -42,9 +42,9 @@ dependencies = [
[[package]]
name = "autocfg"
version = "1.0.1"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "axum"
@ -107,12 +107,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8"
[[package]]
name = "cc"
version = "1.0.73"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
[[package]]
name = "cfg-if"
version = "1.0.0"
@ -146,15 +140,6 @@ dependencies = [
"num-traits",
]
[[package]]
name = "cmake"
version = "0.1.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8ad8cef104ac57b68b89df3208164d228503abbdce70f6880ffa3d970e7443a"
dependencies = [
"cc",
]
[[package]]
name = "either"
version = "1.6.1"
@ -409,25 +394,14 @@ checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
[[package]]
name = "mio"
version = "0.8.2"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52da4364ffb0e4fe33a9841a98a3f3014fb964045ce4f7a45a398243c8d6b0c9"
checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf"
dependencies = [
"libc",
"log",
"miow",
"ntapi",
"wasi 0.11.0+wasi-snapshot-preview1",
"winapi",
]
[[package]]
name = "miow"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21"
dependencies = [
"winapi",
"windows-sys",
]
[[package]]
@ -436,15 +410,6 @@ version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a"
[[package]]
name = "ntapi"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44"
dependencies = [
"winapi",
]
[[package]]
name = "num-integer"
version = "0.1.44"
@ -465,10 +430,16 @@ dependencies = [
]
[[package]]
name = "pbjson"
version = "0.3.0"
name = "once_cell"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d86c0a61b93c50f35af5d8a4f134790f47cbebf8803a7219dd1e7238cd1af022"
checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1"
[[package]]
name = "pbjson"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f06d6c64fa91b40a9321e174ad4e9702038c90210f87b295b4f723c7ad2155a"
dependencies = [
"base64",
"serde",
@ -476,9 +447,9 @@ dependencies = [
[[package]]
name = "pbjson-build"
version = "0.3.0"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "956a449e8a85fc040e9f8cd8fd4dd2e68059d179092401f0d8570ba059f76dae"
checksum = "780b05debc7ed9a64c4ba63309c39a329368aa54a6894686c3a91608a18f9bb2"
dependencies = [
"heck",
"itertools",
@ -488,9 +459,9 @@ dependencies = [
[[package]]
name = "pbjson-types"
version = "0.3.0"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c20bd6ec3b4ba0073e7e5a1a770abd95723b431bf0e1941d2dd8aace9ffb97f"
checksum = "2aa68b479d28fc76e96b1973cb307c177607bbd975e7cd9101605d56cf09f22d"
dependencies = [
"bytes",
"chrono",
@ -576,9 +547,9 @@ dependencies = [
[[package]]
name = "prost"
version = "0.10.1"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a07b0857a71a8cb765763950499cae2413c3f9cede1133478c43600d9e146890"
checksum = "399c3c31cdec40583bb68f0b18403400d01ec4289c383aa047560439952c4dd7"
dependencies = [
"bytes",
"prost-derive",
@ -586,13 +557,11 @@ dependencies = [
[[package]]
name = "prost-build"
version = "0.10.1"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "120fbe7988713f39d780a58cf1a7ef0d7ef66c6d87e5aa3438940c05357929f4"
checksum = "7f835c582e6bd972ba8347313300219fed5bfa52caf175298d860b61ff6069bb"
dependencies = [
"bytes",
"cfg-if",
"cmake",
"heck",
"itertools",
"lazy_static",
@ -608,9 +577,9 @@ dependencies = [
[[package]]
name = "prost-derive"
version = "0.10.1"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b670f45da57fb8542ebdbb6105a925fe571b67f9e7ed9f47a06a84e72b4e7cc"
checksum = "7345d5f0e08c0536d7ac7229952590239e77abf0a0100a1b1d890add6ea96364"
dependencies = [
"anyhow",
"itertools",
@ -621,9 +590,9 @@ dependencies = [
[[package]]
name = "prost-types"
version = "0.10.1"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d0a014229361011dc8e69c8a1ec6c2e8d0f2af7c91e3ea3f5b2170298461e68"
checksum = "4dfaa718ad76a44b3415e6c4d53b17c8f99160dcb3a99b10470fce8ad43f6e3e"
dependencies = [
"bytes",
"prost",
@ -780,14 +749,16 @@ dependencies = [
[[package]]
name = "tokio"
version = "1.17.0"
version = "1.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2af73ac49756f3f7c01172e34a23e5d0216f6c32333757c2c61feb2bbff5a5ee"
checksum = "0020c875007ad96677dcc890298f4b942882c5d4eb7cc8f439fc3bf813dc9c95"
dependencies = [
"autocfg",
"bytes",
"libc",
"memchr",
"mio",
"once_cell",
"pin-project-lite",
"socket2",
"tokio-macros",
@ -856,9 +827,9 @@ dependencies = [
[[package]]
name = "tonic"
version = "0.7.1"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30fb54bf1e446f44d870d260d99957e7d11fb9d0a0f5bd1a662ad1411cc103f9"
checksum = "11cd56bdb54ef93935a6a79dbd1d91f1ebd4c64150fd61654031fd6b8b775c91"
dependencies = [
"async-stream",
"async-trait",
@ -888,9 +859,9 @@ dependencies = [
[[package]]
name = "tonic-build"
version = "0.7.0"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d17087af5c80e5d5fc8ba9878e60258065a0a757e35efe7a05b7904bece1943"
checksum = "2fbcd2800e34e743b9ae795867d5f77b535d3a3be69fd731e39145719752df8c"
dependencies = [
"prettyplease",
"proc-macro2",
@ -1059,3 +1030,46 @@ name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-sys"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2"
dependencies = [
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_msvc"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47"
[[package]]
name = "windows_i686_gnu"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6"
[[package]]
name = "windows_i686_msvc"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024"
[[package]]
name = "windows_x86_64_gnu"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1"
[[package]]
name = "windows_x86_64_msvc"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"

16
api/rust/Cargo.toml vendored
View File

@ -14,17 +14,17 @@ api = ["tonic/transport", "tonic-build/transport", "tokio"]
internal = []
[dependencies]
prost = "0.10"
prost-types = "0.10"
pbjson = "0.3"
pbjson-types = "0.3"
prost = "0.11"
prost-types = "0.11"
pbjson = "0.5"
pbjson-types = "0.5"
hex = "0.4"
rand = "0.8"
tonic = { version = "0.7", features = ["codegen", "prost"], default-features = false }
tokio = { version = "1.17", features = ["macros"], optional = true }
tonic = { version = "0.8", features = ["codegen", "prost"], default-features = false }
tokio = { version = "1.21", features = ["macros"], optional = true }
serde = { version = "1.0" }
[build-dependencies]
tonic-build = { version = "0.7", features = ["prost"], default-features = false }
pbjson-build = "0.3"
tonic-build = { version = "0.8", features = ["prost"], default-features = false }
pbjson-build = "0.5"

View File

@ -11,28 +11,28 @@ license = "MIT"
[dependencies]
# CLI interface
clap = "2.33"
clap = "3.2"
# Configuration
serde = { version = "1.0", features = ["derive", "rc"] }
serde_yaml = "0.8"
serde_yaml = "0.9"
serde_json = "1.0"
humantime-serde = "1.0"
humantime-serde = "1.1"
toml = "0.5"
handlebars = "4.1"
handlebars = "4.3"
# Database
validator = "0.13"
diesel = { version = "2.0.0-rc.1", features = [ "chrono", "postgres", "r2d2", "uuid", "serde_json", "numeric" ] }
diesel_migrations = { version = "2.0.0-rc.1" }
validator = "0.16"
diesel = { version = "2.0.0", features = [ "chrono", "postgres", "r2d2", "uuid", "serde_json", "numeric" ] }
diesel_migrations = { version = "2.0.0" }
r2d2 = "0.8"
bigdecimal = "0.3"
redis = { version = "0.21", features = ["r2d2", "cluster"] }
pq-sys = { version = "0.4.6", features = ["pkg-config"] }
pq-sys = { version = "0.4.7", features = ["pkg-config"] }
# Logging
tracing = "0.1"
tracing-subscriber = { version = "0.2", features = ["fmt", "ansi"], default-features = true }
tracing-subscriber = { version = "0.3", features = ["fmt", "ansi"], default-features = true }
# ChirpStack API definitions
chirpstack_api = { path = "../api/rust", features = ["default", "internal"] }
@ -43,28 +43,28 @@ backend = { path = "../backend" }
reqwest = { version = "0.11", features = ["json"] }
# Integrations
aws-types = "0.3.0"
aws-config = "0.3.0"
aws-sdk-sns = "0.3.0"
aws-types = "0.49"
aws-config = "0.49"
aws-sdk-sns = "0.19"
hmac = "0.12"
sha2 = "0.10"
urlencoding = "2.1"
geohash = "0.12"
gcp_auth = "0.7.2"
lapin = "2.1.1"
tokio-executor-trait = "2.1.0"
tokio-reactor-trait = "1.1.0"
rdkafka = { version = "0.28.0", features = ["cmake-build"]}
gcp_auth = "0.7"
lapin = "2.1"
tokio-executor-trait = "2.1"
tokio-reactor-trait = "1.1"
rdkafka = { version = "0.28", features = ["cmake-build"]}
# gRPC and Protobuf
tonic = "0.7"
tonic-web = "0.3"
tonic-reflection = "0.4"
tokio = { version = "1.17", features = ["macros", "rt-multi-thread"] }
tokio-stream = "0.1.8"
prost-types = "0.10"
prost = "0.10"
pbjson-types = "0.3"
tonic = "0.8"
tonic-web = "0.4"
tonic-reflection = "0.5"
tokio = { version = "1.21", features = ["macros", "rt-multi-thread"] }
tokio-stream = "0.1"
prost-types = "0.11"
prost = "0.11"
pbjson-types = "0.5"
# gRPC and HTTP multiplexing
warp = { version = "0.3", features = ["tls"] }
@ -75,37 +75,36 @@ http = "0.2"
http-body = "0.4"
rust-embed = "6.4"
mime_guess = "2.0"
tower-http = { version = "0.1", features = ["trace", "auth"] }
tower-http = { version = "0.3", features = ["trace", "auth"] }
# Error handling
thiserror = "1.0"
anyhow = "1.0"
# Authentication
pbkdf2 = "0.8"
pbkdf2 = "0.11"
rand_core = { version = "0.6", features = ["std"] }
# jsonwebtoken = "8.0"
jsonwebtoken = "8.1.0"
jsonwebtoken = "8.1"
openssl = { version = "0.10", features = ["vendored"] }
openidconnect = { version = "2.3.1", features = ["accept-rfc3339-timestamps"] }
openidconnect = { version = "2.3", features = ["accept-rfc3339-timestamps"] }
# MQTT
paho-mqtt = { version = "0.11", features = ["vendored-ssl"] }
hex = "0.4"
# Codecs
rquickjs = { version = "0.1.6", features = ["bindgen", "loader", "array-buffer", "chrono"] }
rquickjs = { version = "0.1", features = ["bindgen", "loader", "array-buffer", "chrono"] }
# Misc
lazy_static = "1.4"
uuid = { version = "1.1", features = [ "v4", "serde" ] }
chrono = "0.4"
async-trait = "0.1"
aes = "0.7"
aes = "0.8"
rand = "0.8"
base64 = "0.13"
async-recursion = "1.0"
regex = "1"
regex = "1.6"
petgraph = "0.6"
prometheus-client = "0.18"
pin-project = "1.0"
@ -113,7 +112,7 @@ pin-project = "1.0"
# Development and testing
[dev-dependencies]
httpmock = "0.6"
bytes = "1.1"
bytes = "1.2"
# Debian packaging.
[package.metadata.deb]

View File

@ -110,7 +110,7 @@ pub struct Request {
pub uplink_history: Vec<internal::UplinkAdrHistory>,
}
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub struct Response {
pub dr: u8,
pub tx_power_index: u8,

View File

@ -7,7 +7,7 @@ use jsonwebtoken::{decode, encode, Algorithm, DecodingKey, EncodingKey, Header,
use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[derive(Serialize, Deserialize, PartialEq, Debug)]
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug)]
pub struct AuthClaim {
pub aud: String,
#[serde(default, skip_serializing_if = "is_default")]

View File

@ -6,7 +6,7 @@ pub mod claims;
pub mod error;
pub mod validator;
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Eq, Debug)]
pub enum AuthID {
None,
User(Uuid),

View File

@ -85,7 +85,7 @@ impl ToStatus for tokio::task::JoinError {
}
}
impl ToStatus for prost_types::TimestampOutOfSystemRangeError {
impl ToStatus for prost_types::TimestampError {
fn status(&self) -> Status {
Status::new(Code::Internal, format!("{}", self))
}

View File

@ -1,5 +1,6 @@
use aes::cipher::generic_array::GenericArray;
use aes::{Aes128, Block, BlockEncrypt, NewBlockCipher};
use aes::cipher::{BlockEncrypt, KeyInit};
use aes::{Aes128, Block};
use anyhow::Result;
use chrono::{DateTime, Duration, Utc};
use tracing::info;

View File

@ -304,7 +304,7 @@ impl Data {
device_name: self.device.name.clone(),
dev_eui: self.device.dev_eui.to_string(),
tags: {
let mut tags = (&*self.device_profile.tags).clone();
let mut tags = (*self.device_profile.tags).clone();
tags.extend((*self.device.tags).clone());
tags
},

View File

@ -294,7 +294,7 @@ impl TxAck {
let dp = self.device_profile.as_ref().unwrap();
let dev = self.device.as_ref().unwrap();
let mut tags = (&*dp.tags).clone();
let mut tags = (*dp.tags).clone();
tags.extend((*dev.tags).clone());
let pl = integration_pb::LogEvent {
@ -330,7 +330,7 @@ impl TxAck {
let dev = self.device.as_ref().unwrap();
let qi = self.device_queue_item.as_ref().unwrap();
let mut tags = (&*dp.tags).clone();
let mut tags = (*dp.tags).clone();
tags.extend((*dev.tags).clone());
let downlink_id = self.downlink_frame.as_ref().unwrap().downlink_id;

View File

@ -104,7 +104,7 @@ impl ToDateTime for Duration {
let mut t = *GPS_EPOCH_TIME + *self;
for ls in LEAP_SECONDS_TABLE.iter() {
if ls.0 < t {
t = t - ls.1;
t -= ls.1;
}
}
t

View File

@ -23,7 +23,7 @@ pub async fn handle(
dev: &device::Device,
block: &lrwn::MACCommandSet,
) -> Result<Option<lrwn::MACCommandSet>> {
let mac = (&**block)
let mac = (**block)
.first()
.ok_or_else(|| anyhow!("Expected DevStatusAns"))?;
if let lrwn::MACCommand::DevStatusAns(pl) = mac {
@ -42,7 +42,7 @@ pub async fn handle(
)
.await?;
let mut tags = (&*dp.tags).clone();
let mut tags = (*dp.tags).clone();
tags.clone_from(&*dev.tags);
let rx_time: DateTime<Utc> =

View File

@ -6,7 +6,7 @@ pub async fn handle(
dev: &device::Device,
block: &lrwn::MACCommandSet,
) -> Result<Option<lrwn::MACCommandSet>> {
let mac = (&**block)
let mac = (**block)
.first()
.ok_or_else(|| anyhow!("Expected DeviceModeInd"))?;
if let lrwn::MACCommand::DeviceModeInd(pl) = mac {

View File

@ -13,7 +13,7 @@ pub fn handle(
dev: &device::Device,
block: &lrwn::MACCommandSet,
) -> Result<Option<lrwn::MACCommandSet>> {
let _ = (&**block)
let _ = (**block)
.first()
.ok_or_else(|| anyhow!("Expected DeviceTimeReq"))?;

View File

@ -11,7 +11,7 @@ pub fn handle(
dev: &device::Device,
block: &lrwn::MACCommandSet,
) -> Result<Option<lrwn::MACCommandSet>> {
let _ = (&**block)
let _ = (**block)
.first()
.ok_or_else(|| anyhow!("Expected LinkCheckReq"));

View File

@ -9,7 +9,7 @@ pub fn handle(
ds: &mut internal::DeviceSession,
block: &lrwn::MACCommandSet,
) -> Result<Option<lrwn::MACCommandSet>> {
let mac = (&**block)
let mac = (**block)
.first()
.ok_or_else(|| anyhow!("MACCommandSet is empty"))?;

View File

@ -23,10 +23,10 @@ pub fn handle(
return Err(anyhow!("Pending RejoinParamSetupReq expected"));
}
let ans_mac = (&**block)
let ans_mac = (**block)
.first()
.ok_or_else(|| anyhow!("MACCommandSet is empty"))?;
let req_mac = (&**pending.unwrap())
let req_mac = (**pending.unwrap())
.first()
.ok_or_else(|| anyhow!("MACCommandSet is empty"))?;

View File

@ -9,7 +9,7 @@ pub fn handle(
dev: &device::Device,
block: &lrwn::MACCommandSet,
) -> Result<Option<lrwn::MACCommandSet>> {
let block_mac = (&**block)
let block_mac = (**block)
.first()
.ok_or_else(|| anyhow!("MACCommandSet is empty"))?;

View File

@ -12,7 +12,7 @@ pub fn handle(
ds: &mut internal::DeviceSession,
block: &lrwn::MACCommandSet,
) -> Result<Option<lrwn::MACCommandSet>> {
let block_mac = (&**block)
let block_mac = (**block)
.first()
.ok_or_else(|| anyhow!("MACCommandSet is empty"))?;
let block_pl = if let lrwn::MACCommand::ResetInd(pl) = block_mac {

View File

@ -27,10 +27,10 @@ pub fn handle(
return Err(anyhow!("Expected pending RxParamSetupReq"));
}
let req_mac = (&**pending.unwrap())
let req_mac = (**pending.unwrap())
.first()
.ok_or_else(|| anyhow!("MACCommandSet is empty"))?;
let ans_mac = (&**block)
let ans_mac = (**block)
.first()
.ok_or_else(|| anyhow!("MACCommandSet is empty"))?;

View File

@ -20,7 +20,7 @@ pub fn handle(
return Err(anyhow!("Pending RxTimingSetupReq expected"));
}
let req_mac = (&**pending.unwrap())
let req_mac = (**pending.unwrap())
.first()
.ok_or_else(|| anyhow!("MACCommandSet is empty"))?;

View File

@ -38,7 +38,7 @@ pub fn handle(
return Err(anyhow!("Expected pending TxParamSetupReq"));
}
let req_mac = (&**pending.unwrap())
let req_mac = (**pending.unwrap())
.first()
.ok_or_else(|| anyhow!("MACCommandSet is empty"))?;

View File

@ -51,7 +51,7 @@ async fn main() -> Result<()> {
.arg(
Arg::with_name("config-dir")
.required(true)
.short("c")
.short('c')
.long("config-dir")
.value_name("DIR")
.multiple(false)
@ -79,7 +79,7 @@ async fn main() -> Result<()> {
.arg(
Arg::with_name("dir")
.required(true)
.short("d")
.short('d')
.long("dir")
.value_name("DIR")
.multiple(false)

View File

@ -10,7 +10,7 @@ use super::error::Error;
use super::schema::api_key;
use super::{error, get_db_conn};
#[derive(Queryable, Insertable, PartialEq, Debug)]
#[derive(Queryable, Insertable, PartialEq, Eq, Debug)]
#[diesel(table_name = api_key)]
pub struct ApiKey {
pub id: Uuid,

View File

@ -19,7 +19,7 @@ use super::error::Error;
use super::get_db_conn;
use super::schema::{application, application_integration};
#[derive(Clone, Queryable, Insertable, PartialEq, Debug)]
#[derive(Clone, Queryable, Insertable, PartialEq, Eq, Debug)]
#[diesel(table_name = application)]
pub struct Application {
pub id: Uuid,
@ -62,7 +62,7 @@ pub struct Filters {
pub search: Option<String>,
}
#[derive(Queryable, PartialEq, Debug)]
#[derive(Queryable, PartialEq, Eq, Debug)]
pub struct ApplicationListItem {
pub id: Uuid,
pub created_at: DateTime<Utc>,
@ -134,7 +134,7 @@ where
}
}
#[derive(Debug, Clone, PartialEq, AsExpression, FromSqlRow, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, AsExpression, FromSqlRow, Serialize, Deserialize)]
#[diesel(sql_type = Jsonb)]
pub enum IntegrationConfiguration {
None,
@ -164,14 +164,14 @@ impl serialize::ToSql<Jsonb, Pg> for IntegrationConfiguration {
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct HttpConfiguration {
pub headers: HashMap<String, String>,
pub json: bool,
pub event_endpoint_url: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct InfluxDbConfiguration {
pub endpoint: String,
pub db: String,
@ -185,22 +185,22 @@ pub struct InfluxDbConfiguration {
pub bucket: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ThingsBoardConfiguration {
pub server: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct MyDevicesConfiguration {
pub endpoint: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct LoraCloudConfiguration {
pub modem_geolocation_services: LoraCloudModemGeolocationServices,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct LoraCloudModemGeolocationServices {
pub token: String,
pub modem_enabled: bool,
@ -219,7 +219,7 @@ pub struct LoraCloudModemGeolocationServices {
pub geolocation_wifi_payload_field: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct GcpPubSubConfiguration {
pub encoding: i32,
pub credentials_file: String,
@ -227,7 +227,7 @@ pub struct GcpPubSubConfiguration {
pub topic_name: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct AwsSnsConfiguration {
pub encoding: i32,
pub region: String,
@ -236,26 +236,26 @@ pub struct AwsSnsConfiguration {
pub topic_arn: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct AzureServiceBusConfiguration {
pub encoding: i32,
pub connection_string: String,
pub publish_name: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PilotThingsConfiguration {
pub server: String,
pub token: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct IftttConfiguration {
pub key: String,
pub uplink_values: [String; 2], // The first value is reserved for the DevEUI
}
#[derive(Clone, Queryable, Insertable, PartialEq, Debug)]
#[derive(Clone, Queryable, Insertable, PartialEq, Eq, Debug)]
#[diesel(table_name = application_integration)]
pub struct Integration {
pub application_id: Uuid,

View File

@ -82,7 +82,7 @@ impl Default for Device {
}
}
#[derive(Queryable, PartialEq, Debug)]
#[derive(Queryable, PartialEq, Eq, Debug)]
pub struct DeviceListItem {
pub dev_eui: EUI64,
pub name: String,
@ -104,7 +104,7 @@ pub struct Filters {
pub search: Option<String>,
}
#[derive(QueryableByName, PartialEq, Debug)]
#[derive(QueryableByName, PartialEq, Eq, Debug)]
pub struct DevicesActiveInactive {
#[diesel(sql_type = diesel::sql_types::BigInt)]
pub never_seen_count: i64,
@ -114,7 +114,7 @@ pub struct DevicesActiveInactive {
pub inactive_count: i64,
}
#[derive(Queryable, PartialEq, Debug)]
#[derive(Queryable, PartialEq, Eq, Debug)]
pub struct DevicesDataRate {
pub dr: Option<i16>, // as the column is nullable
pub count: i64,

View File

@ -16,7 +16,7 @@ use super::{error, fields, get_db_conn};
use crate::codec::Codec;
use chirpstack_api::internal;
#[derive(Clone, Queryable, Insertable, Debug, PartialEq)]
#[derive(Clone, Queryable, Insertable, Debug, PartialEq, Eq)]
#[diesel(table_name = device_profile)]
pub struct DeviceProfile {
pub id: Uuid,
@ -122,7 +122,7 @@ impl DeviceProfile {
}
}
#[derive(Queryable, PartialEq, Debug)]
#[derive(Queryable, PartialEq, Eq, Debug)]
pub struct DeviceProfileListItem {
pub id: Uuid,
pub created_at: DateTime<Utc>,

View File

@ -15,7 +15,7 @@ use super::schema::device_profile_template;
use super::{error, fields, get_db_conn};
use crate::codec::Codec;
#[derive(Clone, Queryable, Insertable, Debug, PartialEq)]
#[derive(Clone, Queryable, Insertable, Debug, PartialEq, Eq)]
#[diesel(table_name = device_profile_template)]
pub struct DeviceProfileTemplate {
pub id: String,
@ -114,7 +114,7 @@ impl Default for DeviceProfileTemplate {
}
}
#[derive(Queryable, PartialEq, Debug)]
#[derive(Queryable, PartialEq, Eq, Debug)]
pub struct DeviceProfileTemplateListItem {
pub id: String,
pub created_at: DateTime<Utc>,

View File

@ -10,7 +10,7 @@ use super::get_db_conn;
use super::schema::device_queue_item;
use lrwn::EUI64;
#[derive(Queryable, Insertable, PartialEq, Debug, Clone)]
#[derive(Queryable, Insertable, PartialEq, Eq, Debug, Clone)]
#[diesel(table_name = device_queue_item)]
pub struct DeviceQueueItem {
pub id: Uuid,

View File

@ -7,7 +7,7 @@ use diesel::sql_types::Jsonb;
use diesel::{deserialize, serialize};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, AsExpression, FromSqlRow)]
#[derive(Debug, Clone, PartialEq, Eq, AsExpression, FromSqlRow)]
#[diesel(sql_type = Jsonb)]
pub struct KeyValue(HashMap<String, String>);
@ -51,7 +51,7 @@ impl serialize::ToSql<Jsonb, Pg> for KeyValue {
}
}
#[derive(Debug, Clone, AsExpression, FromSqlRow, PartialEq)]
#[derive(Debug, Clone, AsExpression, FromSqlRow, PartialEq, Eq)]
#[diesel(sql_type = Jsonb)]
pub struct Measurements(HashMap<String, Measurement>);
@ -95,7 +95,7 @@ impl serialize::ToSql<Jsonb, Pg> for Measurements {
}
}
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub struct Measurement {
pub name: String,
pub kind: MeasurementKind,
@ -103,7 +103,7 @@ pub struct Measurement {
#[allow(clippy::upper_case_acronyms)]
#[allow(non_camel_case_types)]
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
pub enum MeasurementKind {
// Unknown.
UNKNOWN,

View File

@ -72,7 +72,7 @@ pub struct Filters {
pub search: Option<String>,
}
#[derive(QueryableByName, PartialEq, Debug)]
#[derive(QueryableByName, PartialEq, Eq, Debug)]
pub struct GatewaysActiveInactive {
#[diesel(sql_type = diesel::sql_types::BigInt)]
pub never_seen_count: i64,

View File

@ -200,7 +200,7 @@ pub async fn get(
while ts.le(&end) {
timestamps.push(ts);
keys.push(get_key(name, a, ts));
ts = ts + ChronoDuration::hours(1);
ts += ChronoDuration::hours(1);
}
}
Aggregation::DAY => {

View File

@ -66,7 +66,7 @@ impl Default for MulticastGroup {
}
}
#[derive(Queryable, PartialEq, Debug)]
#[derive(Queryable, PartialEq, Eq, Debug)]
pub struct MulticastGroupListItem {
pub id: Uuid,
pub created_at: DateTime<Utc>,
@ -82,7 +82,7 @@ pub struct Filters {
pub search: Option<String>,
}
#[derive(Clone, Queryable, QueryableByName, Insertable, AsChangeset, Debug, PartialEq)]
#[derive(Clone, Queryable, QueryableByName, Insertable, AsChangeset, Debug, PartialEq, Eq)]
#[diesel(table_name = multicast_group_queue_item)]
pub struct MulticastGroupQueueItem {
pub id: Uuid,
@ -448,8 +448,7 @@ pub async fn enqueue(
true => {
// Increment with margin as requesting the gateway to send the
// downlink 'now' will result in a too late error from the gateway.
scheduler_run_after_ts = scheduler_run_after_ts
+ Duration::from_std(
scheduler_run_after_ts += Duration::from_std(
conf.network.scheduler.multicast_class_c_margin,
)
.unwrap();
@ -478,8 +477,7 @@ pub async fn enqueue(
if !conf.network.scheduler.multicast_class_c_use_gps_time {
// Increment timing for each gateway to avoid colissions.
scheduler_run_after_ts = scheduler_run_after_ts
+ Duration::from_std(
scheduler_run_after_ts += Duration::from_std(
conf.network.scheduler.multicast_class_c_margin,
)
.unwrap();

View File

@ -10,7 +10,7 @@ use super::error::Error;
use super::get_db_conn;
use super::schema::{tenant, tenant_user, user};
#[derive(Queryable, Insertable, PartialEq, Debug, Clone)]
#[derive(Queryable, Insertable, PartialEq, Eq, Debug, Clone)]
#[diesel(table_name = tenant)]
pub struct Tenant {
pub id: Uuid,
@ -51,7 +51,7 @@ impl Default for Tenant {
}
}
#[derive(Queryable, Insertable, AsChangeset, PartialEq, Debug)]
#[derive(Queryable, Insertable, AsChangeset, PartialEq, Eq, Debug)]
#[diesel(table_name = tenant_user)]
pub struct TenantUser {
pub tenant_id: Uuid,
@ -79,7 +79,7 @@ impl Default for TenantUser {
}
}
#[derive(Queryable, PartialEq, Debug)]
#[derive(Queryable, PartialEq, Eq, Debug)]
pub struct TenantUserListItem {
pub tenant_id: Uuid,
pub user_id: Uuid,

View File

@ -16,7 +16,7 @@ use super::error::Error;
use super::get_db_conn;
use super::schema::user;
#[derive(Queryable, Insertable, PartialEq, Debug, Clone)]
#[derive(Queryable, Insertable, PartialEq, Eq, Debug, Clone)]
#[diesel(table_name = user)]
pub struct User {
pub id: Uuid,
@ -248,9 +248,10 @@ pub async fn list(limit: i64, offset: i64) -> Result<Vec<User>, Error> {
// https://github.com/P-H-C/phc-string-format/blob/master/phc-sf-spec.md#specification
fn hash_password(pw: &str, rounds: u32) -> Result<String, Error> {
let salt = SaltString::generate(&mut OsRng);
let hash_resp = Pbkdf2.hash_password(
let hash_resp = Pbkdf2.hash_password_customized(
pw.as_bytes(),
Some(Algorithm::Pbkdf2Sha512.ident()),
None,
pbkdf2::Params {
rounds,
..Default::default()

View File

@ -218,7 +218,7 @@ impl Data {
let dp = self.device_profile.as_ref().unwrap();
let dev = self.device.as_ref().unwrap();
let mut tags = (&*dp.tags).clone();
let mut tags = (*dp.tags).clone();
tags.extend((*dev.tags).clone());
self.device_info = Some(integration_pb::DeviceInfo {
@ -807,7 +807,7 @@ impl Data {
device_queue::delete_item(&qi.id).await?;
let mut tags = (&*dp.tags).clone();
let mut tags = (*dp.tags).clone();
tags.extend((*dev.tags).clone());
integration::ack_event(

View File

@ -193,7 +193,7 @@ impl JoinRequest {
let dp = self.device_profile.as_ref().unwrap();
let dev = self.device.as_ref().unwrap();
let mut tags = (&*dp.tags).clone();
let mut tags = (*dp.tags).clone();
tags.extend((*dev.tags).clone());
self.device_info = Some(integration_pb::DeviceInfo {

View File

@ -171,7 +171,7 @@ impl JoinRequest {
let dp = self.device_profile.as_ref().unwrap();
let dev = self.device.as_ref().unwrap();
let mut tags = (&*dp.tags).clone();
let mut tags = (*dp.tags).clone();
tags.extend((*dev.tags).clone());
self.device_info = Some(integration_pb::DeviceInfo {

View File

@ -10,10 +10,10 @@ repository = "https://github.com/chirpstack/chirpstack"
[dependencies]
hex = "0.4"
cmac = "0.6"
aes = "0.7"
cmac = "0.7"
aes = "0.8"
serde = { version = "1.0", features = ["derive"] }
diesel = { version = "2.0.0-rc.1", features = [ "postgres" ] }
diesel = { version = "2.0.0", features = [ "postgres" ] }
# Error handling
thiserror = "1.0"

View File

@ -1,4 +1,4 @@
use aes::cipher::{generic_array::GenericArray, BlockEncrypt, NewBlockCipher};
use aes::cipher::{generic_array::GenericArray, BlockEncrypt, KeyInit};
use aes::{Aes128, Block};
use anyhow::Result;

View File

@ -1,7 +1,7 @@
use aes::cipher::{generic_array::GenericArray, BlockDecrypt, BlockEncrypt, NewBlockCipher};
use aes::cipher::{generic_array::GenericArray, BlockDecrypt, BlockEncrypt};
use aes::{Aes128, Block};
use anyhow::Result;
use cmac::{Cmac, Mac, NewMac};
use cmac::{Cmac, Mac};
use serde::Serialize;
use super::aes128::AES128Key;
@ -523,6 +523,8 @@ impl PhyPayload {
/// For encrypting a join-request response, use the nwk_key, for rejoin-request 0, 1 and 3
/// response, use the js_enc_key.
pub fn encrypt_join_accept_payload(&mut self, key: &AES128Key) -> Result<()> {
use aes::cipher::KeyInit;
if self.mic.is_none() {
return Err(anyhow!("mic must be set first"));
}
@ -565,6 +567,8 @@ impl PhyPayload {
/// For decrypting a join-request response, use the nwk_key, for rejoin-request 0, 1 and 3
/// response, use the js_enc_key.
pub fn decrypt_join_accept_payload(&mut self, key: &AES128Key) -> Result<()> {
use aes::cipher::KeyInit;
if self.mic.is_none() {
return Err(anyhow!("mic must be set first"));
}
@ -901,6 +905,8 @@ pub fn encrypt_f_opts(
f_cnt: u32,
data: &[u8],
) -> Result<Vec<u8>> {
use aes::cipher::KeyInit;
if data.len() > 15 {
return Err(anyhow!("max size of f_opts is 15 bytes"));
}
@ -945,6 +951,8 @@ pub fn encrypt_frm_payload(
f_cnt: u32,
data: &[u8],
) -> Result<Vec<u8>> {
use aes::cipher::KeyInit;
let mut data = data.to_vec();
let data_len = data.len();

View File

@ -1881,7 +1881,7 @@
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@chirpstack/chirpstack-api-grpc-web@file:../api/grpc-web":
version "4.0.0-rc.4"
version "4.0.0"
dependencies:
"@types/google-protobuf" "^3.15.2"
google-protobuf "^3.17.3"