mirror of
https://github.com/jwinterm/grim.git
synced 2026-12-03 03:03:58 +01:00
tor: handle client creation error
This commit is contained in:
+12
-4
@@ -19,7 +19,7 @@ use std::collections::{BTreeMap, BTreeSet};
|
|||||||
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::thread;
|
use std::{fs, thread};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use arti_client::config::{CfgPath, TorClientConfigBuilder};
|
use arti_client::config::{CfgPath, TorClientConfigBuilder};
|
||||||
@@ -83,10 +83,18 @@ impl Default for Tor {
|
|||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
let runtime = TokioNativeTlsRuntime::create().unwrap();
|
let runtime = TokioNativeTlsRuntime::create().unwrap();
|
||||||
let config = Self::build_config();
|
let config = Self::build_config();
|
||||||
let client = TorClient::with_runtime(runtime)
|
let client = if let Ok(c) = TorClient::with_runtime(runtime)
|
||||||
.config(config.clone())
|
.config(config.clone())
|
||||||
.create_unbootstrapped()
|
.create_unbootstrapped() {
|
||||||
.unwrap();
|
c
|
||||||
|
} else {
|
||||||
|
fs::remove_dir_all(TorConfig::state_path()).unwrap();
|
||||||
|
fs::remove_dir_all(TorConfig::cache_path()).unwrap();
|
||||||
|
let runtime = TokioNativeTlsRuntime::create().unwrap();
|
||||||
|
TorClient::with_runtime(runtime)
|
||||||
|
.config(config.clone())
|
||||||
|
.create_unbootstrapped().unwrap()
|
||||||
|
};
|
||||||
Self {
|
Self {
|
||||||
running_services: Arc::new(RwLock::new(BTreeMap::new())),
|
running_services: Arc::new(RwLock::new(BTreeMap::new())),
|
||||||
starting_services: Arc::new(RwLock::new(BTreeSet::new())),
|
starting_services: Arc::new(RwLock::new(BTreeSet::new())),
|
||||||
|
|||||||
Reference in New Issue
Block a user