Skip to content

Commit 0dbdacc

Browse files
Compatibility w/ Rust 1.35-nightly
Signed-off-by: Valerian Saliou <valerian@valeriansaliou.name>
1 parent a7550d2 commit 0dbdacc

23 files changed

+860
-695
lines changed

Cargo.lock

+490-271
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ doc = false
2323
[dependencies]
2424
log = "0.3"
2525
clap = { version = "2.29", default-features = false }
26-
lazy_static = "1.0"
26+
lazy_static = "1.3"
2727
sha2 = "0.7"
2828
time = "0.1"
2929
rand = "0.4"
@@ -38,9 +38,8 @@ native-tls = "0.1"
3838
openssl-probe = "0.1"
3939
lettre = { version = "0.7", features = ["smtp-transport"] }
4040
lettre_email = "0.7"
41-
rocket = { version = "0.3", default-features = false }
42-
rocket_codegen = "0.3"
43-
rocket_contrib = { version = "0.3", features = ["tera_templates"] }
41+
rocket = { version = "0.4", features = ["private-cookies"] }
42+
rocket_contrib = { version = "0.4", features = ["tera_templates"] }
4443
diesel = { version = "1.1", features = ["mysql", "chrono", "numeric"] }
4544
r2d2 = "0.8"
4645
r2d2-diesel = "1.0"

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Raider
77

88
Raider is easy to integrate in your existing system. You can also customize the dashboard look & feel with templates and styles. It can be used as a self-service affiliates system, for your affiliate users to manage their account, create tracking URLs, review their balance and request for payouts.
99

10-
_Tested at Rust version: `rust 1.25.0-nightly (8ccab7eed 2018-01-31)`_
10+
_Tested at Rust version: `rustc 1.35.0-nightly (aa99abeb2 2019-04-14)`_
1111

1212
**🇭🇺 Crafted in Budapest, Hungary.**
1313

src/config/logger.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// License: Mozilla Public License v2.0 (MPL v2.0)
66

77
use log;
8-
use log::{LogRecord, LogLevel, LogMetadata, LogLevelFilter, SetLoggerError};
8+
use log::{LogLevel, LogLevelFilter, LogMetadata, LogRecord, SetLoggerError};
99

1010
pub struct ConfigLogger;
1111

src/config/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
mod defaults;
88

9-
pub mod logger;
109
pub mod config;
10+
pub mod logger;
1111
pub mod reader;

src/config/reader.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
// Copyright: 2018, Valerian Saliou <valerian@valeriansaliou.name>
55
// License: Mozilla Public License v2.0 (MPL v2.0)
66

7+
use log;
78
use std::fs::File;
89
use std::io::Read;
9-
use log;
1010
use toml;
1111

