Skip to content
This repository was archived by the owner on Feb 21, 2025. It is now read-only.

Insecure 18 02 25 #611

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ async fn _make_http_request<T: Serialize>(
url: &str,
body: &T,
) -> Result<Response, String> {
// NOTE: if you're going to use https make sure that you set insecure flag from cmdline
let client = Client::builder().build().map_err(|e| e.to_string())?;

let request_builder = match method {
Expand Down
11 changes: 6 additions & 5 deletions src/http/routers/v1/dashboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use hyper::Body;
use crate::custom_error::ScratchError;
use crate::global_context::SharedGlobalContext;

use reqwest::Client;
use reqwest;
use serde::{Serialize, Deserialize};
use tracing::info;
use tokio::io;
Expand All @@ -25,11 +25,11 @@ struct DashboardPlotsResponse {
}

async fn fetch_data(
http_client: &reqwest::Client,
url: &String,
api_key: &String,
) -> Result<Vec<RHData>, String> {
let client = Client::new();
let response = match client
let response = match http_client
.get(url)
.header("Authorization", format!("Bearer {}", api_key))
.send().await {
Expand Down Expand Up @@ -65,15 +65,16 @@ pub async fn get_dashboard_plots(
) -> axum::response::Result<Response<Body>, ScratchError> {

let caps = crate::global_context::try_load_caps_quickly_if_not_present(global_context.clone(), 0).await?;
let (api_key, url) = {
let (http_client, api_key, url) = {
let gcx_locked = global_context.read().await;
(gcx_locked.cmdline.api_key.clone(), caps.read().unwrap().telemetry_basic_retrieve_my_own.clone())
(gcx_locked.http_client.clone(), gcx_locked.cmdline.api_key.clone(), caps.read().unwrap().telemetry_basic_retrieve_my_own.clone())
};
if url.is_empty() {
return Err(ScratchError::new(StatusCode::INTERNAL_SERVER_ERROR, "Error: no url provided from caps".to_string()));
}

let mut records = match fetch_data(
&http_client,
&url,
&api_key
).await {
Expand Down
1 change: 1 addition & 0 deletions src/trajectories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use tokio::sync::{RwLock as ARwLock, Mutex as AMutex};
use tracing::info;
use chrono::{NaiveDateTime, Utc};

// NOTE: if you're going to use it with local https proxy make sure that you set insecure flag from cmdline
static URL: &str = "https://www.smallcloud.ai/v1/trajectory-get-all";
static TRAJECTORIES_STATUS_FILENAME: &str = "trajectories_last_update";
static TRAJECTORIES_UPDATE_EACH_N_DAYS: i64 = 7;
Expand Down
7 changes: 6 additions & 1 deletion src/vecdb/vdb_highlev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,14 @@ impl VecDb {
api_key.clone(),
memdb.clone(),
).await));
let mut http_client_builder = reqwest::Client::builder();
if cmdline.insecure {
http_client_builder = http_client_builder.danger_accept_invalid_certs(true)
}
let vecdb_emb_client = Arc::new(AMutex::new(http_client_builder.build().unwrap()));
Ok(VecDb {
memdb: memdb.clone(),
vecdb_emb_client: Arc::new(AMutex::new(reqwest::Client::new())),
vecdb_emb_client,
vecdb_handler,
vectorizer_service,
constants: constants.clone(),
Expand Down
1 change: 1 addition & 0 deletions src/vecdb/vdb_remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ impl VecdbSearch for VecDbRemote {
_vecdb_scope_filter_mb: Option<String>,
_api_key: &String,
) -> Result<SearchResult, String> {
// NOTE: if you're going to use https make sure that you set insecure flag from cmdline
let url = "http://127.0.0.1:8008/v1/vdb-search".to_string();
let mut headers = HeaderMap::new();
// headers.insert(AUTHORIZATION, HeaderValue::from_str(&format!("Bearer {}", self.token)).unwrap());
Expand Down
Loading