mirror of
https://gitee.com/willfree/min-vpn-client_v2.git
synced 2026-06-03 15:36:14 +08:00
fixed some bugs
This commit is contained in:
Binary file not shown.
@@ -24,15 +24,15 @@
|
||||
<activity
|
||||
android:name=".activity.login.LoginActivity"
|
||||
android:launchMode="singleTask" />
|
||||
<activity
|
||||
android:name=".activity.main.MainActivity"
|
||||
android:launchMode="singleTask" />
|
||||
<activity
|
||||
android:name=".activity.setting.SettingActivity"
|
||||
android:launchMode="singleTask" />
|
||||
<activity
|
||||
android:name=".activity.register.RegisterActivity"
|
||||
android:launchMode="singleTask" />
|
||||
<activity
|
||||
android:name=".activity.main.MainActivity"
|
||||
android:launchMode="singleTask" />
|
||||
<service
|
||||
android:name=".services.MINVpnService"
|
||||
android:permission="android.permission.BIND_VPN_SERVICE">
|
||||
@@ -42,6 +42,12 @@
|
||||
</service>
|
||||
</application>
|
||||
|
||||
<!-- 在SDCard中创建与删除文件权限 -->
|
||||
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"
|
||||
tools:ignore="ProtectedPermissions" />
|
||||
<!-- 往SDCard写入数据权限 -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
tools:ignore="ScopedStorage" />
|
||||
<!-- 以下为copy旧版本VPN的权限定义部分 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
|
||||
@@ -9,12 +9,15 @@ package com.pkusz.min_vpn_client;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import com.pkusz.min_vpn_client.model.MINVpnSettingAPI;
|
||||
|
||||
public class APP extends Application {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
// 网络接口初始化
|
||||
// ...
|
||||
// 本地配置初始化
|
||||
MINVpnSettingAPI.INSTANCE.init(this);
|
||||
System.out.println(MINVpnSettingAPI.INSTANCE.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ package com.pkusz.min_vpn_client.activity.login;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.pkusz.min_vpn_client.model.Request_API;
|
||||
import com.pkusz.min_vpn_client.model.request.LoginRequest;
|
||||
|
||||
import common.LoggerHelper;
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.pkusz.min_vpn_client.extensions;
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description:
|
||||
* @Version: 1.0.0
|
||||
* @Date: 17:22 2021/6/23
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
import android.os.Environment;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class FileUtilsExtensions {
|
||||
public static String getAppDataPath(){
|
||||
File dir=new File(Environment.getDataDirectory().toString()+ "/" + "MIN_VPN" + "/");
|
||||
if(!dir.exists()){
|
||||
dir.mkdir();
|
||||
}
|
||||
return dir.toString();
|
||||
}
|
||||
}
|
||||
@@ -10,14 +10,8 @@ package com.pkusz.min_vpn_client.model;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
|
||||
import com.pkusz.min_vpn_client.utils.EncroptUtilForConnection;
|
||||
import com.pkusz.min_vpn_client.utils.EncryptedSharedPreferenceUtil;
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public enum MINVpnSettingAPI {
|
||||
INSTANCE;
|
||||
|
||||
@@ -33,10 +27,10 @@ public enum MINVpnSettingAPI {
|
||||
private final String SP_LOCAL_SETTING_MIR_PORT = "SP_LOCAL_SETTING_MIR_PORT";
|
||||
private final String SP_LOCAL_SETTING_SERVICE_PREFIX = "SP_LOCAL_SETTING_SERVICE_PREFIX";
|
||||
// BlockChain地址(MIN通信)
|
||||
private final String SP_LOCAL_SETTING_BLOCK_CHAIN_IP_ADDRESS_MIN =
|
||||
"SP_LOCAL_SETTING_BLOCK_CHAIN_IP_ADDRESS_MIN";
|
||||
private final String SP_LOCAL_SETTING_BLOCK_CHAIN_PORT_MIN = "SP_LOCAL_SETTING_BLOCK_CHAIN_PORT_MIN";
|
||||
private final String SP_LOCAL_BLOCK_CHAIN_PREFIX_MIN = "SP_LOCAL_BLOCK_CHAIN_PREFIX_MIN";
|
||||
// private final String SP_LOCAL_SETTING_BLOCK_CHAIN_IP_ADDRESS_MIN =
|
||||
// "SP_LOCAL_SETTING_BLOCK_CHAIN_IP_ADDRESS_MIN";
|
||||
// private final String SP_LOCAL_SETTING_BLOCK_CHAIN_PORT_MIN = "SP_LOCAL_SETTING_BLOCK_CHAIN_PORT_MIN";
|
||||
// private final String SP_LOCAL_BLOCK_CHAIN_PREFIX_MIN = "SP_LOCAL_BLOCK_CHAIN_PREFIX_MIN";
|
||||
// BlockChain地址(SSL-TCP通信)
|
||||
private final String SP_LOCAL_SETTING_BLOCK_CHAIN_IP_ADDRESS_TCP =
|
||||
"SP_LOCAL_SETTING_BLOCK_CHAIN_IP_ADDRESS_TCP";
|
||||
@@ -74,7 +68,7 @@ public enum MINVpnSettingAPI {
|
||||
// app主context,通过它可以获取持久化到本地的配置信息
|
||||
private Context context;
|
||||
|
||||
private void init(Application applicationContext){
|
||||
public void init(Application applicationContext){
|
||||
this.context=applicationContext;
|
||||
EncryptedSharedPreferenceUtil.getAll(applicationContext).forEach((k,v)->{
|
||||
System.out.println(k+" -> "+v);
|
||||
@@ -107,7 +101,12 @@ public enum MINVpnSettingAPI {
|
||||
localPrefix=(String) v;
|
||||
break;
|
||||
case SP_LOCAL_ISENCTRYPTED:
|
||||
isEncrypted=(boolean) v;
|
||||
String flag=(String) v;
|
||||
if(flag.equals("true")){
|
||||
isEncrypted=true;
|
||||
}else{
|
||||
isEncrypted=false;
|
||||
}
|
||||
break;
|
||||
// case SP_LOCAL_SERVER_SWITCH:
|
||||
// serverSwitch=(Integer)v;
|
||||
@@ -241,13 +240,32 @@ public enum MINVpnSettingAPI {
|
||||
}
|
||||
|
||||
public boolean getEncryptedConfig(){
|
||||
return EncryptedSharedPreferenceUtil.get(context,
|
||||
SP_LOCAL_ISENCTRYPTED,true);
|
||||
String flag=EncryptedSharedPreferenceUtil.get(context,
|
||||
SP_LOCAL_ISENCTRYPTED,"true");
|
||||
if(flag.equals("true")){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateEncryptedConfig(boolean isEncrypted){
|
||||
this.isEncrypted=isEncrypted;
|
||||
EncryptedSharedPreferenceUtil.put(context,
|
||||
SP_LOCAL_ISENCTRYPTED,isEncrypted);
|
||||
SP_LOCAL_ISENCTRYPTED,String.valueOf(isEncrypted));
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return "username: "+this.getUsername()+"\n"+
|
||||
"password: "+this.getPassword()+"\n"+
|
||||
"local prefix: "+this.getLocalPrefix()+"\n"+
|
||||
"mir ip: "+this.getMirIpAddress()+"\n"+
|
||||
"mir port: "+this.getMirPort()+"\n"+
|
||||
"vpnServer prefix: "+this.getServicePrefix()+"\n"+
|
||||
"bc ip: "+this.getBlockChainIpAddress()+"\n"+
|
||||
"bc tcp port: "+this.getBcTcpPort()+"\n"+
|
||||
"bc ssl port: "+this.getBcSslPort()+"\n"+
|
||||
"encrypted: "+this.getEncryptedConfig()+"\n"+
|
||||
"mode: "+this.getProxyMode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.pkusz.min_vpn_client.utils;
|
||||
|
||||
import com.pkusz.min_vpn_client.extensions.FileUtilsExtensions;
|
||||
|
||||
import cn.qjm253.min_vpn.extensions.FileUtilsExtensionsKt;
|
||||
import common.LoggerHelper;
|
||||
import minsecurity.certificate.cert.Certificate;
|
||||
import minsecurity.identity.Identity;
|
||||
import security.KeyChain;
|
||||
import cn.qjm253.quick_android_base.util.FileUtils;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
@@ -19,7 +19,7 @@ public enum KeyManager {
|
||||
INSTANCE;
|
||||
private KeyChain keyChain = null;
|
||||
|
||||
private String appPath= FileUtilsExtensions.getAppDataPath();
|
||||
private String appPath= FileUtilsExtensionsKt.getAppDataPath(FileUtils.INSTANCE);
|
||||
|
||||
KeyManager() {
|
||||
LoggerHelper.severe("appPath: "+appPath);
|
||||
|
||||
Reference in New Issue
Block a user