1212
use super::config::*;
@@ -21,9 +21,8 @@ impl ConfigReader {
2121
let mut file = File::open(&APP_ARGS.config).expect("cannot find config file");
2222
let mut conf = String::new();
2323

24-
file.read_to_string(&mut conf).expect(
25-
"cannot read config file",
26-
);
24+
file.read_to_string(&mut conf)
25+
.expect("cannot read config file");
2726

2827
log::debug!("read config file: {}", &APP_ARGS.config);
2928

src/exchange/manager.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
// Copyright: 2018, Valerian Saliou <valerian@valeriansaliou.name>
55
// License: Mozilla Public License v2.0 (MPL v2.0)
66

7-
use std::thread;
8-
use std::sync::RwLock;
9-
use std::sync::Arc;
10-
use std::collections::HashMap;
11-
use std::time::Duration;
127
use log;
138
use reqwest::{Client, StatusCode};
9+
use std::collections::HashMap;
10+
use std::sync::Arc;
11+
use std::sync::RwLock;
12+
use std::thread;
13+
use std::time::Duration;
1414

1515
use APP_CONF;
1616

@@ -19,7 +19,6 @@ const RETRY_POLL_SECONDS: u64 = 30;
1919

2020
lazy_static! {
2121
static ref RATES: Arc<RwLock<HashMap<String, f32>>> = Arc::new(RwLock::new(HashMap::new()));
22-
2322
static ref HTTP_CLIENT: Client = Client::builder()
2423
.timeout(Duration::from_secs(20))
2524
.gzip(true)
@@ -46,7 +45,9 @@ fn update_rates() -> Result<(), ()> {
4645
let response = HTTP_CLIENT
4746
.get(&format!(
4847
"{}/api/latest?access_key={}&base={}",
49-
&APP_CONF.exchange.fixer.endpoint, &APP_CONF.exchange.fixer.access_key, &APP_CONF.payout.currency
48+
&APP_CONF.exchange.fixer.endpoint,
49+
&APP_CONF.exchange.fixer.access_key,
50+
&APP_CONF.payout.currency
5051
))
5152
.send();
5253

src/main.rs

+22-21
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
// Copyright: 2018, Valerian Saliou <valerian@valeriansaliou.name>
55
// License: Mozilla Public License v2.0 (MPL v2.0)
66

7-
#![feature(use_extern_macros, custom_derive, plugin)]
8-
#![plugin(rocket_codegen)]
7+
#![feature(proc_macro_hygiene, decl_macro)]
98

109
#[macro_use(log)]
1110
extern crate log;
@@ -17,27 +16,28 @@ extern crate lazy_static;
1716
extern crate diesel;
1817
#[macro_use]
1918
extern crate serde_derive;
20-
extern crate sha2;
21-
extern crate time;
22-
extern crate rand;
23-
extern crate validate;
24-
extern crate toml;
19+
#[macro_use]
20+
extern crate rocket;
2521
extern crate base64;
26-
extern crate url_serde;
22+
extern crate bigdecimal;
2723
extern crate chrono;
28-
extern crate native_tls;
29-
extern crate openssl_probe;
24+
extern crate iso_country;
3025
extern crate lettre;
3126
extern crate lettre_email;
27+
extern crate native_tls;
28+
extern crate num_traits;
29+
extern crate openssl_probe;
3230
extern crate r2d2;
3331
extern crate r2d2_diesel;
34-
extern crate rocket;
35-
extern crate rocket_contrib;
32+
extern crate rand;
3633
extern crate reqwest;
37-
extern crate bigdecimal;
38-
extern crate num_traits;
34+
extern crate rocket_contrib;
3935
extern crate separator;
40-
extern crate iso_country;
36+
extern crate sha2;
37+
extern crate time;
38+
extern crate toml;
39+
extern crate url_serde;
40+
extern crate validate;
4141

4242
mod config;
4343
mod exchange;
@@ -46,9 +46,9 @@ mod responder;
4646
mod storage;
4747
mod track;
4848

49-
use std::thread;
5049
use std::ops::Deref;
5150
use std::str::FromStr;
51+
use std::thread;
5252
use std::time::Duration;
5353

5454
use clap::{App, Arg};
@@ -68,7 +68,7 @@ pub static THREAD_NAME_EXCHANGE: &'static str = "raider-exchange";
6868
pub static THREAD_NAME_RESPONDER: &'static str = "raider-responder";
6969

7070
macro_rules! gen_spawn_managed {
71-
($name:expr, $method:ident, $thread_name:ident, $managed_fn:ident) => (
71+
($name:expr, $method:ident, $thread_name:ident, $managed_fn:ident) => {
7272
fn $method() {
7373
log::debug!("spawn managed thread: {}", $name);
7474

@@ -93,7 +93,7 @@ macro_rules! gen_spawn_managed {
9393
$method();
9494
}
9595
}
96-
)
96+
};
9797
}
9898

9999
lazy_static! {
@@ -130,13 +130,14 @@ fn make_app_args() -> AppArgs {
130130
.get_matches();
131131

132132
// Generate owned app arguments
133-
AppArgs { config: String::from(matches.value_of("config").expect("invalid config value")) }
133+
AppArgs {
134+
config: String::from(matches.value_of("config").expect("invalid config value")),
135+
}
134136
}
135137

136138
fn ensure_states() {
137139
// Ensure all statics are valid (a `deref` is enough to lazily initialize them)
138-
APP_ARGS.deref();
139-
APP_CONF.deref();
140+
let (_, _) = (APP_ARGS.deref(), APP_CONF.deref());
140141

141142
// Ensure assets path exists
142143
assert_eq!(

src/notifier/email.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
// Copyright: 2018, Valerian Saliou <valerian@valeriansaliou.name>
55
// License: Mozilla Public License v2.0 (MPL v2.0)
66

7-
use std::time::Duration;
8-
use log;
9-
use native_tls::TlsConnector;
10-
use lettre::smtp::{ClientSecurity, SmtpTransportBuilder, SmtpTransport, ConnectionReuseParameters};
117
use lettre::smtp::authentication::Credentials;
128
use lettre::smtp::client::net::ClientTlsParameters;
9+
use lettre::smtp::{
10+
ClientSecurity, ConnectionReuseParameters, SmtpTransport, SmtpTransportBuilder,
11+
};
1312
use lettre::EmailTransport;
1413
use lettre_email::EmailBuilder;
14+
use log;
15+
use native_tls::TlsConnector;
16+
use std::time::Duration;
1517

1618
use APP_CONF;
1719

@@ -52,9 +54,10 @@ impl EmailNotifier {
5254
APP_CONF.email.smtp_username.to_owned(),
5355
APP_CONF.email.smtp_password.to_owned(),
5456
APP_CONF.email.smtp_encrypt,
55-
).map(|mut transport| transport.send(&email_message))
56-
.and(Ok(()))
57-
.or(Err(true));
57+
)
58+
.map(|mut transport| transport.send(&email_message))
59+
.and(Ok(()))
60+
.or(Err(true));
5861
}
5962
}
6063

@@ -94,10 +97,8 @@ fn acquire_transport(
9497

9598
match (smtp_username, smtp_password) {
9699
(Some(smtp_username_value), Some(smtp_password_value)) => {
97-
transport_builder = transport_builder.credentials(Credentials::new(
98-
smtp_username_value,
99-
smtp_password_value,
100-
));
100+
transport_builder = transport_builder
101+
.credentials(Credentials::new(smtp_username_value, smtp_password_value));
101102
}
102103
_ => {}
103104
}

src/responder/asset_file.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
// License: Mozilla Public License v2.0 (MPL v2.0)
66

77
use std::fs::File;
8-
use std::path::{Path, PathBuf};
98
use std::io;
109
use std::ops::{Deref, DerefMut};
10+
use std::path::{Path, PathBuf};
1111
use time::{self, Duration};
1212

13+
use rocket::http::hyper::header::{CacheControl, CacheDirective, Expires, HttpDate};
14+
use rocket::http::ContentType;
1315
use rocket::request::Request;
1416
use rocket::response::{self, Responder};
15-
use rocket::http::ContentType;
16-
use rocket::http::hyper::header::{CacheControl, CacheDirective, Expires, HttpDate};
1717

1818
const ASSETS_EXPIRE_SECONDS: u32 = 10800;
1919

@@ -60,8 +60,7 @@ impl<'r> Responder<'r> for AssetFile {
6060
]));
6161

6262
response.set_header(Expires(HttpDate(
63-
time::now() +
64-
Duration::seconds(ASSETS_EXPIRE_SECONDS as i64),
63+
time::now() + Duration::seconds(ASSETS_EXPIRE_SECONDS as i64),
6564
)));
6665

6766
// Set content type header?

src/responder/auth_guard.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
// License: Mozilla Public License v2.0 (MPL v2.0)
66

77
use log;
8-
use rocket::Outcome;
9-
use rocket::http::{Status, Cookies, Cookie};
10-
use rocket::request::{self, Request, FromRequest};
118
use rand::{self, Rng};
12-
use sha2::{Sha256, Digest};
9+
use rocket::http::{Cookie, Cookies, Status};
10+
use rocket::request::{self, FromRequest, Request};
11+
use rocket::Outcome;
12+
use sha2::{Digest, Sha256};
1313

1414
use APP_CONF;
1515

src/responder/catchers.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
use rocket::response::Redirect;
88

9-
#[error(403)]
9+
#[catch(403)]
1010
pub fn forbidden() -> Redirect {
1111
Redirect::to("/initiate/")
1212
}
1313

14-
#[error(410)]
14+
#[catch(410)]
1515
pub fn gone() -> Redirect {
1616
Redirect::to("/dashboard/")
1717
}

src/responder/context.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// Copyright: 2018, Valerian Saliou <valerian@valeriansaliou.name>
55
// License: Mozilla Public License v2.0 (MPL v2.0)
66

7-
use url_serde::SerdeUrl;
87
use separator::FixedPlaceSeparatable;
8+
use url_serde::SerdeUrl;
99

1010
use config::config::ConfigTrackerBanner;
1111
use APP_CONF;
@@ -25,7 +25,10 @@ lazy_static! {
2525
logo_dark_url: APP_CONF.branding.logo_dark_url.to_owned(),
2626
custom_html: APP_CONF.branding.custom_html.to_owned(),
2727
payout_currency: APP_CONF.payout.currency.to_owned(),
28-
payout_amount_minimum: APP_CONF.payout.amount_minimum.separated_string_with_fixed_place(2),
28+
payout_amount_minimum: APP_CONF
29+
.payout
30+
.amount_minimum
31+
.separated_string_with_fixed_place(2),
2932
track_url: APP_CONF.tracker.track_url.to_owned(),
3033
track_parameter: APP_CONF.tracker.track_parameter.to_owned(),
3134
banners: ConfigContext::map_banners(&APP_CONF.tracker.banner)

0 commit comments

Comments
 (0)