diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index a36a1bae..48241ce3 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -7,6 +7,8 @@
+
+
diff --git a/app/src/main/java/org/bepass/oblivion/ui/MainActivity.java b/app/src/main/java/org/bepass/oblivion/ui/MainActivity.java
index ada7bb6e..6462a784 100644
--- a/app/src/main/java/org/bepass/oblivion/ui/MainActivity.java
+++ b/app/src/main/java/org/bepass/oblivion/ui/MainActivity.java
@@ -188,8 +188,18 @@ private void updateUIForConnectingState() {
private void updateUIForConnectedState() {
binding.switchButton.setEnabled(true);
if (FileManager.getBoolean("USERSETTING_proxymode")) {
- binding.stateText.setText(String.format(Locale.getDefault(), "%s\nsocks5 on 127.0.0.1:%s", getString(R.string.connected), FileManager.getString("USERSETTING_port")));
- } else {
+ if (FileManager.getBoolean("USERSETTING_lan")) {
+ String lanIP;
+ try {
+ lanIP = NetworkUtils.getLocalIpAddress(this);
+ binding.stateText.setText(String.format(Locale.getDefault(), "%s\n socks5 over LAN on\n %s:%s", getString(R.string.connected), lanIP, FileManager.getString("USERSETTING_port")));
+ } catch (Exception e) {
+ binding.stateText.setText(String.format(Locale.getDefault(), "%s\n socks5 over LAN on\n 127.0.0.1:%s", getString(R.string.connected), FileManager.getString("USERSETTING_port")));
+ }
+ } else {
+ binding.stateText.setText(String.format(Locale.getDefault(), "%s\nsocks5 on 127.0.0.1:%s", getString(R.string.connected), FileManager.getString("USERSETTING_port")));
+ }
+ }else {
binding.stateText.setText(R.string.connected);
}
binding.switchButton.setChecked(true, false);
diff --git a/app/src/main/java/org/bepass/oblivion/utils/NetworkUtils.java b/app/src/main/java/org/bepass/oblivion/utils/NetworkUtils.java
index 16baf567..03210135 100644
--- a/app/src/main/java/org/bepass/oblivion/utils/NetworkUtils.java
+++ b/app/src/main/java/org/bepass/oblivion/utils/NetworkUtils.java
@@ -7,11 +7,16 @@
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
+import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Handler;
import org.bepass.oblivion.enums.ConnectionState;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Locale;
+
public class NetworkUtils {
private static final Handler handler = new Handler();
@@ -53,4 +58,54 @@ private static boolean isConnectedToInternet(Context context) {
}
return false;
}
+ public static String getLocalIpAddress(Context context) {
+ ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
+
+ if (activeNetwork != null && activeNetwork.isConnected()) {
+ if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) {
+ // Get IP Address from Wi-Fi
+ WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
+ int ipAddress = wifiManager.getConnectionInfo().getIpAddress();
+ return String.format(Locale.US,"%d.%d.%d.%d",
+ (ipAddress & 0xff),
+ (ipAddress >> 8 & 0xff),
+ (ipAddress >> 16 & 0xff),
+ (ipAddress >> 24 & 0xff));
+ } else if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
+ // Get IP Address from Mobile Data using InetAddress
+ try {
+ InetAddress ip = InetAddress.getByName("google.com");
+ return ip.getHostAddress();
+ } catch (UnknownHostException e) {
+ e.printStackTrace();
+ }
+ }
+ } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ // For devices running Android Marshmallow or higher
+ NetworkCapabilities capabilities = connectivityManager.getNetworkCapabilities(connectivityManager.getActiveNetwork());
+ if (capabilities != null && capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
+ // Get IP Address from Wi-Fi
+ WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
+ int ipAddress = wifiManager.getConnectionInfo().getIpAddress();
+ return String.format(Locale.US,"%d.%d.%d.%d",
+ (ipAddress & 0xff),
+ (ipAddress >> 8 & 0xff),
+ (ipAddress >> 16 & 0xff),
+ (ipAddress >> 24 & 0xff));
+ } else if (capabilities != null && capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) {
+ // Get IP Address from Mobile Data using InetAddress
+ try {
+ InetAddress ip = InetAddress.getByName("google.com");
+ return ip.getHostAddress();
+ } catch (UnknownHostException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return null; // Return null if no connection is available
+ }
+
+
}