Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a211bc24cb | ||
|
|
6f47aa33e8 | ||
|
|
90636bb294 | ||
|
|
ff98ff02c5 | ||
|
|
dc36986255 | ||
|
|
5651e002c4 | ||
|
|
4e7849d1cb | ||
|
|
3a1daf1888 |
@@ -18,8 +18,8 @@ android {
|
||||
minSdkVersion 21
|
||||
targetSdkVersion Integer.parseInt("$targetSdkVer")
|
||||
multiDexEnabled true
|
||||
versionCode 487
|
||||
versionName "1.7.27"
|
||||
versionCode 492
|
||||
versionName "1.7.31"
|
||||
}
|
||||
|
||||
if (props["sign"]) {
|
||||
|
||||
@@ -6,7 +6,8 @@ enum class EConfigType(val value: Int, val protocolScheme: String) {
|
||||
SHADOWSOCKS(3, "ss://"),
|
||||
SOCKS(4, "socks://"),
|
||||
VLESS(5, "vless://"),
|
||||
TROJAN(6, "trojan://");
|
||||
TROJAN(6, "trojan://"),
|
||||
WIREGUARD(7, "wireguard://");
|
||||
|
||||
companion object {
|
||||
fun fromInt(value: Int) = values().firstOrNull { it.value == value }
|
||||
|
||||
@@ -26,7 +26,7 @@ data class ServerConfig(
|
||||
vnext = listOf(V2rayConfig.OutboundBean.OutSettingsBean.VnextBean(
|
||||
users = listOf(V2rayConfig.OutboundBean.OutSettingsBean.VnextBean.UsersBean())))),
|
||||
streamSettings = V2rayConfig.OutboundBean.StreamSettingsBean()))
|
||||
EConfigType.CUSTOM ->
|
||||
EConfigType.CUSTOM, EConfigType.WIREGUARD ->
|
||||
return ServerConfig(configType = configType)
|
||||
EConfigType.SHADOWSOCKS, EConfigType.SOCKS, EConfigType.TROJAN ->
|
||||
return ServerConfig(
|
||||
|
||||
@@ -74,14 +74,18 @@ data class V2rayConfig(
|
||||
var response: Response? = null,
|
||||
/*DNS*/
|
||||
val network: String? = null,
|
||||
val address: String? = null,
|
||||
val address: Any? = null,
|
||||
val port: Int? = null,
|
||||
/*Freedom*/
|
||||
var domainStrategy: String? = null,
|
||||
val redirect: String? = null,
|
||||
val userLevel: Int? = null,
|
||||
/*Loopback*/
|
||||
val inboundTag: String? = null) {
|
||||
val inboundTag: String? = null,
|
||||
/*Wireguard*/
|
||||
val secretKey: String? = null,
|
||||
val peers: List<WireGuardBean>? = null,
|
||||
) {
|
||||
|
||||
data class VnextBean(var address: String = "",
|
||||
var port: Int = DEFAULT_PORT,
|
||||
@@ -113,6 +117,9 @@ data class V2rayConfig(
|
||||
}
|
||||
|
||||
data class Response(var type: String)
|
||||
|
||||
data class WireGuardBean(var publicKey: String = "",
|
||||
var endpoint: String = "")
|
||||
}
|
||||
|
||||
data class StreamSettingsBean(var network: String = DEFAULT_NETWORK,
|
||||
@@ -286,6 +293,8 @@ data class V2rayConfig(
|
||||
|| protocol.equals(EConfigType.SOCKS.name, true)
|
||||
|| protocol.equals(EConfigType.TROJAN.name, true)) {
|
||||
return settings?.servers?.get(0)?.address
|
||||
} else if (protocol.equals(EConfigType.WIREGUARD.name, true)) {
|
||||
return settings?.peers?.get(0)?.endpoint?.substringBeforeLast(":")
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -298,6 +307,8 @@ data class V2rayConfig(
|
||||
|| protocol.equals(EConfigType.SOCKS.name, true)
|
||||
|| protocol.equals(EConfigType.TROJAN.name, true)) {
|
||||
return settings?.servers?.get(0)?.port
|
||||
} else if (protocol.equals(EConfigType.WIREGUARD.name, true)) {
|
||||
return settings?.peers?.get(0)?.endpoint?.substringAfterLast(":")?.toInt()
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -311,6 +322,8 @@ data class V2rayConfig(
|
||||
return settings?.servers?.get(0)?.password
|
||||
} else if (protocol.equals(EConfigType.SOCKS.name, true)) {
|
||||
return settings?.servers?.get(0)?.users?.get(0)?.pass
|
||||
} else if (protocol.equals(EConfigType.WIREGUARD.name, true)) {
|
||||
return settings?.secretKey
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -426,12 +439,10 @@ data class V2rayConfig(
|
||||
|
||||
fun getProxyOutbound(): OutboundBean? {
|
||||
outbounds.forEach { outbound ->
|
||||
if (outbound.protocol.equals(EConfigType.VMESS.name, true) ||
|
||||
outbound.protocol.equals(EConfigType.VLESS.name, true) ||
|
||||
outbound.protocol.equals(EConfigType.SHADOWSOCKS.name, true) ||
|
||||
outbound.protocol.equals(EConfigType.SOCKS.name, true) ||
|
||||
outbound.protocol.equals(EConfigType.TROJAN.name, true)) {
|
||||
return outbound
|
||||
EConfigType.values().forEach {
|
||||
if (outbound.protocol.equals(it.name, true)) {
|
||||
return outbound
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
|
||||
@@ -36,6 +36,7 @@ class V2RayVpnService : VpnService(), ServiceControl {
|
||||
private val settingsStorage by lazy { MMKV.mmkvWithID(MmkvManager.ID_SETTING, MMKV.MULTI_PROCESS_MODE) }
|
||||
|
||||
private lateinit var mInterface: ParcelFileDescriptor
|
||||
private var isRunning = false
|
||||
|
||||
//val fd: Int get() = mInterface.fd
|
||||
private lateinit var process: Process
|
||||
@@ -183,6 +184,7 @@ class V2RayVpnService : VpnService(), ServiceControl {
|
||||
// Create a new interface using the builder and save the parameters.
|
||||
try {
|
||||
mInterface = builder.establish()!!
|
||||
isRunning = true
|
||||
runTun2socks()
|
||||
} catch (e: Exception) {
|
||||
// non-nullable lateinit var
|
||||
@@ -219,6 +221,15 @@ class V2RayVpnService : VpnService(), ServiceControl {
|
||||
process = proBuilder
|
||||
.directory(applicationContext.filesDir)
|
||||
.start()
|
||||
Thread(Runnable {
|
||||
Log.d(packageName,"$TUN2SOCKS check")
|
||||
process.waitFor()
|
||||
Log.d(packageName,"$TUN2SOCKS exited")
|
||||
if (isRunning) {
|
||||
Log.d(packageName,"$TUN2SOCKS restart")
|
||||
runTun2socks()
|
||||
}
|
||||
}).start()
|
||||
Log.d(packageName, process.toString())
|
||||
|
||||
sendFd()
|
||||
@@ -262,6 +273,7 @@ class V2RayVpnService : VpnService(), ServiceControl {
|
||||
// val emptyInfo = VpnNetworkInfo()
|
||||
// val info = loadVpnNetworkInfo(configName, emptyInfo)!! + (lastNetworkInfo ?: emptyInfo)
|
||||
// saveVpnNetworkInfo(configName, info)
|
||||
isRunning = false;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
try {
|
||||
connectivity.unregisterNetworkCallback(defaultNetworkCallback)
|
||||
|
||||
@@ -488,7 +488,7 @@ class MainActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedList
|
||||
if (!it.second.enabled) {
|
||||
return@forEach
|
||||
}
|
||||
val url = it.second.url
|
||||
val url = Utils.idnToASCII(it.second.url)
|
||||
if (!Utils.isValidUrl(url)) {
|
||||
return@forEach
|
||||
}
|
||||
|
||||
@@ -486,7 +486,7 @@ object AngConfigManager {
|
||||
val json = Gson().toJson(vmessQRCode)
|
||||
Utils.encode(json)
|
||||
}
|
||||
EConfigType.CUSTOM -> ""
|
||||
EConfigType.CUSTOM, EConfigType.WIREGUARD -> ""
|
||||
EConfigType.SHADOWSOCKS -> {
|
||||
val remark = "#" + Utils.urlEncode(config.remarks)
|
||||
val pw = Utils.encode("${outbound.getSecurityEncryption()}:${outbound.getPassword()}")
|
||||
|
||||
@@ -429,5 +429,21 @@ object Utils {
|
||||
fun removeWhiteSpace(str: String?): String? {
|
||||
return str?.replace(" ", "")
|
||||
}
|
||||
|
||||
fun idnToASCII(str: String): String {
|
||||
var url = str
|
||||
var prot = ""
|
||||
if (url.startsWith(AppConfig.HTTPS_PROTOCOL)) {
|
||||
url = url.substring(8)
|
||||
prot = AppConfig.HTTPS_PROTOCOL
|
||||
} else if (url.startsWith(AppConfig.HTTP_PROTOCOL)) {
|
||||
url = url.substring(7)
|
||||
prot = AppConfig.HTTP_PROTOCOL
|
||||
}
|
||||
url = prot + IDN.toASCII(url, IDN.ALLOW_UNASSIGNED)
|
||||
if (url != str) return url else {
|
||||
return str
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user