Skip to content

Commit

Permalink
Pr 299 (#343)
Browse files Browse the repository at this point in the history
Fixed @ilanyu PR #299 conflicts.

---------
Co-authored-by: lanyu <[email protected]>
  • Loading branch information
DanielcoderX authored Jul 14, 2024
1 parent 68078c7 commit 3931a42
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 12 deletions.
14 changes: 12 additions & 2 deletions app/libs/tun2socks.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type StartOptions struct {
PsiphonEnabled bool
Gool bool
DNS string
EndpointType int
}

var global StartOptions
Expand Down Expand Up @@ -101,10 +102,19 @@ func Start(opt *StartOptions) {
var scanOpts *wiresocks.ScanOptions
if global.Endpoint == "" {
scanOpts = &wiresocks.ScanOptions{
V4: true,
V6: true,
V4: false,
V6: false,
MaxRTT: 1500 * time.Millisecond,
}
switch global.EndpointType {
case 0:
scanOpts.V4 = true
scanOpts.V6 = true
case 1:
scanOpts.V4 = true
case 2:
scanOpts.V6 = true
}
}

var psiphonOpts *app.PsiphonOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ private void configure() throws Exception {
if (endpoint.equals("engage.cloudflareclient.com:2408")) {
endpoint = "";
}
int endpointType = fileManager.getInt("USERSETTING_endpoint_type");

String license = fileManager.getString("USERSETTING_license", "").trim();
boolean enablePsiphon = fileManager.getBoolean("USERSETTING_psiphon", false);
Expand All @@ -591,6 +592,7 @@ private void configure() throws Exception {
so.setBindAddress(bindAddress);
so.setLicense(license);
so.setDNS("1.1.1.1");
so.setEndpointType(endpointType);

if (enablePsiphon && !enableGool) {
so.setPsiphonEnabled(true);
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/java/org/bepass/oblivion/ui/LogActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,10 @@ protected int getStatusBarColor() {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_log);

setupScrollListener();
binding.back.setOnClickListener(v -> getOnBackPressedDispatcher().onBackPressed());

binding.copytoclip.setOnClickListener(v -> copyLast100LinesToClipboard());
setupScrollListener();

logUpdater = new Runnable() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ public void onNothingSelected(AdapterView parent) {
binding.country.setEnabled(false);
}
};
binding.txtDarkMode.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
binding.checkBoxDarkMode.setChecked(!binding.checkBoxDarkMode.isChecked());
}
});
binding.checkBoxDarkMode.setChecked(ThemeHelper.getInstance().getCurrentTheme() == ThemeHelper.Theme.DARK);
binding.checkBoxDarkMode.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
Expand Down Expand Up @@ -198,4 +204,4 @@ public String getKey() {
@Override
public void onConnectionStateChange(ConnectionState state) {
}
}
}
42 changes: 41 additions & 1 deletion app/src/main/res/layout/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,47 @@
android:layout_height="1dp"
android:background="@android:color/darker_gray" />
</LinearLayout>
<LinearLayout
android:id="@+id/endpoint_type_layout"
android:layout_width="match_parent"
android:paddingHorizontal="16dp"
android:background="?selectableItemBackground"
android:layout_height="80dp"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end">

<Spinner
android:id="@+id/endpoint_type"
android:entries="@array/endpointType"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/shabnam"
android:minWidth="100dp"
android:text="@string/endpointTypeText"
android:textAlignment="viewEnd"
android:textColor="@color/black"
android:textSize="20sp" />

</LinearLayout>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:fontFamily="@font/shabnam"
android:text="@string/endpointTypeTextDesc"
android:textColor="#9A9A9A"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/endpoint_layout"
android:layout_width="match_parent"
Expand Down Expand Up @@ -647,4 +687,4 @@


</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
</layout>
7 changes: 7 additions & 0 deletions app/src/main/res/layout/endpoint_type_item_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- spinner_item_layout.xml -->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:textSize="18sp"
android:fontFamily="@font/shabnammedium" />
6 changes: 3 additions & 3 deletions app/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
<string name="dialBtText">为了确保应用程序正常运行,请为此应用程序关闭电池优化。</string>
<string name="goToSettings">前往设置</string>
<string name="copytoclip">复制日志到剪贴板</string>
<string name="turn_on_dark_mode">Turn on dark mode</string>
<string name="turn_on_dark_mode_desc">turn on dark mode</string>
<string name="endpointTypeText">端点类型</string>
<string name="endpointTypeTextDesc">用于查找终点IP</string>
<string-array name="countries">
<item>奥地利</item>
<item>比利时</item>
Expand Down Expand Up @@ -81,4 +81,4 @@
<item>美国</item>
</string-array>

</resources>
</resources>
11 changes: 9 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
<string name="dialBtText"> To ensure the app works properly, please disable battery optimization for this app. </string>
<string name="goToSettings"> Go to Settings </string>
<string name="copytoclip">Copy log to clipboard</string>
<string name="turn_on_dark_mode">Turn on dark mode</string>
<string name="endpointTypeText">Endpoint Type</string>
<string name="endpointTypeTextDesc">Used to find the endpoint IP</string>
<string name="turn_on_dark_mode">Turn on dark mode</string>
<string name="turn_on_dark_mode_desc">turn on dark mode</string>
<string-array name="countries">
<item>Austria</item>
Expand Down Expand Up @@ -114,4 +116,9 @@
<item>United Kingdom</item>
<item>United States</item>
</string-array>
</resources>
<string-array name="endpointType">
<item>Auto</item>
<item>IPv4</item>
<item>IPv6</item>
</string-array>
</resources>

0 comments on commit 3931a42

Please sign in to comment.