Skip to content

Commit

Permalink
feat(tor): setup tor bridges and control port (tari-project#871)
Browse files Browse the repository at this point in the history
## General Info
* We fetch default tor bridges from
https://bridges.torproject.org/bridges?transport=obfs4
* Any changes related to Tor makes Save button visible and display
Restart Dialog
## Notes
* Commented out setting those values using Control Port for now - it
behaves randomly sometimes and doesn't apply those changes.
* Lyrebird(obfs4proxy client) is affected when Windows path has space -
my only solution for now is to run lyrebird binary by hand
* Need to fetch tor bridges using Rust due to CORS issues
## Need to doublecheck
* We manage tor for windows and unix now. We need to make sure all
previous args etc are the same now
* Add tor to CDN for unix systems
* Do I need to generate random password for hash?

![Screenshot from 2024-10-18
09-08-01](https://github.com/user-attachments/assets/9641f04d-7867-46cd-875d-065e245e5ec4)
![Screenshot from 2024-10-18
09-37-31](https://github.com/user-attachments/assets/66779c4c-6098-408d-bf01-2d40b6a41d1e)
![Screenshot from 2024-10-18
09-41-09](https://github.com/user-attachments/assets/e6e2f53f-1420-4244-9cd1-29048512c633)
![Screenshot from 2024-10-18
09-41-23](https://github.com/user-attachments/assets/4be1ac91-c0d4-46f2-a708-1a0aa1a0f372)

---------

Co-authored-by: stringhandler <[email protected]>
  • Loading branch information
mmrrnn and stringhandler authored Oct 22, 2024
1 parent 34c587b commit 0719b9c
Show file tree
Hide file tree
Showing 26 changed files with 615 additions and 69 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@
"typescript-eslint": "^8.8.1",
"vite": "^5.4.9"
}
}
}
10 changes: 9 additions & 1 deletion public/locales/af/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,13 @@
"invalid-seed-words": "Voer 24 woorde in, geskei deur spasies",
"yes": "Yes",
"cancel": "Cancel",
"report-issue": "Rapporteer \"n probleem"
"report-issue": "Rapporteer \"n probleem",
"app-restart-required": "App restart required",
"setup-tor-settings": "Setup Tor Settings for Privacy Control and Connectivity",
"control-port": "Control Port",
"save": "Save",
"errors": {
"invalid-control-port": "Control Port configuration is invalid",
"invalid-bridge": "Bridge configuration is invalid"
}
}
10 changes: 9 additions & 1 deletion public/locales/cn/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,13 @@
"action-requires-restart": "此操作需要重启以应用更改",
"low-hash-rate-warning": "您的哈希率非常低。尝试关闭除Tari Universe以外的所有应用程序",
"invalid-seed-words": "输入24个用空格分隔的单词",
"report-issue": "报告问题"
"report-issue": "报告问题",
"app-restart-required": "App restart required",
"setup-tor-settings": "Setup Tor Settings for Privacy Control and Connectivity",
"control-port": "Control Port",
"save": "Save",
"errors": {
"invalid-control-port": "Control Port configuration is invalid",
"invalid-bridge": "Bridge configuration is invalid"
}
}
10 changes: 9 additions & 1 deletion public/locales/de/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,13 @@
"importing-wallet": "Wallet wird importiert",
"action-requires-restart": "Diese Aktion erfordert einen Neustart, um Änderungen anzuwenden",
"low-hash-rate-warning": "Ihre Hashrate ist sehr niedrig. Versuchen Sie, alle Apps außer Tari Universe zu schließen",
"invalid-seed-words": "Geben Sie 24 Wörter ein, getrennt durch Leerzeichen"
"invalid-seed-words": "Geben Sie 24 Wörter ein, getrennt durch Leerzeichen",
"app-restart-required": "App restart required",
"setup-tor-settings": "Setup Tor Settings for Privacy Control and Connectivity",
"control-port": "Control Port",
"save": "Save",
"errors": {
"invalid-control-port": "Control Port configuration is invalid",
"invalid-bridge": "Bridge configuration is invalid"
}
}
10 changes: 9 additions & 1 deletion public/locales/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,13 @@

