Add obfs for Hysteria2
This commit is contained in:
1 parent
3688dd4634
commit
ed8fb7fa82
13 files changed
+67
-8
No files matched your search
@@ -4,9 +4,19 @@ data class Hysteria2Bean(
|
||||
val server: String?,
|
||||
val auth: String?,
|
||||
val lazy: Boolean? = true,
|
||||
val socks5: Socks5Bean?,
|
||||
val tls: TlsBean?
|
||||
val obfs: ObfsBean? = null,
|
||||
val socks5: Socks5Bean? = null,
|
||||
val tls: TlsBean? = null,
|
||||
) {
|
||||
data class ObfsBean(
|
||||
val type: String?,
|
||||
val salamander: SalamanderBean?
|
||||
) {
|
||||
data class SalamanderBean(
|
||||
val password: String?,
|
||||
)
|
||||
}
|
||||
|
||||
data class Socks5Bean(
|
||||
val listen: String?,
|
||||
)
|
||||
@@ -15,4 +25,4 @@ data class Hysteria2Bean(
|
||||
val sni: String?,
|
||||
val insecure: Boolean?,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -104,7 +104,8 @@ data class V2rayConfig(
|
||||
var secretKey: String? = null,
|
||||
val peers: List<WireGuardBean>? = null,
|
||||
var reserved: List<Int>? = null,
|
||||
var mtu: Int? = null
|
||||
var mtu: Int? = null,
|
||||
var obfsPassword: String? = null,
|
||||
) {
|
||||
|
||||
data class VnextBean(
|
||||
|
||||
@@ -118,6 +118,7 @@ class ServerActivity : BaseActivity() {
|
||||
private val et_reserved3: EditText? by lazy { findViewById(R.id.et_reserved3) }
|
||||
private val et_local_address: EditText? by lazy { findViewById(R.id.et_local_address) }
|
||||
private val et_local_mtu: EditText? by lazy { findViewById(R.id.et_local_mtu) }
|
||||
private val et_obfs_password: EditText? by lazy { findViewById(R.id.et_obfs_password) }
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -292,7 +293,10 @@ class ServerActivity : BaseActivity() {
|
||||
} else {
|
||||
et_local_mtu?.text = Utils.getEditable(outbound.settings?.mtu.toString())
|
||||
}
|
||||
} else if (config.configType == EConfigType.HYSTERIA2) {
|
||||
et_obfs_password?.text = Utils.getEditable(outbound.settings?.obfsPassword)
|
||||
}
|
||||
|
||||
val securityEncryptions =
|
||||
if (config.configType == EConfigType.SHADOWSOCKS) shadowsocksSecuritys else securitys
|
||||
val security =
|
||||
@@ -455,6 +459,9 @@ class ServerActivity : BaseActivity() {
|
||||
if (config.subscriptionId.isEmpty() && !subscriptionId.isNullOrEmpty()) {
|
||||
config.subscriptionId = subscriptionId.orEmpty()
|
||||
}
|
||||
if (config.configType == EConfigType.HYSTERIA2) {
|
||||
config.outboundBean?.settings?.obfsPassword = et_obfs_password?.text?.toString()
|
||||
}
|
||||
|
||||
MmkvManager.encodeServerConfig(editGuid, config)
|
||||
toast(R.string.toast_success)
|
||||
|
||||
@@ -40,6 +40,10 @@ object Hysteria2Fmt {
|
||||
server.port = uri.port
|
||||
server.password = uri.userInfo
|
||||
}
|
||||
if (!queryParam["obfs-password"].isNullOrEmpty()) {
|
||||
config.outboundBean?.settings?.obfsPassword = queryParam["obfs-password"]
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
@@ -59,6 +63,10 @@ object Hysteria2Fmt {
|
||||
dicQuery["alpn"] = Utils.removeWhiteSpace(tlsSetting.alpn.joinToString(",")).orEmpty()
|
||||
}
|
||||
}
|
||||
if (!outbound.settings?.obfsPassword.isNullOrEmpty()) {
|
||||
dicQuery["obfs"] = "salamander"
|
||||
dicQuery["obfs-password"] = outbound.settings?.obfsPassword ?: ""
|
||||
}
|
||||
|
||||
val query = "?" + dicQuery.toList().joinToString(
|
||||
separator = "&",
|
||||
@@ -76,9 +84,18 @@ object Hysteria2Fmt {
|
||||
fun toNativeConfig(config: ServerConfig, socksPort: Int): Hysteria2Bean? {
|
||||
val outbound = config.getProxyOutbound() ?: return null
|
||||
val tls = outbound.streamSettings?.tlsSettings
|
||||
val obfs = if (outbound.settings?.obfsPassword.isNullOrEmpty()) null else
|
||||
Hysteria2Bean.ObfsBean(
|
||||
type = "salamander",
|
||||
salamander = Hysteria2Bean.ObfsBean.SalamanderBean(
|
||||
password = outbound.settings?.obfsPassword
|
||||
)
|
||||
)
|
||||
|
||||
val bean = Hysteria2Bean(
|
||||
server = outbound.getServerAddressAndPort(),
|
||||
auth = outbound.getPassword(),
|
||||
obfs = obfs,
|
||||
socks5 = Hysteria2Bean.Socks5Bean(
|
||||
listen = "$LOOPBACK:${socksPort}",
|
||||
),
|
||||
|
||||
@@ -13,6 +13,25 @@
|
||||
|
||||
<include layout="@layout/layout_address_port" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/layout_margin_top_height"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/server_obfs_password" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/et_obfs_password"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/edit_height"
|
||||
android:inputType="text" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -32,7 +51,6 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<include layout="@layout/layout_tls_hysteria2" />
|
||||
|
||||
<LinearLayout
|
||||
|
||||
@@ -112,6 +112,7 @@
|
||||
<string name="msg_file_not_found">الملف غير موجود</string>
|
||||
<string name="msg_remark_is_duplicate">الملاحظات موجودة بالفعل</string>
|
||||
<string name="toast_action_not_allowed">الإجراء غير مسموح به</string>
|
||||
<string name="server_obfs_password">Obfs password</string>
|
||||
|
||||
<!-- PerAppProxyActivity -->
|
||||
<string name="msg_dialog_progress">جار التحميل</string>
|
||||
|
||||
@@ -111,6 +111,8 @@
|
||||
<string name="msg_file_not_found">ফাইল খুঁজে পাওয়া যায়নি</string>
|
||||
<string name="msg_remark_is_duplicate">মন্তব্য ইতিমধ্যে বিদ্যমান</string>
|
||||
<string name="toast_action_not_allowed">অ্যাকশন অনুমোদিত নয়</string>
|
||||
<string name="server_obfs_password">Obfs password</string>
|
||||
|
||||
<!-- PerAppProxyActivity -->
|
||||
<string name="msg_dialog_progress">লোড হচ্ছে</string>
|
||||
<string name="menu_item_search">অনুসন্ধান করুন</string>
|
||||
|
||||
@@ -105,6 +105,7 @@
|
||||
<string name="title_url">URL</string>
|
||||
<string name="menu_item_download_file">دانلود فایلها</string>
|
||||
<string name="toast_action_not_allowed">این عمل ممنوع است</string>
|
||||
<string name="server_obfs_password">Obfs password</string>
|
||||
|
||||
<!-- PerAppProxyActivity -->
|
||||
<string name="title_user_asset_add_url">URL را اضافه کنید</string>
|
||||
|
||||
@@ -110,7 +110,7 @@
|
||||
<string name="msg_file_not_found">Файл не найден</string>
|
||||
<string name="msg_remark_is_duplicate">Название уже существует</string>
|
||||
<string name="toast_action_not_allowed">Это действие запрещено</string>
|
||||
|
||||
<string name="server_obfs_password">Obfs password</string>
|
||||
|
||||
<!-- PerAppProxyActivity -->
|
||||
<string name="msg_dialog_progress">Загрузка…</string>
|
||||
|
||||
@@ -105,6 +105,7 @@
|
||||
<string name="title_url">URL</string>
|
||||
<string name="menu_item_download_file">Tải xuống tệp tin</string>
|
||||
<string name="toast_action_not_allowed">Hành động này bị cấm!</string>
|
||||
<string name="server_obfs_password">Obfs password</string>
|
||||
|
||||
<!-- PerAppProxyActivity -->
|
||||
<string name="title_user_asset_add_url">Thêm URL nội dung</string>
|
||||
|
||||
@@ -105,7 +105,7 @@
|
||||
<string name="title_url">URL</string>
|
||||
<string name="menu_item_download_file">下载文件</string>
|
||||
<string name="toast_action_not_allowed">禁止此项操作</string>
|
||||
|
||||
<string name="server_obfs_password">混淆密码</string>
|
||||
|
||||
<!-- PerAppProxyActivity -->
|
||||
<string name="title_user_asset_add_url">添加资产网址</string>
|
||||
|
||||
@@ -105,6 +105,7 @@
|
||||
<string name="title_url">URL</string>
|
||||
<string name="menu_item_download_file">下載檔案</string>
|
||||
<string name="toast_action_not_allowed">禁止此項操作</string>
|
||||
<string name="server_obfs_password">混淆密碼</string>
|
||||
|
||||
<!-- PerAppProxyActivity -->
|
||||
<string name="title_user_asset_add_url">新增資產網址</string>
|
||||
|
||||
@@ -111,7 +111,7 @@
|
||||
<string name="msg_file_not_found">File not found</string>
|
||||
<string name="msg_remark_is_duplicate">The remarks already exists</string>
|
||||
<string name="toast_action_not_allowed">Action not allowed</string>
|
||||
|
||||
<string name="server_obfs_password">Obfs password</string>
|
||||
|
||||
<!-- PerAppProxyActivity -->
|
||||
<string name="msg_dialog_progress">Loading</string>
|
||||
|
||||
Reference in new issue
Block a user