Compare commits
12 Commits
1.5.2-v2fl
...
1.5.7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03eeeb9b62 | ||
|
|
038daf5fda | ||
|
|
bfd1387d9b | ||
|
|
5afec5cf25 | ||
|
|
ec29bdf5bf | ||
|
|
57efab093f | ||
|
|
9c92a64811 | ||
|
|
7ddc82d5cd | ||
|
|
c286ba18a8 | ||
|
|
867b5fc880 | ||
|
|
e8a7fa5320 | ||
|
|
f2f9e55286 |
@@ -17,7 +17,6 @@ import (
|
||||
v2filesystem "v2ray.com/core/common/platform/filesystem"
|
||||
v2stats "v2ray.com/core/features/stats"
|
||||
v2serial "v2ray.com/core/infra/conf/serial"
|
||||
_ "v2ray.com/core/main/distro/all"
|
||||
v2internet "v2ray.com/core/transport/internet"
|
||||
|
||||
v2applog "v2ray.com/core/app/log"
|
||||
|
||||
58
AndroidLibV2rayLite/libv2init.go
Normal file
58
AndroidLibV2rayLite/libv2init.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package libv2ray
|
||||
|
||||
import (
|
||||
// The following are necessary as they register handlers in their init functions.
|
||||
|
||||
// Required features. Can't remove unless there is replacements.
|
||||
_ "v2ray.com/core/app/dispatcher"
|
||||
_ "v2ray.com/core/app/proxyman/inbound"
|
||||
_ "v2ray.com/core/app/proxyman/outbound"
|
||||
|
||||
// Other optional features.
|
||||
_ "v2ray.com/core/app/dns"
|
||||
_ "v2ray.com/core/app/log"
|
||||
_ "v2ray.com/core/app/policy"
|
||||
_ "v2ray.com/core/app/router"
|
||||
_ "v2ray.com/core/app/stats"
|
||||
|
||||
// Inbound and outbound proxies.
|
||||
_ "v2ray.com/core/proxy/blackhole"
|
||||
_ "v2ray.com/core/proxy/dns"
|
||||
_ "v2ray.com/core/proxy/dokodemo"
|
||||
_ "v2ray.com/core/proxy/freedom"
|
||||
_ "v2ray.com/core/proxy/http"
|
||||
_ "v2ray.com/core/proxy/mtproto"
|
||||
_ "v2ray.com/core/proxy/shadowsocks"
|
||||
_ "v2ray.com/core/proxy/socks"
|
||||
_ "v2ray.com/core/proxy/trojan"
|
||||
_ "v2ray.com/core/proxy/vless/inbound"
|
||||
_ "v2ray.com/core/proxy/vless/outbound"
|
||||
_ "v2ray.com/core/proxy/vmess/inbound"
|
||||
_ "v2ray.com/core/proxy/vmess/outbound"
|
||||
|
||||
// Transport
|
||||
_ "v2ray.com/core/transport/internet/http"
|
||||
_ "v2ray.com/core/transport/internet/kcp"
|
||||
_ "v2ray.com/core/transport/internet/quic"
|
||||
_ "v2ray.com/core/transport/internet/tcp"
|
||||
_ "v2ray.com/core/transport/internet/tls"
|
||||
_ "v2ray.com/core/transport/internet/udp"
|
||||
_ "v2ray.com/core/transport/internet/websocket"
|
||||
|
||||
// Transport headers
|
||||
_ "v2ray.com/core/transport/internet/headers/http"
|
||||
_ "v2ray.com/core/transport/internet/headers/noop"
|
||||
_ "v2ray.com/core/transport/internet/headers/srtp"
|
||||
_ "v2ray.com/core/transport/internet/headers/tls"
|
||||
_ "v2ray.com/core/transport/internet/headers/utp"
|
||||
_ "v2ray.com/core/transport/internet/headers/wechat"
|
||||
_ "v2ray.com/core/transport/internet/headers/wireguard"
|
||||
|
||||
// JSON config support. Choose only one from the two below.
|
||||
// The following line loads JSON from v2ctl
|
||||
// _ "v2ray.com/core/main/json"
|
||||
// The following line loads JSON internally
|
||||
_ "v2ray.com/core/main/jsonem"
|
||||
// Load config from file or http(s)
|
||||
// _ "v2ray.com/core/main/confloader/external"
|
||||
)
|
||||
@@ -1,12 +1,13 @@
|
||||
# v2rayNG
|
||||
|
||||
A V2Ray client for Android
|
||||
A V2Ray client for Android, support [Xray core](https://github.com/XTLS/Xray-core) and [v2fly core](https://github.com/v2fly/v2ray-core)
|
||||
|
||||
[](https://developer.android.com/about/versions/jelly-bean#android-4.2)
|
||||
[](https://kotlinlang.org)
|
||||
[](https://github.com/2dust/v2rayNG/commits/master)
|
||||
[](https://www.codefactor.io/repository/github/2dust/v2rayng)
|
||||
[](https://github.com/2dust/v2rayNG/releases)
|
||||
[](https://t.me/v2rayn)
|
||||
|
||||
<a href="https://play.google.com/store/apps/details?id=com.v2ray.ang">
|
||||
<img alt="Get it on Google Play" src="https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png" width="165" height="64" />
|
||||
|
||||
@@ -96,6 +96,7 @@ dependencies {
|
||||
implementation 'me.dm7.barcodescanner:core:1.9.8'
|
||||
implementation 'me.dm7.barcodescanner:zxing:1.9.8'
|
||||
implementation 'com.github.jorgecastilloprz:fabprogresscircle:1.01@aar'
|
||||
implementation 'me.drakeet.support:toastcompat:1.1.0'
|
||||
|
||||
implementation(name: 'libv2ray', ext: 'aar')
|
||||
//implementation(name: 'tun2socks', ext: 'aar')
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.os.Build
|
||||
import android.widget.Toast
|
||||
import com.v2ray.ang.AngApplication
|
||||
import me.dozen.dpreference.DPreference
|
||||
import me.drakeet.support.toast.ToastCompat
|
||||
import org.json.JSONObject
|
||||
import java.net.URLConnection
|
||||
|
||||
@@ -22,13 +23,13 @@ val Context.v2RayApplication: AngApplication
|
||||
val Context.defaultDPreference: DPreference
|
||||
get() = v2RayApplication.defaultDPreference
|
||||
|
||||
inline fun Context.toast(message: Int): Toast = Toast
|
||||
inline fun Context.toast(message: Int): Toast = ToastCompat
|
||||
.makeText(this, message, Toast.LENGTH_SHORT)
|
||||
.apply {
|
||||
show()
|
||||
}
|
||||
|
||||
inline fun Context.toast(message: CharSequence): Toast = Toast
|
||||
inline fun Context.toast(message: CharSequence): Toast = ToastCompat
|
||||
.makeText(this, message, Toast.LENGTH_SHORT)
|
||||
.apply {
|
||||
show()
|
||||
|
||||
@@ -50,15 +50,16 @@ class WidgetProvider : AppWidgetProvider() {
|
||||
Utils.startVServiceFromToggle(context)
|
||||
}
|
||||
} else if (AppConfig.BROADCAST_ACTION_ACTIVITY == intent.action) {
|
||||
val manager = AppWidgetManager.getInstance(context)
|
||||
when (intent.getIntExtra("key", 0)) {
|
||||
AppConfig.MSG_STATE_RUNNING, AppConfig.MSG_STATE_START_SUCCESS -> {
|
||||
updateWidgetBackground(context, manager, manager.getAppWidgetIds(ComponentName(context, WidgetProvider::class.java)),
|
||||
true)
|
||||
}
|
||||
AppConfig.MSG_STATE_NOT_RUNNING, AppConfig.MSG_STATE_START_FAILURE, AppConfig.MSG_STATE_STOP_SUCCESS -> {
|
||||
updateWidgetBackground(context, manager, manager.getAppWidgetIds(ComponentName(context, WidgetProvider::class.java)),
|
||||
false)
|
||||
AppWidgetManager.getInstance(context)?.let { manager ->
|
||||
when (intent.getIntExtra("key", 0)) {
|
||||
AppConfig.MSG_STATE_RUNNING, AppConfig.MSG_STATE_START_SUCCESS -> {
|
||||
updateWidgetBackground(context, manager, manager.getAppWidgetIds(ComponentName(context, WidgetProvider::class.java)),
|
||||
true)
|
||||
}
|
||||
AppConfig.MSG_STATE_NOT_RUNNING, AppConfig.MSG_STATE_START_FAILURE, AppConfig.MSG_STATE_STOP_SUCCESS -> {
|
||||
updateWidgetBackground(context, manager, manager.getAppWidgetIds(ComponentName(context, WidgetProvider::class.java)),
|
||||
false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import android.os.Bundle
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.text.Editable
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import com.google.gson.Gson
|
||||
@@ -70,45 +69,32 @@ class Server2Activity : BaseActivity() {
|
||||
* save server config
|
||||
*/
|
||||
fun saveServer(): Boolean {
|
||||
var saveSuccess: Boolean
|
||||
val vmess = configs.vmess[edit_index]
|
||||
|
||||
vmess.remarks = et_remarks.text.toString()
|
||||
|
||||
if (TextUtils.isEmpty(vmess.remarks)) {
|
||||
toast(R.string.server_lab_remarks)
|
||||
saveSuccess = false
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
if (AngConfigManager.addCustomServer(vmess, edit_index) == 0) {
|
||||
toast(R.string.toast_success)
|
||||
saveSuccess = true
|
||||
} else {
|
||||
toast(R.string.toast_failure)
|
||||
saveSuccess = false
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
Gson().fromJson<Object>(tv_content.text.toString(), Object::class.java)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
toast(R.string.toast_malformed_josn)
|
||||
saveSuccess = false
|
||||
return false
|
||||
}
|
||||
|
||||
if (saveSuccess) {
|
||||
if (AngConfigManager.addCustomServer(vmess, edit_index) == 0) {
|
||||
//update config
|
||||
defaultDPreference.setPrefString(AppConfig.ANG_CONFIG + edit_guid, tv_content.text.toString())
|
||||
if (edit_index == configs.index) {
|
||||
if (!AngConfigManager.genStoreV2rayConfig(edit_index)) {
|
||||
Log.d(AppConfig.ANG_PACKAGE, "update custom config $edit_index but generate full configuration failed!")
|
||||
}
|
||||
}
|
||||
AngConfigManager.genStoreV2rayConfigIfActive(edit_index)
|
||||
toast(R.string.toast_success)
|
||||
finish()
|
||||
return true
|
||||
} else {
|
||||
toast(R.string.toast_failure)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,6 +112,7 @@ class Server3Activity : BaseActivity() {
|
||||
}
|
||||
|
||||
if (AngConfigManager.addShadowsocksServer(vmess, edit_index) == 0) {
|
||||
AngConfigManager.genStoreV2rayConfigIfActive(edit_index)
|
||||
toast(R.string.toast_success)
|
||||
finish()
|
||||
return true
|
||||
|
||||
@@ -96,6 +96,7 @@ class Server4Activity : BaseActivity() {
|
||||
}
|
||||
|
||||
if (AngConfigManager.addSocksServer(vmess, edit_index) == 0) {
|
||||
AngConfigManager.genStoreV2rayConfigIfActive(edit_index)
|
||||
toast(R.string.toast_success)
|
||||
finish()
|
||||
return true
|
||||
|
||||
@@ -155,6 +155,7 @@ class ServerActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
if (AngConfigManager.addServer(vmess, edit_index) == 0) {
|
||||
AngConfigManager.genStoreV2rayConfigIfActive(edit_index)
|
||||
toast(R.string.toast_success)
|
||||
finish()
|
||||
return true
|
||||
|
||||
@@ -155,7 +155,7 @@ object AngConfigManager {
|
||||
angConfig.index = index
|
||||
app.curIndex = index
|
||||
storeConfigFile()
|
||||
if (!genStoreV2rayConfig(index)) {
|
||||
if (!genStoreV2rayConfig()) {
|
||||
Log.d(AppConfig.ANG_PACKAGE, "set active index $index but generate full configuration failed!")
|
||||
return -1
|
||||
}
|
||||
@@ -179,35 +179,32 @@ object AngConfigManager {
|
||||
}
|
||||
}
|
||||
|
||||
fun genStoreV2rayConfigIfActive(index: Int) {
|
||||
if (index == configs.index) {
|
||||
if (!genStoreV2rayConfig()) {
|
||||
Log.d(AppConfig.ANG_PACKAGE, "update config $index but generate full configuration failed!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gen and store v2ray config file
|
||||
*/
|
||||
fun genStoreV2rayConfig(index: Int): Boolean {
|
||||
fun genStoreV2rayConfig(): Boolean {
|
||||
try {
|
||||
if (angConfig.index < 0
|
||||
|| angConfig.vmess.count() <= 0
|
||||
|| angConfig.index > angConfig.vmess.count() - 1
|
||||
) {
|
||||
return false
|
||||
}
|
||||
var index2 = angConfig.index
|
||||
if (index >= 0) {
|
||||
index2 = index
|
||||
}
|
||||
|
||||
val result = V2rayConfigUtil.getV2rayConfig(app, angConfig.vmess[index2])
|
||||
if (result.status) {
|
||||
app.defaultDPreference.setPrefString(PREF_CURR_CONFIG, result.content)
|
||||
app.defaultDPreference.setPrefString(PREF_CURR_CONFIG_GUID, currConfigGuid())
|
||||
app.defaultDPreference.setPrefString(PREF_CURR_CONFIG_NAME, currConfigName())
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
angConfig.vmess.getOrNull(angConfig.index)?.let {
|
||||
val result = V2rayConfigUtil.getV2rayConfig(app, it)
|
||||
if (result.status) {
|
||||
app.defaultDPreference.setPrefString(PREF_CURR_CONFIG, result.content)
|
||||
app.defaultDPreference.setPrefString(PREF_CURR_CONFIG_GUID, currConfigGuid())
|
||||
app.defaultDPreference.setPrefString(PREF_CURR_CONFIG_NAME, currConfigName())
|
||||
return true
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun currGeneratedV2rayConfig(): String {
|
||||
|
||||
@@ -36,7 +36,7 @@ class SettingsViewModel(application: Application) : AndroidViewModel(application
|
||||
AppConfig.PREF_V2RAY_ROUTING_BLOCKED,
|
||||
AppConfig.PREF_V2RAY_ROUTING_DIRECT -> {
|
||||
GlobalScope.launch {
|
||||
if (!AngConfigManager.genStoreV2rayConfig(AngConfigManager.configs.index)) {
|
||||
if (!AngConfigManager.genStoreV2rayConfig()) {
|
||||
Log.d(AppConfig.ANG_PACKAGE, "$key changed but generate full configuration failed!")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user