"yes": "Yes",
"your-feedback": "Describe your issue, including your Telegram handle if you have one, so that we can contact you with updates.",
"your-reference": "Your reference:<br/><bold>{{logRef}}</bold>"
"your-reference": "Your reference:<br/><bold>{{logRef}}</bold>",
"app-restart-required": "App restart required",
"setup-tor-settings": "Setup Tor Settings for Privacy Control and Connectivity",
"control-port": "Control Port",
"save": "Save",
"errors": {
"invalid-control-port": "Control Port configuration is invalid",
"invalid-bridge": "Bridge configuration is invalid"
}
}
10 changes: 9 additions & 1 deletion public/locales/fr/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,13 @@
"report-issue": "Signaler un problème",
"importing-wallet": "Importation du portefeuille",
"action-requires-restart": "Cette action nécessite un redémarrage pour appliquer les modifications",
"invalid-seed-words": "Entrez 24 mots séparés par des espaces"
"invalid-seed-words": "Entrez 24 mots séparés par des espaces",
"app-restart-required": "App restart required",
"setup-tor-settings": "Setup Tor Settings for Privacy Control and Connectivity",
"control-port": "Control Port",
"save": "Save",
"errors": {
"invalid-control-port": "Control Port configuration is invalid",
"invalid-bridge": "Bridge configuration is invalid"
}
}
10 changes: 9 additions & 1 deletion public/locales/hi/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,13 @@
"action-requires-restart": "इस क्रिया के लिए परिवर्तनों को लागू करने हेतु पुनः आरंभ करना आवश्यक है",
"low-hash-rate-warning": "आपकी हैश रेट बहुत कम है। Tari Universe के अलावा सभी ऐप्स को बंद करने का प्रयास करें",
"invalid-seed-words": "24 शब्दों को स्पेस से अलग करके दर्ज करें",
"report-issue": "समस्या की रिपोर्ट करें"
"report-issue": "समस्या की रिपोर्ट करें",
"app-restart-required": "App restart required",
"setup-tor-settings": "Setup Tor Settings for Privacy Control and Connectivity",
"control-port": "Control Port",
"save": "Save",
"errors": {
"invalid-control-port": "Control Port configuration is invalid",
"invalid-bridge": "Bridge configuration is invalid"
}
}
10 changes: 9 additions & 1 deletion public/locales/id/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,13 @@
"action-requires-restart": "Tindakan ini memerlukan restart untuk menerapkan perubahan",
"low-hash-rate-warning": "Hashrate Anda sangat rendah. Coba tutup semua aplikasi selain Tari Universe",
"invalid-seed-words": "Masukkan 24 kata yang dipisahkan oleh spasi",
"report-issue": "Laporkan masalah"
"report-issue": "Laporkan masalah",
"app-restart-required": "App restart required",
"setup-tor-settings": "Setup Tor Settings for Privacy Control and Connectivity",
"control-port": "Control Port",
"save": "Save",
"errors": {
"invalid-control-port": "Control Port configuration is invalid",
"invalid-bridge": "Bridge configuration is invalid"
}
}
10 changes: 9 additions & 1 deletion public/locales/ja/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,13 @@
"action-requires-restart": "この操作には再起動が必要です。変更を適用します",
"low-hash-rate-warning": "ハッシュレートが非常に低いです。Tari Universe以外のすべてのアプリを閉じてみてください",
"invalid-seed-words": "スペースで区切って24の単語を入力してください",
"report-issue": "問題を報告する"
"report-issue": "問題を報告する",
"app-restart-required": "App restart required",
"setup-tor-settings": "Setup Tor Settings for Privacy Control and Connectivity",
"control-port": "Control Port",
"save": "Save",
"errors": {
"invalid-control-port": "Control Port configuration is invalid",
"invalid-bridge": "Bridge configuration is invalid"
}
}
10 changes: 9 additions & 1 deletion public/locales/ko/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,13 @@
"action-requires-restart": "이 작업은 변경 사항을 적용하기 위해 재시작이 필요합니다",
"low-hash-rate-warning": "해시레이트가 매우 낮습니다. Tari Universe 외의 모든 앱을 닫아보세요",
"invalid-seed-words": "공백으로 구분된 24개의 단어를 입력하세요",
"report-issue": "문제 보고"
"report-issue": "문제 보고",
"app-restart-required": "App restart required",
"setup-tor-settings": "Setup Tor Settings for Privacy Control and Connectivity",
"control-port": "Control Port",
"save": "Save",
"errors": {
"invalid-control-port": "Control Port configuration is invalid",
"invalid-bridge": "Bridge configuration is invalid"
}
}
10 changes: 9 additions & 1 deletion public/locales/pl/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,13 @@
"action-requires-restart": "Ta akcja wymaga ponownego uruchomienia, aby wprowadzić zmiany",
"low-hash-rate-warning": "Twój hash rate jest bardzo niski. Spróbuj zamknąć wszystkie aplikacje poza Tari Universe",
"invalid-seed-words": "Wprowadź 24 słowa oddzielone spacjami",
"report-issue": "Zgłoś problem"
"report-issue": "Zgłoś problem",
"app-restart-required": "Wymagane ponowne uruchomienie",
"setup-tor-settings": "Skonfiguruj sieć Tor w celu prywatności połączenia",
"control-port": "Control Port",
"save": "Zapisz",
"errors": {
"invalid-control-port": "Konfiguracja Control Portu nieprawidłowa",
"invalid-bridge": "Konfiguracja Bridge nieprawidłowa"
}
}
10 changes: 9 additions & 1 deletion public/locales/ru/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,13 @@
"action-requires-restart": "Для применения изменений требуется перезапуск",
"low-hash-rate-warning": "Ваш хешрейт очень низкий. Попробуйте закрыть все приложения, кроме Tari Universe",
"invalid-seed-words": "Введите 24 слова, разделенные пробелами",
"report-issue": "Сообщить о проблеме"
"report-issue": "Сообщить о проблеме",
"app-restart-required": "App restart required",
"setup-tor-settings": "Setup Tor Settings for Privacy Control and Connectivity",
"control-port": "Control Port",
"save": "Save",
"errors": {
"invalid-control-port": "Control Port configuration is invalid",
"invalid-bridge": "Bridge configuration is invalid"
}
}
10 changes: 9 additions & 1 deletion public/locales/tr/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,13 @@
"action-requires-restart": "Bu işlem değişikliklerin uygulanması için yeniden başlatma gerektirir",
"low-hash-rate-warning": "Hashrate\"iniz çok düşük. Tari Evreni dışındaki tüm uygulamaları kapatmayı deneyin",
"invalid-seed-words": "Boşluklarla ayrılmış 24 kelime girin",
"report-issue": "Bir sorunu bildir"
"report-issue": "Bir sorunu bildir",
"app-restart-required": "App restart required",
"setup-tor-settings": "Setup Tor Settings for Privacy Control and Connectivity",
"control-port": "Control Port",
"save": "Save",
"errors": {
"invalid-control-port": "Control Port configuration is invalid",
"invalid-bridge": "Bridge configuration is invalid"
}
}
37 changes: 24 additions & 13 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ tauri-plugin-single-instance = {git = "https://github.com/tauri-apps/plugins-wor
thiserror = "1.0.26"
tokio = {version = "1", features = ["full"]}
tokio-util = {version = "0.7.11", features = ["compat"]}
tor-hash-passwd = "1.0.1"
xz2 = {version = "0.1.7", features = ["static"]}# static bind lzma
zip = "2.2.0"

Expand Down
37 changes: 28 additions & 9 deletions src-tauri/src/binaries/adapter_tor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ pub(crate) struct TorReleaseAdapter {}
#[async_trait]
impl LatestVersionApiAdapter for TorReleaseAdapter {
async fn fetch_releases_list(&self) -> Result<Vec<VersionDownloadInfo>, Error> {
let cdn_tor_bundle_url = "https://cdn-universe.tari.com/torbrowser/13.5.7/tor-expert-bundle-windows-x86_64-13.5.7.tar.gz";

let platform = get_platform_name();
let cdn_tor_bundle_url = format!(
"https://cdn-universe.tari.com/torbrowser/13.5.7/tor-expert-bundle-{}-13.5.7.tar.gz",
platform
);
let mut cdn_responded = false;

let client = reqwest::Client::new();
Expand All @@ -38,7 +41,7 @@ impl LatestVersionApiAdapter for TorReleaseAdapter {
version: "13.5.7".parse().expect("Bad tor version"),
assets: vec![VersionAsset {
url: cdn_tor_bundle_url.to_string(),
name: "tor-expert-bundle-windows-x86_64-13.5.7.tar.gz".to_string(),
name: format!("tor-expert-bundle-{}-13.5.7.tar.gz", platform),
}],
};
return Ok(vec![version]);
Expand All @@ -48,9 +51,9 @@ impl LatestVersionApiAdapter for TorReleaseAdapter {
let version = VersionDownloadInfo {
version: "13.5.7".parse().expect("Bad tor version"),
assets: vec![VersionAsset {
url: "https://archive.torproject.org/tor-package-archive/torbrowser/13.5.7/tor-expert-bundle-windows-x86_64-13.5.7.tar.gz".to_string(),
name: "tor-expert-bundle-windows-x86_64-13.5.7.tar.gz".to_string(),
}],
url: format!("https://dist.torproject.org/torbrowser/13.5.7/tor-expert-bundle-{}-13.5.7.tar.gz", platform),
name: format!("tor-expert-bundle-{}-13.5.7.tar.gz", platform),
}]
};
Ok(vec![version])
}
Expand Down Expand Up @@ -109,14 +112,14 @@ impl LatestVersionApiAdapter for TorReleaseAdapter {
}

if cfg!(target_os = "macos") && cfg!(target_arch = "x86_64") {
panic!("Unsupported OS");
name_suffix = r"macos-x86_64.*\.gz";
}

if cfg!(target_os = "macos") && cfg!(target_arch = "aarch64") {
panic!("Unsupported OS");
name_suffix = r"macos-aarch64.*\.gz";
}
if cfg!(target_os = "linux") {
panic!("Unsupported OS");
name_suffix = r"linux-x86_64.*\.gz";
}
if name_suffix.is_empty() {
panic!("Unsupported OS");
Expand All @@ -136,3 +139,19 @@ impl LatestVersionApiAdapter for TorReleaseAdapter {
Ok(platform.clone())
}
}

fn get_platform_name() -> String {
if cfg!(target_os = "windows") {
return "windows-x86_64".to_string();
}
if cfg!(target_os = "macos") && cfg!(target_arch = "x86_64") {
return "macos-x86_64".to_string();
}
if cfg!(target_os = "macos") && cfg!(target_arch = "aarch64") {
return "macos-aarch64".to_string();
}
if cfg!(target_os = "linux") {
return "linux-x86_64".to_string();
}
panic!("Unsupported OS");
}
Loading

0 comments on commit 0719b9c

Please sign in to comment.