|
@ -3,7 +3,7 @@ use serde::de::DeserializeOwned; |
|
|
use serde_json::Value; |
|
|
use serde_json::Value; |
|
|
use std::{env, time::Duration}; |
|
|
use std::{env, time::Duration}; |
|
|
|
|
|
|
|
|
use reqwest::{blocking::Client, header::USER_AGENT}; |
|
|
|
|
|
use rocket::{ |
|
|
use rocket::{ |
|
|
http::{Cookie, Cookies, SameSite}, |
|
|
http::{Cookie, Cookies, SameSite}, |
|
|
request::{self, FlashMessage, Form, FromRequest, Outcome, Request}, |
|
|
request::{self, FlashMessage, Form, FromRequest, Outcome, Request}, |
|
@ -19,7 +19,7 @@ use crate::{ |
|
|
db::{backup_database, get_sql_server_version, models::*, DbConn, DbConnType}, |
|
|
db::{backup_database, get_sql_server_version, models::*, DbConn, DbConnType}, |
|
|
error::{Error, MapResult}, |
|
|
error::{Error, MapResult}, |
|
|
mail, |
|
|
mail, |
|
|
util::{format_naive_datetime_local, get_display_size, is_running_in_docker}, |
|
|
util::{format_naive_datetime_local, get_display_size, is_running_in_docker, get_reqwest_client}, |
|
|
CONFIG, |
|
|
CONFIG, |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
@ -469,24 +469,22 @@ struct GitCommit { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
fn get_github_api<T: DeserializeOwned>(url: &str) -> Result<T, Error> { |
|
|
fn get_github_api<T: DeserializeOwned>(url: &str) -> Result<T, Error> { |
|
|
let github_api = Client::builder().build()?; |
|
|
let github_api = get_reqwest_client(); |
|
|
|
|
|
|
|
|
Ok(github_api |
|
|
Ok(github_api |
|
|
.get(url) |
|
|
.get(url) |
|
|
.timeout(Duration::from_secs(10)) |
|
|
.timeout(Duration::from_secs(10)) |
|
|
.header(USER_AGENT, "Bitwarden_RS") |
|
|
|
|
|
.send()? |
|
|
.send()? |
|
|
.error_for_status()? |
|
|
.error_for_status()? |
|
|
.json::<T>()?) |
|
|
.json::<T>()?) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
fn has_http_access() -> bool { |
|
|
fn has_http_access() -> bool { |
|
|
let http_access = Client::builder().build().unwrap(); |
|
|
let http_access = get_reqwest_client(); |
|
|
|
|
|
|
|
|
match http_access |
|
|
match http_access |
|
|
.head("https://github.com/dani-garcia/bitwarden_rs") |
|
|
.head("https://github.com/dani-garcia/bitwarden_rs") |
|
|
.timeout(Duration::from_secs(10)) |
|
|
.timeout(Duration::from_secs(10)) |
|
|
.header(USER_AGENT, "Bitwarden_RS") |
|
|
|
|
|
.send() |
|
|
.send() |
|
|
{ |
|
|
{ |
|
|
Ok(r) => r.status().is_success(), |
|
|
Ok(r) => r.status().is_success(), |
|
|