Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setting to use tor proxy #59

Merged
merged 2 commits into from
Nov 26, 2023
Merged
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
10 changes: 9 additions & 1 deletion src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,7 @@ fun load_groupmessages_for_friend(selectedGroupId: String?)
}
}

@OptIn(ExperimentalFoundationApi::class)
@Composable
private fun ToxIDQRCode()
{
Expand Down Expand Up @@ -1180,7 +1181,14 @@ fun set_tox_online_state(new_state: String)
online_button_color_wrapper = Color.Green.toArgb()
} else if (online_button_text_wrapper == "tcp")
{
online_button_color_wrapper = Color.Yellow.toArgb()
if (MainActivity.PREF__orbot_enabled_to_int_used_for_init == 1)
{
online_button_color_wrapper = Color.Magenta.toArgb()
}
else
{
online_button_color_wrapper = Color.Yellow.toArgb()
}
} else
{
online_button_color_wrapper = Color.Red.toArgb()
Expand Down
30 changes: 27 additions & 3 deletions src/main/kotlin/com/zoffcc/applications/trifa/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,14 @@ class MainActivity
@JvmStatic var native_ffmpegav_lib_loaded_error = -1
var tox_service_fg: TrifaToxService? = null
var tox_savefile_directory = "."
var ORBOT_PROXY_HOST = "127.0.0.1"
var ORBOT_PROXY_PORT: Long = 9050
var PREF__udp_enabled = 1
var PREF__audio_play_volume_percent = 100
var PREF__audio_input_filter = 0
var PREF__v4l2_capture_force_mjpeg: Int = 0 // 0 -> auto, 1 -> force MJPEG video capture with v4l2 devices
var PREF__orbot_enabled_to_int = 0
var PREF__orbot_enabled_to_int_used_for_init = -1
var PREF__local_discovery_enabled = 1
var PREF__ipv6_enabled = 1
var PREF__force_udp_only = 0
Expand Down Expand Up @@ -242,15 +245,36 @@ class MainActivity
PREF__ipv6_enabled = ipv6_mode_int
Log.i(TAG, "PREF__ipv6_enabled:" + PREF__ipv6_enabled)

var tox_tor_proxy_int = 0
try
{
if (global_prefs.getBoolean("tox.settings.tor_proxy", false))
{
tox_tor_proxy_int = 1
}
} catch (_: Exception)
{
}
PREF__orbot_enabled_to_int = tox_tor_proxy_int
Log.i(TAG, "PREF__orbot_enabled_to_int:" + PREF__orbot_enabled_to_int)

lock_data_dir_input()

if (!TrifaToxService.TOX_SERVICE_STARTED)
{
var ORBOT_PROXY_HOST = ""
var ORBOT_PROXY_PORT: Long = 0
tox_savefile_directory = PREF__tox_savefile_dir + File.separator
if (PREF__orbot_enabled_to_int == 1)
{
PREF__udp_enabled = 0
PREF__force_udp_only = 0
PREF__local_discovery_enabled = 0
}
Log.i(TAG, "init:PREF__udp_enabled=$PREF__udp_enabled")
init(tox_savefile_directory, PREF__udp_enabled, PREF__local_discovery_enabled, PREF__orbot_enabled_to_int, ORBOT_PROXY_HOST, ORBOT_PROXY_PORT, password_hash, PREF__ipv6_enabled, PREF__force_udp_only, PREF__ngc_video_bitrate, PREF__ngc_video_max_quantizer, PREF__ngc_audio_bitrate, PREF__ngc_audio_samplerate, PREF__ngc_audio_channels)
Log.i(TAG, "init:PREF__force_udp_only=$PREF__force_udp_only")
Log.i(TAG, "init:PREF__local_discovery_enabled=$PREF__local_discovery_enabled")
Log.i(TAG, "init:PREF__orbot_enabled_to_int=$PREF__orbot_enabled_to_int")
PREF__orbot_enabled_to_int_used_for_init = PREF__orbot_enabled_to_int
init(tox_savefile_directory, PREF__udp_enabled, PREF__local_discovery_enabled, PREF__orbot_enabled_to_int_used_for_init, ORBOT_PROXY_HOST, ORBOT_PROXY_PORT, password_hash, PREF__ipv6_enabled, PREF__force_udp_only, PREF__ngc_video_bitrate, PREF__ngc_video_max_quantizer, PREF__ngc_audio_bitrate, PREF__ngc_audio_samplerate, PREF__ngc_audio_channels)
}
val my_tox_id_temp = get_my_toxid()
Log.i(TAG, "MyToxID:$my_tox_id_temp")
Expand Down
23 changes: 23 additions & 0 deletions src/main/kotlin/org/briarproject/briar/desktop/SettingDetails.kt
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,29 @@ fun SettingDetails()
}
// ---- IPv6 ----

// ---- tor proxy ----
var tox_tor_proxy by remember { mutableStateOf(false) }
try
{
if (global_prefs.getBoolean("tox.settings.tor_proxy", false))
{
tox_tor_proxy = true
}
} catch (_: Exception)
{
}
DetailItem(label = i18n("use Tor proxy [on localhost port: 9050]"),
description = (if (tox_tor_proxy) i18n("enabled") else i18n("disabled"))) {
Switch(
checked = tox_tor_proxy,
onCheckedChange = {
global_prefs.putBoolean("tox.settings.tor_proxy", it)
tox_tor_proxy = it
},
)
}
// ---- tor proxy ----

// database prefs ===================
if (orma != null)
{
Expand Down
Loading