Add Wireguard Mtu
This commit is contained in:
1 parent
89b4060ba2
commit
8f62e42ae8
12 files changed
+122
-55
No files matched your search
@@ -62,8 +62,10 @@ object AppConfig {
|
|||||||
const val TAG_DIRECT = "direct"
|
const val TAG_DIRECT = "direct"
|
||||||
const val TAG_BLOCKED = "block"
|
const val TAG_BLOCKED = "block"
|
||||||
|
|
||||||
const val androidpackagenamelistUrl = "https://raw.githubusercontent.com/2dust/androidpackagenamelist/master/proxy.txt"
|
const val androidpackagenamelistUrl =
|
||||||
const val v2rayCustomRoutingListUrl = "https://raw.githubusercontent.com/2dust/v2rayCustomRoutingList/master/"
|
"https://raw.githubusercontent.com/2dust/androidpackagenamelist/master/proxy.txt"
|
||||||
|
const val v2rayCustomRoutingListUrl =
|
||||||
|
"https://raw.githubusercontent.com/2dust/v2rayCustomRoutingList/master/"
|
||||||
const val v2rayNGIssues = "https://github.com/2dust/v2rayNG/issues"
|
const val v2rayNGIssues = "https://github.com/2dust/v2rayNG/issues"
|
||||||
const val v2rayNGWikiMode = "https://github.com/2dust/v2rayNG/wiki/Mode"
|
const val v2rayNGWikiMode = "https://github.com/2dust/v2rayNG/wiki/Mode"
|
||||||
const val v2rayNGPrivacyPolicy = "https://raw.githubusercontent.com/2dust/v2rayNG/master/CR.md"
|
const val v2rayNGPrivacyPolicy = "https://raw.githubusercontent.com/2dust/v2rayNG/master/CR.md"
|
||||||
@@ -76,6 +78,9 @@ object AppConfig {
|
|||||||
const val PORT_LOCAL_DNS = "10853"
|
const val PORT_LOCAL_DNS = "10853"
|
||||||
const val PORT_SOCKS = "10808"
|
const val PORT_SOCKS = "10808"
|
||||||
const val PORT_HTTP = "10809"
|
const val PORT_HTTP = "10809"
|
||||||
|
const val WIREGUARD_LOCAL_ADDRESS_V4 = "172.16.0.2/32"
|
||||||
|
const val WIREGUARD_LOCAL_ADDRESS_V6 = "2606:4700:110:8f81:d551:a0:532e:a2b3/128"
|
||||||
|
const val WIREGUARD_LOCAL_MTU = "1420"
|
||||||
|
|
||||||
const val MSG_REGISTER_CLIENT = 1
|
const val MSG_REGISTER_CLIENT = 1
|
||||||
const val MSG_STATE_RUNNING = 11
|
const val MSG_STATE_RUNNING = 11
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ data class V2rayConfig(
|
|||||||
var secretKey: String? = null,
|
var secretKey: String? = null,
|
||||||
val peers: List<WireGuardBean>? = null,
|
val peers: List<WireGuardBean>? = null,
|
||||||
var reserved: List<Int>? = null,
|
var reserved: List<Int>? = null,
|
||||||
|
var mtu :Int? = null
|
||||||
) {
|
) {
|
||||||
|
|
||||||
data class VnextBean(var address: String = "",
|
data class VnextBean(var address: String = "",
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ import androidx.appcompat.app.AlertDialog
|
|||||||
import com.tencent.mmkv.MMKV
|
import com.tencent.mmkv.MMKV
|
||||||
import com.v2ray.ang.AppConfig
|
import com.v2ray.ang.AppConfig
|
||||||
import com.v2ray.ang.AppConfig.PREF_ALLOW_INSECURE
|
import com.v2ray.ang.AppConfig.PREF_ALLOW_INSECURE
|
||||||
|
import com.v2ray.ang.AppConfig.WIREGUARD_LOCAL_ADDRESS_V4
|
||||||
|
import com.v2ray.ang.AppConfig.WIREGUARD_LOCAL_ADDRESS_V6
|
||||||
|
import com.v2ray.ang.AppConfig.WIREGUARD_LOCAL_MTU
|
||||||
import com.v2ray.ang.R
|
import com.v2ray.ang.R
|
||||||
import com.v2ray.ang.dto.EConfigType
|
import com.v2ray.ang.dto.EConfigType
|
||||||
import com.v2ray.ang.dto.ServerConfig
|
import com.v2ray.ang.dto.ServerConfig
|
||||||
@@ -26,7 +29,12 @@ import com.v2ray.ang.util.Utils.getIpv6Address
|
|||||||
class ServerActivity : BaseActivity() {
|
class ServerActivity : BaseActivity() {
|
||||||
|
|
||||||
private val mainStorage by lazy { MMKV.mmkvWithID(ID_MAIN, MMKV.MULTI_PROCESS_MODE) }
|
private val mainStorage by lazy { MMKV.mmkvWithID(ID_MAIN, MMKV.MULTI_PROCESS_MODE) }
|
||||||
private val settingsStorage by lazy { MMKV.mmkvWithID(MmkvManager.ID_SETTING, MMKV.MULTI_PROCESS_MODE) }
|
private val settingsStorage by lazy {
|
||||||
|
MMKV.mmkvWithID(
|
||||||
|
MmkvManager.ID_SETTING,
|
||||||
|
MMKV.MULTI_PROCESS_MODE
|
||||||
|
)
|
||||||
|
}
|
||||||
private val editGuid by lazy { intent.getStringExtra("guid").orEmpty() }
|
private val editGuid by lazy { intent.getStringExtra("guid").orEmpty() }
|
||||||
private val isRunning by lazy {
|
private val isRunning by lazy {
|
||||||
intent.getBooleanExtra("isRunning", false)
|
intent.getBooleanExtra("isRunning", false)
|
||||||
@@ -34,7 +42,8 @@ class ServerActivity : BaseActivity() {
|
|||||||
&& editGuid == mainStorage?.decodeString(KEY_SELECTED_SERVER)
|
&& editGuid == mainStorage?.decodeString(KEY_SELECTED_SERVER)
|
||||||
}
|
}
|
||||||
private val createConfigType by lazy {
|
private val createConfigType by lazy {
|
||||||
EConfigType.fromInt(intent.getIntExtra("createConfigType", EConfigType.VMESS.value)) ?: EConfigType.VMESS
|
EConfigType.fromInt(intent.getIntExtra("createConfigType", EConfigType.VMESS.value))
|
||||||
|
?: EConfigType.VMESS
|
||||||
}
|
}
|
||||||
private val subscriptionId by lazy {
|
private val subscriptionId by lazy {
|
||||||
intent.getStringExtra("subscriptionId")
|
intent.getStringExtra("subscriptionId")
|
||||||
@@ -73,6 +82,7 @@ class ServerActivity : BaseActivity() {
|
|||||||
private val alpns: Array<out String> by lazy {
|
private val alpns: Array<out String> by lazy {
|
||||||
resources.getStringArray(R.array.streamsecurity_alpn)
|
resources.getStringArray(R.array.streamsecurity_alpn)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kotlin synthetics was used, but since it is removed in 1.8. We switch to old manual approach.
|
// Kotlin synthetics was used, but since it is removed in 1.8. We switch to old manual approach.
|
||||||
// We don't use AndroidViewBinding because, it is better to share similar logics for different
|
// We don't use AndroidViewBinding because, it is better to share similar logics for different
|
||||||
// protocols. Use findViewById manually ensures the xml are de-coupled with the activity logic.
|
// protocols. Use findViewById manually ensures the xml are de-coupled with the activity logic.
|
||||||
@@ -107,8 +117,8 @@ class ServerActivity : BaseActivity() {
|
|||||||
private val et_reserved1: EditText? by lazy { findViewById(R.id.et_reserved1) }
|
private val et_reserved1: EditText? by lazy { findViewById(R.id.et_reserved1) }
|
||||||
private val et_reserved2: EditText? by lazy { findViewById(R.id.et_reserved2) }
|
private val et_reserved2: EditText? by lazy { findViewById(R.id.et_reserved2) }
|
||||||
private val et_reserved3: EditText? by lazy { findViewById(R.id.et_reserved3) }
|
private val et_reserved3: EditText? by lazy { findViewById(R.id.et_reserved3) }
|
||||||
private val et_local_v4_address: EditText? by lazy { findViewById(R.id.et_local_v4_address) }
|
private val et_local_address: EditText? by lazy { findViewById(R.id.et_local_address) }
|
||||||
private val et_local_v6_address: EditText? by lazy { findViewById(R.id.et_local_v6_address) }
|
private val et_local_mtu: EditText? by lazy { findViewById(R.id.et_local_mtu) }
|
||||||
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
@@ -126,10 +136,16 @@ class ServerActivity : BaseActivity() {
|
|||||||
EConfigType.WIREGUARD -> setContentView(R.layout.activity_server_wireguard)
|
EConfigType.WIREGUARD -> setContentView(R.layout.activity_server_wireguard)
|
||||||
}
|
}
|
||||||
sp_network?.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
sp_network?.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
override fun onItemSelected(
|
||||||
|
parent: AdapterView<*>?,
|
||||||
|
view: View?,
|
||||||
|
position: Int,
|
||||||
|
id: Long
|
||||||
|
) {
|
||||||
val types = transportTypes(networks[position])
|
val types = transportTypes(networks[position])
|
||||||
sp_header_type?.isEnabled = types.size > 1
|
sp_header_type?.isEnabled = types.size > 1
|
||||||
val adapter = ArrayAdapter(this@ServerActivity, android.R.layout.simple_spinner_item, types)
|
val adapter =
|
||||||
|
ArrayAdapter(this@ServerActivity, android.R.layout.simple_spinner_item, types)
|
||||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||||
sp_header_type?.adapter = adapter
|
sp_header_type?.adapter = adapter
|
||||||
sp_header_type_title?.text = if (networks[position] == "grpc")
|
sp_header_type_title?.text = if (networks[position] == "grpc")
|
||||||
@@ -141,12 +157,18 @@ class ServerActivity : BaseActivity() {
|
|||||||
et_path?.text = Utils.getEditable(transportDetails[2])
|
et_path?.text = Utils.getEditable(transportDetails[2])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sp_stream_security?.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
sp_stream_security?.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
override fun onItemSelected(
|
||||||
|
parent: AdapterView<*>?,
|
||||||
|
view: View?,
|
||||||
|
position: Int,
|
||||||
|
id: Long
|
||||||
|
) {
|
||||||
if (streamSecuritys[position].isBlank()) {
|
if (streamSecuritys[position].isBlank()) {
|
||||||
container_sni?.visibility = View.GONE
|
container_sni?.visibility = View.GONE
|
||||||
container_fingerprint?.visibility = View.GONE
|
container_fingerprint?.visibility = View.GONE
|
||||||
@@ -173,6 +195,7 @@ class ServerActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNothingSelected(p0: AdapterView<*>?) {
|
override fun onNothingSelected(p0: AdapterView<*>?) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
@@ -192,39 +215,55 @@ class ServerActivity : BaseActivity() {
|
|||||||
|
|
||||||
et_remarks.text = Utils.getEditable(config.remarks)
|
et_remarks.text = Utils.getEditable(config.remarks)
|
||||||
et_address.text = Utils.getEditable(outbound.getServerAddress().orEmpty())
|
et_address.text = Utils.getEditable(outbound.getServerAddress().orEmpty())
|
||||||
et_port.text = Utils.getEditable(outbound.getServerPort()?.toString() ?: DEFAULT_PORT.toString())
|
et_port.text =
|
||||||
|
Utils.getEditable(outbound.getServerPort()?.toString() ?: DEFAULT_PORT.toString())
|
||||||
et_id.text = Utils.getEditable(outbound.getPassword().orEmpty())
|
et_id.text = Utils.getEditable(outbound.getPassword().orEmpty())
|
||||||
et_alterId?.text = Utils.getEditable(outbound.settings?.vnext?.get(0)?.users?.get(0)?.alterId.toString())
|
et_alterId?.text =
|
||||||
|
Utils.getEditable(outbound.settings?.vnext?.get(0)?.users?.get(0)?.alterId.toString())
|
||||||
if (config.configType == EConfigType.SOCKS) {
|
if (config.configType == EConfigType.SOCKS) {
|
||||||
et_security?.text = Utils.getEditable(outbound.settings?.servers?.get(0)?.users?.get(0)?.user.orEmpty())
|
et_security?.text =
|
||||||
|
Utils.getEditable(outbound.settings?.servers?.get(0)?.users?.get(0)?.user.orEmpty())
|
||||||
} else if (config.configType == EConfigType.VLESS) {
|
} else if (config.configType == EConfigType.VLESS) {
|
||||||
et_security?.text = Utils.getEditable(outbound.getSecurityEncryption().orEmpty())
|
et_security?.text = Utils.getEditable(outbound.getSecurityEncryption().orEmpty())
|
||||||
val flow = Utils.arrayFind(flows, outbound.settings?.vnext?.get(0)?.users?.get(0)?.flow.orEmpty())
|
val flow = Utils.arrayFind(
|
||||||
|
flows,
|
||||||
|
outbound.settings?.vnext?.get(0)?.users?.get(0)?.flow.orEmpty()
|
||||||
|
)
|
||||||
if (flow >= 0) {
|
if (flow >= 0) {
|
||||||
sp_flow?.setSelection(flow)
|
sp_flow?.setSelection(flow)
|
||||||
}
|
}
|
||||||
} else if (config.configType == EConfigType.WIREGUARD) {
|
} else if (config.configType == EConfigType.WIREGUARD) {
|
||||||
et_public_key?.text = Utils.getEditable(outbound.settings?.peers?.get(0)?.publicKey.orEmpty())
|
et_public_key?.text =
|
||||||
|
Utils.getEditable(outbound.settings?.peers?.get(0)?.publicKey.orEmpty())
|
||||||
if (outbound.settings?.reserved == null) {
|
if (outbound.settings?.reserved == null) {
|
||||||
et_reserved1?.text = Utils.getEditable("0")
|
et_reserved1?.text = Utils.getEditable("0")
|
||||||
et_reserved2?.text = Utils.getEditable("0")
|
et_reserved2?.text = Utils.getEditable("0")
|
||||||
et_reserved3?.text = Utils.getEditable("0")
|
et_reserved3?.text = Utils.getEditable("0")
|
||||||
} else {
|
} else {
|
||||||
et_reserved1?.text = Utils.getEditable(outbound.settings?.reserved?.get(0).toString())
|
et_reserved1?.text =
|
||||||
et_reserved2?.text = Utils.getEditable(outbound.settings?.reserved?.get(1).toString())
|
Utils.getEditable(outbound.settings?.reserved?.get(0).toString())
|
||||||
et_reserved3?.text = Utils.getEditable(outbound.settings?.reserved?.get(2).toString())
|
et_reserved2?.text =
|
||||||
|
Utils.getEditable(outbound.settings?.reserved?.get(1).toString())
|
||||||
|
et_reserved3?.text =
|
||||||
|
Utils.getEditable(outbound.settings?.reserved?.get(2).toString())
|
||||||
}
|
}
|
||||||
if (outbound.settings?.address == null) {
|
if (outbound.settings?.address == null) {
|
||||||
et_local_v4_address?.text = Utils.getEditable("172.16.0.2/32")
|
et_local_address?.text =
|
||||||
et_local_v6_address?.text = Utils.getEditable("2606:4700:110:8f81:d551:a0:532e:a2b3/128")
|
Utils.getEditable("${WIREGUARD_LOCAL_ADDRESS_V4},${WIREGUARD_LOCAL_ADDRESS_V6}")
|
||||||
} else {
|
} else {
|
||||||
val list = outbound.settings?.address as List<*>
|
val list = outbound.settings?.address as List<*>
|
||||||
et_local_v4_address?.text = Utils.getEditable(list.get(0).toString())
|
et_local_address?.text = Utils.getEditable(list.joinToString())
|
||||||
et_local_v6_address?.text = Utils.getEditable(list.get(1).toString())
|
}
|
||||||
|
if (outbound.settings?.mtu == null) {
|
||||||
|
et_local_mtu?.text = Utils.getEditable(WIREGUARD_LOCAL_MTU)
|
||||||
|
} else {
|
||||||
|
et_local_mtu?.text = Utils.getEditable(outbound.settings?.mtu.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val securityEncryptions = if (config.configType == EConfigType.SHADOWSOCKS) shadowsocksSecuritys else securitys
|
val securityEncryptions =
|
||||||
val security = Utils.arrayFind(securityEncryptions, outbound.getSecurityEncryption().orEmpty())
|
if (config.configType == EConfigType.SHADOWSOCKS) shadowsocksSecuritys else securitys
|
||||||
|
val security =
|
||||||
|
Utils.arrayFind(securityEncryptions, outbound.getSecurityEncryption().orEmpty())
|
||||||
if (security >= 0) {
|
if (security >= 0) {
|
||||||
sp_security?.setSelection(security)
|
sp_security?.setSelection(security)
|
||||||
}
|
}
|
||||||
@@ -243,12 +282,16 @@ class ServerActivity : BaseActivity() {
|
|||||||
sp_stream_fingerprint?.setSelection(utlsIndex)
|
sp_stream_fingerprint?.setSelection(utlsIndex)
|
||||||
}
|
}
|
||||||
tlsSetting.alpn?.let {
|
tlsSetting.alpn?.let {
|
||||||
val alpnIndex = Utils.arrayFind(alpns, Utils.removeWhiteSpace(tlsSetting.alpn.joinToString())!!)
|
val alpnIndex = Utils.arrayFind(
|
||||||
|
alpns,
|
||||||
|
Utils.removeWhiteSpace(tlsSetting.alpn.joinToString())!!
|
||||||
|
)
|
||||||
sp_stream_alpn?.setSelection(alpnIndex)
|
sp_stream_alpn?.setSelection(alpnIndex)
|
||||||
}
|
}
|
||||||
if (streamSetting.tlsSettings != null) {
|
if (streamSetting.tlsSettings != null) {
|
||||||
container_allow_insecure?.visibility = View.VISIBLE
|
container_allow_insecure?.visibility = View.VISIBLE
|
||||||
val allowinsecure = Utils.arrayFind(allowinsecures, tlsSetting.allowInsecure.toString())
|
val allowinsecure =
|
||||||
|
Utils.arrayFind(allowinsecures, tlsSetting.allowInsecure.toString())
|
||||||
if (allowinsecure >= 0) {
|
if (allowinsecure >= 0) {
|
||||||
sp_allow_insecure?.setSelection(allowinsecure)
|
sp_allow_insecure?.setSelection(allowinsecure)
|
||||||
}
|
}
|
||||||
@@ -307,8 +350,9 @@ class ServerActivity : BaseActivity() {
|
|||||||
et_reserved1?.text = Utils.getEditable("0")
|
et_reserved1?.text = Utils.getEditable("0")
|
||||||
et_reserved2?.text = Utils.getEditable("0")
|
et_reserved2?.text = Utils.getEditable("0")
|
||||||
et_reserved3?.text = Utils.getEditable("0")
|
et_reserved3?.text = Utils.getEditable("0")
|
||||||
et_local_v4_address?.text = Utils.getEditable("172.16.0.2/32")
|
et_local_address?.text =
|
||||||
et_local_v6_address?.text = Utils.getEditable("2606:4700:110:8f81:d551:a0:532e:a2b3/128")
|
Utils.getEditable("${WIREGUARD_LOCAL_ADDRESS_V4},${WIREGUARD_LOCAL_ADDRESS_V6}")
|
||||||
|
et_local_mtu?.text = Utils.getEditable(WIREGUARD_LOCAL_MTU)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,7 +373,8 @@ class ServerActivity : BaseActivity() {
|
|||||||
toast(R.string.server_lab_port)
|
toast(R.string.server_lab_port)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
val config = MmkvManager.decodeServerConfig(editGuid) ?: ServerConfig.create(createConfigType)
|
val config =
|
||||||
|
MmkvManager.decodeServerConfig(editGuid) ?: ServerConfig.create(createConfigType)
|
||||||
if (config.configType != EConfigType.SOCKS && TextUtils.isEmpty(et_id.text.toString())) {
|
if (config.configType != EConfigType.SOCKS && TextUtils.isEmpty(et_id.text.toString())) {
|
||||||
if (config.configType == EConfigType.TROJAN || config.configType == EConfigType.SHADOWSOCKS) {
|
if (config.configType == EConfigType.TROJAN || config.configType == EConfigType.SHADOWSOCKS) {
|
||||||
toast(R.string.server_lab_id3)
|
toast(R.string.server_lab_id3)
|
||||||
@@ -376,7 +421,11 @@ class ServerActivity : BaseActivity() {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun saveVnext(vnext: V2rayConfig.OutboundBean.OutSettingsBean.VnextBean, port: Int, config: ServerConfig) {
|
private fun saveVnext(
|
||||||
|
vnext: V2rayConfig.OutboundBean.OutSettingsBean.VnextBean,
|
||||||
|
port: Int,
|
||||||
|
config: ServerConfig
|
||||||
|
) {
|
||||||
vnext.address = et_address.text.toString().trim()
|
vnext.address = et_address.text.toString().trim()
|
||||||
vnext.port = port
|
vnext.port = port
|
||||||
vnext.users[0].id = et_id.text.toString().trim()
|
vnext.users[0].id = et_id.text.toString().trim()
|
||||||
@@ -389,7 +438,11 @@ class ServerActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun saveServers(server: V2rayConfig.OutboundBean.OutSettingsBean.ServersBean, port: Int, config: ServerConfig) {
|
private fun saveServers(
|
||||||
|
server: V2rayConfig.OutboundBean.OutSettingsBean.ServersBean,
|
||||||
|
port: Int,
|
||||||
|
config: ServerConfig
|
||||||
|
) {
|
||||||
server.address = et_address.text.toString().trim()
|
server.address = et_address.text.toString().trim()
|
||||||
server.port = port
|
server.port = port
|
||||||
if (config.configType == EConfigType.SHADOWSOCKS) {
|
if (config.configType == EConfigType.SHADOWSOCKS) {
|
||||||
@@ -399,7 +452,8 @@ class ServerActivity : BaseActivity() {
|
|||||||
if (TextUtils.isEmpty(et_security?.text) && TextUtils.isEmpty(et_id.text)) {
|
if (TextUtils.isEmpty(et_security?.text) && TextUtils.isEmpty(et_id.text)) {
|
||||||
server.users = null
|
server.users = null
|
||||||
} else {
|
} else {
|
||||||
val socksUsersBean = V2rayConfig.OutboundBean.OutSettingsBean.ServersBean.SocksUsersBean()
|
val socksUsersBean =
|
||||||
|
V2rayConfig.OutboundBean.OutSettingsBean.ServersBean.SocksUsersBean()
|
||||||
socksUsersBean.user = et_security?.text.toString().trim()
|
socksUsersBean.user = et_security?.text.toString().trim()
|
||||||
socksUsersBean.pass = et_id.text.toString().trim()
|
socksUsersBean.pass = et_id.text.toString().trim()
|
||||||
server.users = listOf(socksUsersBean)
|
server.users = listOf(socksUsersBean)
|
||||||
@@ -412,7 +466,8 @@ class ServerActivity : BaseActivity() {
|
|||||||
private fun savePeer(wireguard: V2rayConfig.OutboundBean.OutSettingsBean, port: Int) {
|
private fun savePeer(wireguard: V2rayConfig.OutboundBean.OutSettingsBean, port: Int) {
|
||||||
wireguard.secretKey = et_id.text.toString().trim()
|
wireguard.secretKey = et_id.text.toString().trim()
|
||||||
wireguard.peers?.get(0)?.publicKey = et_public_key?.text.toString().trim()
|
wireguard.peers?.get(0)?.publicKey = et_public_key?.text.toString().trim()
|
||||||
wireguard.peers?.get(0)?.endpoint = getIpv6Address(et_address.text.toString().trim()) + ":" + port
|
wireguard.peers?.get(0)?.endpoint =
|
||||||
|
getIpv6Address(et_address.text.toString().trim()) + ":" + port
|
||||||
val reserved1 = Utils.parseInt(et_reserved1?.text.toString())
|
val reserved1 = Utils.parseInt(et_reserved1?.text.toString())
|
||||||
val reserved2 = Utils.parseInt(et_reserved2?.text.toString())
|
val reserved2 = Utils.parseInt(et_reserved2?.text.toString())
|
||||||
val reserved3 = Utils.parseInt(et_reserved3?.text.toString())
|
val reserved3 = Utils.parseInt(et_reserved3?.text.toString())
|
||||||
@@ -421,8 +476,8 @@ class ServerActivity : BaseActivity() {
|
|||||||
} else {
|
} else {
|
||||||
wireguard.reserved = null
|
wireguard.reserved = null
|
||||||
}
|
}
|
||||||
wireguard.address = listOf(et_local_v4_address?.text.toString().trim(),
|
wireguard.address = listOf(et_local_address?.text.toString().trim())
|
||||||
et_local_v6_address?.text.toString().trim())
|
wireguard.mtu = Utils.parseInt(et_local_mtu?.text.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun saveStreamSettings(streamSetting: V2rayConfig.OutboundBean.StreamSettingsBean) {
|
private fun saveStreamSettings(streamSetting: V2rayConfig.OutboundBean.StreamSettingsBean) {
|
||||||
@@ -476,12 +531,15 @@ class ServerActivity : BaseActivity() {
|
|||||||
"tcp" -> {
|
"tcp" -> {
|
||||||
tcpTypes
|
tcpTypes
|
||||||
}
|
}
|
||||||
|
|
||||||
"kcp", "quic" -> {
|
"kcp", "quic" -> {
|
||||||
kcpAndQuicTypes
|
kcpAndQuicTypes
|
||||||
}
|
}
|
||||||
|
|
||||||
"grpc" -> {
|
"grpc" -> {
|
||||||
grpcModes
|
grpcModes
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
arrayOf("---")
|
arrayOf("---")
|
||||||
}
|
}
|
||||||
@@ -532,10 +590,12 @@ class ServerActivity : BaseActivity() {
|
|||||||
deleteServer()
|
deleteServer()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.save_config -> {
|
R.id.save_config -> {
|
||||||
saveServer()
|
saveServer()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> super.onOptionsItemSelected(item)
|
else -> super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,8 @@ import com.google.gson.*
|
|||||||
import com.tencent.mmkv.MMKV
|
import com.tencent.mmkv.MMKV
|
||||||
import com.v2ray.ang.AppConfig
|
import com.v2ray.ang.AppConfig
|
||||||
import com.v2ray.ang.AppConfig.ANG_PACKAGE
|
import com.v2ray.ang.AppConfig.ANG_PACKAGE
|
||||||
|
import com.v2ray.ang.AppConfig.WIREGUARD_LOCAL_ADDRESS_V4
|
||||||
|
import com.v2ray.ang.AppConfig.WIREGUARD_LOCAL_ADDRESS_V6
|
||||||
import com.v2ray.ang.dto.V2rayConfig
|
import com.v2ray.ang.dto.V2rayConfig
|
||||||
import com.v2ray.ang.dto.EConfigType
|
import com.v2ray.ang.dto.EConfigType
|
||||||
import com.v2ray.ang.dto.ERoutingMode
|
import com.v2ray.ang.dto.ERoutingMode
|
||||||
@@ -428,7 +430,7 @@ object V2rayConfigUtil {
|
|||||||
|
|
||||||
if (protocol.equals(EConfigType.WIREGUARD.name, true)) {
|
if (protocol.equals(EConfigType.WIREGUARD.name, true)) {
|
||||||
var localTunAddr = if (outbound.settings?.address == null) {
|
var localTunAddr = if (outbound.settings?.address == null) {
|
||||||
listOf("172.16.0.2/32", "2606:4700:110:8f81:d551:a0:532e:a2b3/128")
|
listOf(WIREGUARD_LOCAL_ADDRESS_V4, WIREGUARD_LOCAL_ADDRESS_V6)
|
||||||
} else {
|
} else {
|
||||||
outbound.settings?.address as List<*>
|
outbound.settings?.address as List<*>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,14 +160,13 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/server_lab_local_v4_address" />
|
android:text="@string/server_lab_local_address" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/et_local_v4_address"
|
android:id="@+id/et_local_address"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/edit_height"
|
android:layout_height="@dimen/edit_height"
|
||||||
android:inputType="text" />
|
android:inputType="text" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@@ -179,13 +178,13 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/server_lab_local_v6_address" />
|
android:text="@string/server_lab_local_mtu" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/et_local_v6_address"
|
android:id="@+id/et_local_mtu"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/edit_height"
|
android:layout_height="@dimen/edit_height"
|
||||||
android:inputType="text" />
|
android:inputType="number" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -64,8 +64,8 @@
|
|||||||
<string name="server_lab_short_id" translatable="false">ShortId</string>
|
<string name="server_lab_short_id" translatable="false">ShortId</string>
|
||||||
<string name="server_lab_spider_x" translatable="false">SpiderX</string>
|
<string name="server_lab_spider_x" translatable="false">SpiderX</string>
|
||||||
<string name="server_lab_reserved">Reserved (اختياري)</string>
|
<string name="server_lab_reserved">Reserved (اختياري)</string>
|
||||||
<string name="server_lab_local_v4_address">العنوان المحلي IPv4(اختياري)</string>
|
<string name="server_lab_local_address">العنوان المحلي IPv4(اختياري)</string>
|
||||||
<string name="server_lab_local_v6_address">العنوان المحلي IPv6(اختياري, يستخدم فقط عندما تفضل IPv6)</string>
|
<string name="server_lab_local_mtu">Mtu(optional, default 1420)</string>
|
||||||
<string name="toast_success">نجاح</string>
|
<string name="toast_success">نجاح</string>
|
||||||
<string name="toast_failure">فشل</string>
|
<string name="toast_failure">فشل</string>
|
||||||
<string name="toast_none_data">لا يوجد شيء</string>
|
<string name="toast_none_data">لا يوجد شيء</string>
|
||||||
|
|||||||
@@ -61,8 +61,8 @@
|
|||||||
<string name="server_lab_encryption">رمزگذاری</string>
|
<string name="server_lab_encryption">رمزگذاری</string>
|
||||||
<string name="server_lab_flow">جریان</string>
|
<string name="server_lab_flow">جریان</string>
|
||||||
<string name="server_lab_reserved">Reserved (اختیاری)</string>
|
<string name="server_lab_reserved">Reserved (اختیاری)</string>
|
||||||
<string name="server_lab_local_v4_address">آدرس محلی IPv4(اختیاری)</string>
|
<string name="server_lab_local_address">آدرس محلی IPv4(اختیاری)</string>
|
||||||
<string name="server_lab_local_v6_address">آدرس محلی IPv6(اختیاری, فقط زمانی استفاده می شود که IPv6 را ترجیح می دهد)</string>
|
<string name="server_lab_local_mtu">Mtu(optional, default 1420)</string>
|
||||||
<string name="toast_success">موفقیت</string>
|
<string name="toast_success">موفقیت</string>
|
||||||
<string name="toast_failure">شکست</string>
|
<string name="toast_failure">شکست</string>
|
||||||
<string name="toast_none_data">چیزی نیست</string>
|
<string name="toast_none_data">چیزی نیست</string>
|
||||||
|
|||||||
@@ -66,8 +66,8 @@
|
|||||||
<string name="server_lab_short_id" translatable="false">ShortId</string>
|
<string name="server_lab_short_id" translatable="false">ShortId</string>
|
||||||
<string name="server_lab_spider_x" translatable="false">SpiderX</string>
|
<string name="server_lab_spider_x" translatable="false">SpiderX</string>
|
||||||
<string name="server_lab_reserved">Reserved (необязательно)</string>
|
<string name="server_lab_reserved">Reserved (необязательно)</string>
|
||||||
<string name="server_lab_local_v4_address">Локальный адрес IPv4 (необязательно)</string>
|
<string name="server_lab_local_address">Локальный адрес IPv4 (необязательно)</string>
|
||||||
<string name="server_lab_local_v6_address">Локальный адрес IPv6 (необязательно, используется только если предпочитаете IPv6)</string>
|
<string name="server_lab_local_mtu">Mtu(optional, default 1420)</string>
|
||||||
<string name="toast_success">Успешно</string>
|
<string name="toast_success">Успешно</string>
|
||||||
<string name="toast_failure">Ошибка</string>
|
<string name="toast_failure">Ошибка</string>
|
||||||
<string name="toast_none_data">Ничего нет</string>
|
<string name="toast_none_data">Ничего нет</string>
|
||||||
|
|||||||
@@ -60,8 +60,8 @@
|
|||||||
<string name="server_lab_encryption">Mã hóa</string>
|
<string name="server_lab_encryption">Mã hóa</string>
|
||||||
<string name="server_lab_flow">Kiểm soát lưu lượng (flow)</string>
|
<string name="server_lab_flow">Kiểm soát lưu lượng (flow)</string>
|
||||||
<string name="server_lab_reserved">Reserved (không bắt buộc)</string>
|
<string name="server_lab_reserved">Reserved (không bắt buộc)</string>
|
||||||
<string name="server_lab_local_v4_address">Địa chỉ cục bộ IPv4(không bắt buộc)</string>
|
<string name="server_lab_local_address">Địa chỉ cục bộ IPv4(không bắt buộc)</string>
|
||||||
<string name="server_lab_local_v6_address">Địa chỉ cục bộ IPv6 (không bắt buộc, chỉ sử dụng khi ưu tiên IPv6)</string>
|
<string name="server_lab_local_mtu">Mtu(optional, default 1420)</string>
|
||||||
<string name="toast_success">Thành công!</string>
|
<string name="toast_success">Thành công!</string>
|
||||||
<string name="toast_failure">Đã xảy ra lỗi, vui lòng thử lại!</string>
|
<string name="toast_failure">Đã xảy ra lỗi, vui lòng thử lại!</string>
|
||||||
<string name="toast_none_data">Không có gì ở đây</string>
|
<string name="toast_none_data">Không có gì ở đây</string>
|
||||||
|
|||||||
@@ -60,8 +60,8 @@
|
|||||||
<string name="server_lab_encryption">加密方式(encryption)</string>
|
<string name="server_lab_encryption">加密方式(encryption)</string>
|
||||||
<string name="server_lab_flow">流控(flow)</string>
|
<string name="server_lab_flow">流控(flow)</string>
|
||||||
<string name="server_lab_reserved">Reserved(可选)</string>
|
<string name="server_lab_reserved">Reserved(可选)</string>
|
||||||
<string name="server_lab_local_v4_address">本地 IPv4 地址(可选)</string>
|
<string name="server_lab_local_address">本地地址(可选IPv4/IPv6,逗号隔开)</string>
|
||||||
<string name="server_lab_local_v6_address">本地 IPv6 地址(可选, 仅 IPv6 优先时使用)</string>
|
<string name="server_lab_local_mtu">Mtu(可选, 默认1420)</string>
|
||||||
<string name="toast_success">成功</string>
|
<string name="toast_success">成功</string>
|
||||||
<string name="toast_failure">失败</string>
|
<string name="toast_failure">失败</string>
|
||||||
<string name="toast_none_data">没有数据</string>
|
<string name="toast_none_data">没有数据</string>
|
||||||
|
|||||||
@@ -60,8 +60,8 @@
|
|||||||
<string name="server_lab_encryption">加密 (encryption)</string>
|
<string name="server_lab_encryption">加密 (encryption)</string>
|
||||||
<string name="server_lab_flow">流程 (flow)</string>
|
<string name="server_lab_flow">流程 (flow)</string>
|
||||||
<string name="server_lab_reserved">Reserved (可選)</string>
|
<string name="server_lab_reserved">Reserved (可選)</string>
|
||||||
<string name="server_lab_local_v4_address">本機 IPv4 位址(可選)</string>
|
<string name="server_lab_local_address">本機位址(可選IPv4/IPv6,逗號隔開)</string>
|
||||||
<string name="server_lab_local_v6_address">本機 IPv6 位址(可選, 僅偏好 IPv6 時使用)</string>
|
<string name="server_lab_local_mtu">Mtu(可選, 預設1420)</string>
|
||||||
<string name="toast_success">成功</string>
|
<string name="toast_success">成功</string>
|
||||||
<string name="toast_failure">失敗</string>
|
<string name="toast_failure">失敗</string>
|
||||||
<string name="toast_none_data">無資料</string>
|
<string name="toast_none_data">無資料</string>
|
||||||
|
|||||||
@@ -67,8 +67,8 @@
|
|||||||
<string name="server_lab_spider_x" translatable="false">SpiderX</string>
|
<string name="server_lab_spider_x" translatable="false">SpiderX</string>
|
||||||
<string name="server_lab_secret_key" translatable="false">SecretKey</string>
|
<string name="server_lab_secret_key" translatable="false">SecretKey</string>
|
||||||
<string name="server_lab_reserved">Reserved(Optional)</string>
|
<string name="server_lab_reserved">Reserved(Optional)</string>
|
||||||
<string name="server_lab_local_v4_address">local address IPv4(Optional)</string>
|
<string name="server_lab_local_address">Local address (optional IPv4/IPv6, separated by commas)</string>
|
||||||
<string name="server_lab_local_v6_address">local address IPv6(Optional, only used when prefer IPv6)</string>
|
<string name="server_lab_local_mtu">Mtu(optional, default 1420)</string>
|
||||||
<string name="toast_success">Success</string>
|
<string name="toast_success">Success</string>
|
||||||
<string name="toast_failure">Failure</string>
|
<string name="toast_failure">Failure</string>
|
||||||
<string name="toast_none_data">There is nothing</string>
|
<string name="toast_none_data">There is nothing</string>
|
||||||
|
|||||||
Reference in new issue
Block a user