Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Add HTTP protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust authored and AnGgIt86 committed Sep 26, 2024
1 parent f70cdcb commit e196f8b
Show file tree
Hide file tree
Showing 20 changed files with 56 additions and 20 deletions.
1 change: 1 addition & 0 deletions app/src/main/kotlin/com/neko/v2ray/AppConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ object AppConfig {
const val CUSTOM = ""
const val SHADOWSOCKS = "ss://"
const val SOCKS = "socks://"
const val HTTP = "http://"
const val VLESS = "vless://"
const val TROJAN = "trojan://"
const val WIREGUARD = "wireguard://"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/kotlin/com/neko/v2ray/dto/EConfigType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ enum class EConfigType(val value: Int, val protocolScheme: String) {
SOCKS(4, AppConfig.SOCKS),
VLESS(5, AppConfig.VLESS),
TROJAN(6, AppConfig.TROJAN),
WIREGUARD(7, AppConfig.WIREGUARD);
WIREGUARD(7, AppConfig.WIREGUARD),
HTTP(10, AppConfig.HTTP);

companion object {
fun fromInt(value: Int) = values().firstOrNull { it.value == value }
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/kotlin/com/neko/v2ray/dto/ServerConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ data class ServerConfig(
EConfigType.CUSTOM ->
return ServerConfig(configType = configType)

EConfigType.SHADOWSOCKS, EConfigType.SOCKS, EConfigType.TROJAN ->
EConfigType.SHADOWSOCKS,
EConfigType.SOCKS,
EConfigType.HTTP,
EConfigType.TROJAN ->
return ServerConfig(
configType = configType,
outboundBean = V2rayConfig.OutboundBean(
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/kotlin/com/neko/v2ray/dto/V2rayConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ data class V2rayConfig(

data class ServersBean(
var address: String = "",
var method: String = "chacha20-poly1305",
var method: String? = null,
var ota: Boolean = false,
var password: String = "",
var password: String? = null,
var port: Int = DEFAULT_PORT,
var level: Int = DEFAULT_LEVEL,
val email: String? = null,
Expand Down Expand Up @@ -425,6 +425,7 @@ data class V2rayConfig(
return settings?.vnext?.get(0)?.address
} else if (protocol.equals(EConfigType.SHADOWSOCKS.name, true)
|| protocol.equals(EConfigType.SOCKS.name, true)
|| protocol.equals(EConfigType.HTTP.name, true)
|| protocol.equals(EConfigType.TROJAN.name, true)
) {
return settings?.servers?.get(0)?.address
Expand All @@ -441,6 +442,7 @@ data class V2rayConfig(
return settings?.vnext?.get(0)?.port
} else if (protocol.equals(EConfigType.SHADOWSOCKS.name, true)
|| protocol.equals(EConfigType.SOCKS.name, true)
|| protocol.equals(EConfigType.HTTP.name, true)
|| protocol.equals(EConfigType.TROJAN.name, true)
) {
return settings?.servers?.get(0)?.port
Expand All @@ -465,7 +467,8 @@ data class V2rayConfig(
|| protocol.equals(EConfigType.TROJAN.name, true)
) {
return settings?.servers?.get(0)?.password
} else if (protocol.equals(EConfigType.SOCKS.name, true)) {
} else if (protocol.equals(EConfigType.SOCKS.name, true)
|| protocol.equals(EConfigType.HTTP.name, true)) {
return settings?.servers?.get(0)?.users?.get(0)?.pass
} else if (protocol.equals(EConfigType.WIREGUARD.name, true)) {
return settings?.secretKey
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/kotlin/com/neko/v2ray/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,11 @@ class MainActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedList
true
}

R.id.import_manually_http -> {
importManually(EConfigType.HTTP.value)
true
}

R.id.import_manually_trojan -> {
importManually(EConfigType.TROJAN.value)
true
Expand Down
12 changes: 9 additions & 3 deletions app/src/main/kotlin/com/neko/v2ray/ui/ServerActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class ServerActivity : BaseActivity() {
EConfigType.CUSTOM -> return
EConfigType.SHADOWSOCKS -> setContentView(R.layout.activity_server_shadowsocks)
EConfigType.SOCKS -> setContentView(R.layout.activity_server_socks)
EConfigType.HTTP -> setContentView(R.layout.activity_server_socks)
EConfigType.VLESS -> setContentView(R.layout.activity_server_vless)
EConfigType.TROJAN -> setContentView(R.layout.activity_server_trojan)
EConfigType.WIREGUARD -> setContentView(R.layout.activity_server_wireguard)
Expand Down Expand Up @@ -305,7 +306,9 @@ class ServerActivity : BaseActivity() {
et_id.text = Utils.getEditable(outbound.getPassword().orEmpty())
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
|| config.configType == EConfigType.HTTP
) {
et_security?.text =
Utils.getEditable(outbound.settings?.servers?.get(0)?.users?.get(0)?.user.orEmpty())
} else if (config.configType == EConfigType.VLESS) {
Expand Down Expand Up @@ -460,7 +463,10 @@ class ServerActivity : BaseActivity() {
}
val config =
MmkvManager.decodeServerConfig(editGuid) ?: ServerConfig.create(createConfigType)
if (config.configType != EConfigType.SOCKS && TextUtils.isEmpty(et_id.text.toString())) {
if (config.configType != EConfigType.SOCKS
&& config.configType != EConfigType.HTTP
&& TextUtils.isEmpty(et_id.text.toString())
) {
if (config.configType == EConfigType.TROJAN || config.configType == EConfigType.SHADOWSOCKS) {
toast(R.string.server_lab_id3)
} else {
Expand Down Expand Up @@ -533,7 +539,7 @@ class ServerActivity : BaseActivity() {
if (config.configType == EConfigType.SHADOWSOCKS) {
server.password = et_id.text.toString().trim()
server.method = shadowsocksSecuritys[sp_security?.selectedItemPosition ?: 0]
} else if (config.configType == EConfigType.SOCKS) {
} else if (config.configType == EConfigType.SOCKS || config.configType == EConfigType.HTTP) {
if (TextUtils.isEmpty(et_security?.text) && TextUtils.isEmpty(et_id.text)) {
server.users = null
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ object AngConfigManager {
EConfigType.CUSTOM -> ""
EConfigType.SHADOWSOCKS -> ShadowsocksFmt.toUri(config)
EConfigType.SOCKS -> SocksFmt.toUri(config)
EConfigType.HTTP -> ""
EConfigType.VLESS -> VlessFmt.toUri(config)
EConfigType.TROJAN -> TrojanFmt.toUri(config)
EConfigType.WIREGUARD -> WireguardFmt.toUri(config)
Expand Down
1 change: 1 addition & 0 deletions app/src/main/kotlin/com/neko/v2ray/util/V2rayConfigUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ object V2rayConfigUtil {
val protocol = outbound.protocol
if (protocol.equals(EConfigType.SHADOWSOCKS.name, true)
|| protocol.equals(EConfigType.SOCKS.name, true)
|| protocol.equals(EConfigType.HTTP.name, true)
|| protocol.equals(EConfigType.TROJAN.name, true)
|| protocol.equals(EConfigType.WIREGUARD.name, true)
) {
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/menu/menu_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
android:id="@+id/import_manually_socks"
android:title="@string/menu_item_import_config_manually_socks"
app:showAsAction="never" />
<item
android:id="@+id/import_manually_http"
android:title="@string/menu_item_import_config_manually_http"
app:showAsAction="never" />
<item
android:id="@+id/import_manually_trojan"
android:title="@string/menu_item_import_config_manually_trojan"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
<string name="menu_item_import_config_manually_vless">اكتب يدويًا[VLESS]</string>
<string name="menu_item_import_config_manually_ss">اكتب يدويًا[Shadowsocks]</string>
<string name="menu_item_import_config_manually_socks">اكتب يدويًا[الجوارب]</string>
<string name="menu_item_import_config_manually_trojan">اكتب يدويًا[حصان طروادة]</string>
<string name="menu_item_import_config_manually_http">اكتب يدويًا[HTTP]</string>/
<string name="menu_item_import_config_manually_trojan">اكتب يدويًا[Trojan]</string>
<string name="menu_item_import_config_manually_wireguard">اكتب يدويًا[Wireguard]</string>
<string name="menu_item_import_config_custom">التكوين المخصص</string>
<string name="menu_item_import_config_custom_clipboard">استيراد التكوين المخصص من الحافظة</string>
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-fa/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
<string name="menu_item_import_config_manually_vmess">به صورت دستی تایپ کنید[Vmess]</string>
<string name="menu_item_import_config_manually_vless">به صورت دستی تایپ کنید[VLESS]</string>
<string name="menu_item_import_config_manually_ss">تایپ دستی [Shadowsocks]</string>
<string name="menu_item_import_config_manually_socks">تایپ دستی [جوراب]</string>
<string name="menu_item_import_config_manually_socks">تایپ دستی [Socks]</string>
<string name="menu_item_import_config_manually_http">به صورت دستی تایپ کنید[HTTP]</string>
<string name="menu_item_import_config_manually_trojan">به صورت دستی تایپ کنید[Trojan]</string>
<string name="menu_item_import_config_manually_wireguard">به صورت دستی تایپ کنید[Wireguard]</string>
<string name="menu_item_import_config_custom">پیکربندی سفارشی</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-in/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<string name="menu_item_import_config_manually_vless">Ketik secara manual[VLESS]</string>
<string name="menu_item_import_config_manually_ss">Ketik secara manual[Shadowsocks]</string>
<string name="menu_item_import_config_manually_socks">Ketik secara manual[Socks]</string>
<string name="menu_item_import_config_manually_http">Ketik secara manual[HTTP]</string>
<string name="menu_item_import_config_manually_trojan">Ketik secara manual[Trojan]</string>
<string name="menu_item_import_config_manually_wireguard">Ketik secara manual[Wireguard ]</string>
<string name="menu_item_import_config_custom">Config khusus</string>
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
<string name="menu_item_import_config_manually_vmess">手動で入力[Vmess]</string>
<string name="menu_item_import_config_manually_vless">手動で入力[VLESS]</string>
<string name="menu_item_import_config_manually_ss">手動で入力[Shadowsocks]</string>
<string name="menu_item_import_config_manually_socks">手動で入力[靴下]</string>
<string name="menu_item_import_config_manually_trojan">手動で入力[トロイの木馬]</string>
<string name="menu_item_import_config_manually_wireguard">手動で入力[ワイヤーガード]</string>
<string name="menu_item_import_config_manually_socks">手動で入力[Socks]</string>
<string name="menu_item_import_config_manually_http">手動で入力[HTTP]</string>
<string name="menu_item_import_config_manually_trojan">手動で入力[Trojan]</string>
<string name="menu_item_import_config_manually_wireguard">手動で入力[Wireguard]</string>
<string name="menu_item_import_config_custom">カスタム構成</string>
<string name="menu_item_import_config_custom_clipboard">クリップボードからカスタム構成をインポートする</string>
<string name="menu_item_import_config_custom_local">カスタム構成をローカルからインポートする</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-jw/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<string name="menu_item_import_config_manually_vless">Ketik manual[VLESS]</string>
<string name="menu_item_import_config_manually_ss">Ketik manual[Shadowsocks]</string>
<string name="menu_item_import_config_manually_socks">Ketik manual[Socks]</string>
<string name="menu_item_import_config_manually_http">Ketik manual[HTTP]</string>
<string name="menu_item_import_config_manually_trojan">Ketik manual[Trojan]</string>
<string name="menu_item_import_config_manually_wireguard">Ketik kanthi manual[Wireguard]</string>
<string name="menu_item_import_config_custom">Konfigurasi kustom</string>
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
<string name="menu_item_import_config_manually_vmess">Введите вручную [Vmess]</string>
<string name="menu_item_import_config_manually_vless">Введите вручную[VLESS]</string>
<string name="menu_item_import_config_manually_ss">Введите вручную[Shadowsocks]</string>
<string name="menu_item_import_config_manually_socks">Введите вручную [Носки]</string>
<string name="menu_item_import_config_manually_trojan">Введите вручную [Троян]</string>
<string name="menu_item_import_config_manually_socks">Введите вручную [Socks]</string>
<string name="menu_item_import_config_manually_http">Введите вручную[HTTP]</string>
<string name="menu_item_import_config_manually_trojan">Введите вручную [Trojan]</string>
<string name="menu_item_import_config_manually_wireguard">Введите вручную [Wireguard]</string>
<string name="menu_item_import_config_custom">Пользовательская конфигурация</string>
<string name="menu_item_import_config_custom_clipboard">Импортировать пользовательскую конфигурацию из буфера обмена</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-su/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<string name="menu_item_import_config_manually_vless">Ketik sacara manual[VLESS]</string>
<string name="menu_item_import_config_manually_ss">Ketik sacara manual[Shadowsocks]</string>
<string name="menu_item_import_config_manually_socks">Ketik sacara manual[Kaos kaki]</string>
<string name="menu_item_import_config_manually_http">Ketik secara manual[HTTP]</string>
<string name="menu_item_import_config_manually_trojan">Ketik sacara manual[Trojan]</string>
<string name="menu_item_import_config_manually_wireguard">Ketik sacara manual[Wireguard]</string>
<string name="menu_item_import_config_custom">Konfigurasi custom</string>
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-vi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
<string name="menu_item_import_config_manually_vmess">Nhập thủ công [Vmess]</string>
<string name="menu_item_import_config_manually_vless">Nhập thủ công[VLESS]</string>
<string name="menu_item_import_config_manually_ss">Nhập thủ công [Shadowsocks]</string>
<string name="menu_item_import_config_manually_socks">Nhập thủ công [Tất]</string>
<string name="menu_item_import_config_manually_socks">Nhập thủ công [Socks]</string>
<string name="menu_item_import_config_manually_http">Nhập thủ công [HTTP]</string>
<string name="menu_item_import_config_manually_trojan">Nhập thủ công [Trojan]</string>
<string name="menu_item_import_config_manually_wireguard">Nhập thủ công [Wireguard]</string>
<string name="menu_item_import_config_custom">Cấu hình tùy chỉnh</string>
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
<string name="menu_item_import_config_manually_vmess">手动输入[Vmess]</string>
<string name="menu_item_import_config_manually_vless">手动输入[VLESS]</string>
<string name="menu_item_import_config_manually_ss">手动输入[Shadowsocks]</string>
<string name="menu_item_import_config_manually_socks">手动输入[袜子]</string>
<string name="menu_item_import_config_manually_trojan">手动输入[木马]</string>
<string name="menu_item_import_config_manually_socks">手动输入[Socks]</string>
<string name="menu_item_import_config_manually_http">手动输入[HTTP]</string>
<string name="menu_item_import_config_manually_trojan">手动输入[Trojan]</string>
<string name="menu_item_import_config_manually_wireguard">手动输入[Wireguard]</string>
<string name="menu_item_import_config_custom">自定义配置</string>
<string name="menu_item_import_config_custom_clipboard">从剪贴板导入自定义配置</string>
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
<string name="menu_item_import_config_manually_vmess">手動輸入[Vmess]</string>
<string name="menu_item_import_config_manually_vless">手動輸入[VLESS]</string>
<string name="menu_item_import_config_manually_ss">手動輸入[Shadowsocks]</string>
<string name="menu_item_import_config_manually_socks">手動輸入[襪子]</string>
<string name="menu_item_import_config_manually_trojan">手動輸入[木馬]</string>
<string name="menu_item_import_config_manually_socks">手動輸入[Socks]</string>
<string name="menu_item_import_config_manually_http">手动输入[HTTP]</string>
<string name="menu_item_import_config_manually_trojan">手動輸入[Trojan]</string>
<string name="menu_item_import_config_manually_wireguard">手動輸入[Wireguard]</string>
<string name="menu_item_import_config_custom">自訂配置</string>
<string name="menu_item_import_config_custom_clipboard">從剪貼簿匯入自訂配置</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<string name="menu_item_import_config_manually_vless">Type manually[VLESS]</string>
<string name="menu_item_import_config_manually_ss">Type manually[Shadowsocks]</string>
<string name="menu_item_import_config_manually_socks">Type manually[Socks]</string>
<string name="menu_item_import_config_manually_http">Type manually[HTTP]</string>
<string name="menu_item_import_config_manually_trojan">Type manually[Trojan]</string>
<string name="menu_item_import_config_manually_wireguard">Type manually[Wireguard]</string>
<string name="menu_item_import_config_custom">Custom config</string>
Expand Down

0 comments on commit e196f8b

Please sign in to comment.