From 6754e093aac25296e856b6a0150bb910e53ba13f Mon Sep 17 00:00:00 2001 From: Andrew Weiss Date: Wed, 1 May 2019 10:45:28 -0700 Subject: [PATCH] Add proxy configuration --- builder_derive/Cargo.toml | 2 +- core/Cargo.toml | 2 +- core/src/configuration.rs | 2 ++ core/src/transport.rs | 14 +++++++++----- jvm_bare_agent/Cargo.toml | 2 +- jvm_bare_agent/src/lib.rs | 4 ++-- jvm_core/Cargo.toml | 2 +- jvm_sdk_agent/Cargo.toml | 2 +- jvm_sdk_agent/src/lib.rs | 4 ++-- pyagent/Cargo.toml | 2 +- 10 files changed, 21 insertions(+), 15 deletions(-) diff --git a/builder_derive/Cargo.toml b/builder_derive/Cargo.toml index c4efc2a..fa101ba 100644 --- a/builder_derive/Cargo.toml +++ b/builder_derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "builder_derive" -version = "0.1.0" +version = "0.1.1" authors = ["Andrew Weiss "] edition = "2018" diff --git a/core/Cargo.toml b/core/Cargo.toml index 4e0fbe7..ad335ed 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rollbar-rust" -version = "0.1.0" +version = "0.1.1" authors = ["Andrew Weiss "] edition = "2018" diff --git a/core/src/configuration.rs b/core/src/configuration.rs index 02c4e2b..1004158 100644 --- a/core/src/configuration.rs +++ b/core/src/configuration.rs @@ -10,6 +10,7 @@ pub struct Configuration { pub code_version: Option, pub log_level: Level, pub timeout: u64, + pub proxy: Option, } impl Default for Configuration { @@ -22,6 +23,7 @@ impl Default for Configuration { code_version: None, log_level: Level::Info, timeout: 10, + proxy: None, } } } diff --git a/core/src/transport.rs b/core/src/transport.rs index 49c58b5..1271615 100644 --- a/core/src/transport.rs +++ b/core/src/transport.rs @@ -6,7 +6,7 @@ use std::time::Duration; use crate::configuration::Configuration; use crate::types::Item; -use reqwest::Client; +use reqwest::{Client, Proxy}; const QUEUE_DEPTH: usize = 50; @@ -32,11 +32,15 @@ impl HttpTransport { let (tx, rx) = sync_channel(QUEUE_DEPTH); let signal = Arc::new(Condvar::new()); let shutdown = Arc::new(AtomicBool::new(false)); - let client = Client::builder() + let client_builder = Client::builder() .gzip(true) - .timeout(Duration::from_secs(configuration.timeout)) - .build() - .unwrap(); + .timeout(Duration::from_secs(configuration.timeout)); + let client_builder = if let Some(proxy) = &configuration.proxy { + client_builder.proxy(Proxy::all(proxy).unwrap()) + } else { + client_builder + }; + let client = client_builder.build().unwrap(); #[allow(clippy::mutex_atomic)] let queue_depth = Arc::new(Mutex::new(0)); let endpoint = configuration.endpoint.clone(); diff --git a/jvm_bare_agent/Cargo.toml b/jvm_bare_agent/Cargo.toml index b5c1520..9e7df85 100644 --- a/jvm_bare_agent/Cargo.toml +++ b/jvm_bare_agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rollbar-jvm-agent" -version = "0.1.0" +version = "0.1.1" authors = ["Andrew Weiss "] edition = "2018" diff --git a/jvm_bare_agent/src/lib.rs b/jvm_bare_agent/src/lib.rs index 962b7f5..83e0714 100644 --- a/jvm_bare_agent/src/lib.rs +++ b/jvm_bare_agent/src/lib.rs @@ -16,10 +16,10 @@ use rollbar_jvm::jvmti::*; use rollbar_rust::Configuration; use std::env; use std::os::raw::{c_char, c_void}; -use std::sync::atomic::{AtomicBool, Ordering, ATOMIC_BOOL_INIT}; +use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Once; -static INIT_SUCCESS: AtomicBool = ATOMIC_BOOL_INIT; +static INIT_SUCCESS: AtomicBool = AtomicBool::new(false); static mut CONFIG: Option = None; static INIT: Once = Once::new(); diff --git a/jvm_core/Cargo.toml b/jvm_core/Cargo.toml index 6308a5e..0140514 100644 --- a/jvm_core/Cargo.toml +++ b/jvm_core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rollbar-jvm" -version = "0.1.0" +version = "0.1.1" authors = ["Andrew Weiss "] build = "build.rs" edition = "2018" diff --git a/jvm_sdk_agent/Cargo.toml b/jvm_sdk_agent/Cargo.toml index 359fdf8..b52fb81 100644 --- a/jvm_sdk_agent/Cargo.toml +++ b/jvm_sdk_agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rollbar-java-agent" -version = "0.1.0" +version = "0.1.1" authors = ["Andrew Weiss "] edition = "2018" diff --git a/jvm_sdk_agent/src/lib.rs b/jvm_sdk_agent/src/lib.rs index 6cd60aa..2fbf7b2 100644 --- a/jvm_sdk_agent/src/lib.rs +++ b/jvm_sdk_agent/src/lib.rs @@ -11,9 +11,9 @@ use rollbar_jvm::env::JvmTiEnv; use rollbar_jvm::jni::JniEnv; use rollbar_jvm::jvmti::{jint, jlocation, jmethodID, jobject, jthread, jvmtiEnv, JNIEnv, JavaVM}; use std::os::raw::{c_char, c_void}; -use std::sync::atomic::{AtomicBool, Ordering, ATOMIC_BOOL_INIT}; +use std::sync::atomic::{AtomicBool, Ordering}; -static INIT_SUCCESS: AtomicBool = ATOMIC_BOOL_INIT; +static INIT_SUCCESS: AtomicBool = AtomicBool::new(false); /// This is the Agent entry point that is called by the JVM during the loading phase. /// Any failures in this function will cause the JVM not to start which is strictly diff --git a/pyagent/Cargo.toml b/pyagent/Cargo.toml index cab7336..be451ca 100644 --- a/pyagent/Cargo.toml +++ b/pyagent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pyagent" -version = "0.1.0" +version = "0.1.1" authors = ["Andrew Weiss "] edition = "2018"