feat(gui): add an Iran rule set to the RoutingA templates

This commit is contained in:
Zakk committed 2026-11-17 23:28:45 +11:00
1 parent 819b25b0a8
commit f8063e430c
16 files changed
+59

No files matched your search

+16
View File
@@ -18,6 +18,7 @@ import RoutingA from "./RoutingA.vue";
import RuleDialog from "./routingA/RuleDialog.vue";
import { template } from "./routingA/template";
import { russia } from "./routingA/russia";
import { iran } from "./routingA/iran";
const api = vi.hoisted(() => ({
getRoutingA: vi.fn(),
@@ -141,6 +142,21 @@ describe("RoutingA dialog", () => {
expect((await textView(wrapper)).element.value).toBe(russia);
});
test("offers the Iran rule set as a confirmed replacement", async () => {
const wrapper = mountWithApp(RoutingA);
await flushPromises();
await button(wrapper, en.routingA.templates.title).trigger("click");
await flushPromises();
const option = [...document.querySelectorAll(".v-list-item")].find((item) =>
item.textContent?.includes(en.routingA.templates.iran),
);
expect(option).toBeDefined();
option!.dispatchEvent(new MouseEvent("click", { bubbles: true }));
await flushPromises();
await respond(true);
expect((await textView(wrapper)).element.value).toBe(iran);
});
test("loads, highlights and saves rules verbatim without confirming comments", async () => {
const wrapper = mountWithApp(RoutingA);
await flushPromises();
+12
View File
@@ -0,0 +1,12 @@
// Iranian sites and addresses go direct, everything else through the proxy.
// Only categories in the v2fly geosite.dat and geoip.dat: category-ir and ir.
export const iran = `default: proxy
# Route local hostnames and private IP addresses directly
domain(geosite:private) -> direct
ip(geoip:private) -> direct
# Route Iranian domains directly
domain(geosite:category-ir) -> direct
# Route Iranian IP addresses directly
ip(geoip:ir) -> direct`;
@@ -19,6 +19,7 @@ describe("the rule templates", () => {
"global",
"minimal",
"russia",
"iran",
]);
});
test("Russian proxy exceptions precede the direct category", () => {
@@ -29,4 +30,14 @@ describe("the rule templates", () => {
);
expect(rules).toContain("default: proxy");
});
test("the Iran rule set follows Russia in the menu and keeps the LAN direct", () => {
const keys = presets.map((p) => p.key);
expect(keys.indexOf("iran")).toBe(keys.indexOf("russia") + 1);
const rules = presets.find((p) => p.key === "iran")!.code;
expect(rules.startsWith("default: proxy\n")).toBe(true);
expect(rules).toContain("domain(geosite:private) -> direct");
expect(rules).toContain("ip(geoip:private) -> direct");
expect(rules).toContain("domain(geosite:category-ir) -> direct");
expect(rules).toContain("ip(geoip:ir) -> direct");
});
});
@@ -1,5 +1,6 @@
import { template } from "./template";
import { russia } from "./russia";
import { iran } from "./iran";
// Rule sets for the Templates menu: one that starts with `default:` replaces
// the rules, the others are inserted. Outbounds are only proxy, direct and
@@ -37,6 +38,7 @@ domain(geosite:category-social-media-!cn, geosite:category-ai-!cn)->proxy
${telegramRanges}`,
},
{ key: "russia", code: russia },
{ key: "iran", code: iran },
{ key: "ads", code: "domain(geosite:category-ads-all)->block" },
{
key: "streaming",
+2
View File
@@ -48,6 +48,8 @@ The Russia template sends `geosite:category-ru` directly, except for its listed
Russian IP addresses (`geoip:ru`) and private hostnames and IP addresses (`geosite:private`, `geoip:private`) also go directly; the proxy exceptions take precedence.
The Iran template sends private hostnames and IP addresses (`geosite:private`, `geoip:private`), Iranian domains (`geosite:category-ir`) and Iranian IP addresses (`geoip:ir`) directly; everything else uses the proxy. It requires a `geosite.dat` containing `category-ir`.
Saving reloads a running core with the new rules; when the core rejects them, v2rayA puts the previous rules back and shows the core's error, which names the offending text. A stopped core takes the rules on its next start.
## Custom inbounds
+2
View File
@@ -48,6 +48,8 @@ domain(domain: corp.example) -> office
نشانی‌های IP روسیه (`geoip:ru`) و نام‌ها و نشانی‌های IP شبکهٔ محلی (`geosite:private`، `geoip:private`) نیز مستقیم متصل می‌شوند؛ استثناهای پروکسی اولویت دارند.
الگوی ایران نام‌ها و نشانی‌های IP شبکهٔ محلی (`geosite:private`، `geoip:private`)، دامنه‌های ایران (`geosite:category-ir`) و نشانی‌های IP ایران (`geoip:ir`) را مستقیم می‌فرستد؛ بقیهٔ ترافیک از پروکسی می‌گذرد. فایل `geosite.dat` باید شامل `category-ir` باشد.
ذخیره کردن، هستهٔ در حال اجرا را با قوانین جدید دوباره بارگذاری می‌کند؛ اگر هسته آن‌ها را رد کند، v2rayA قوانین قبلی را برمی‌گرداند و خطای هسته را نشان می‌دهد که متن مشکل‌دار را مشخص می‌کند. هستهٔ متوقف‌شده قوانین را در راه‌اندازی بعدی دریافت می‌کند.
## ورودی‌های سفارشی
+2
View File
@@ -48,6 +48,8 @@ Loyalsoldier 빌드에만 있는 이름(`gfw`, `apple-cn`, `google-cn`, `geoip:t
러시아 IP 주소(`geoip:ru`)와 로컬 호스트 이름 및 IP 주소(`geosite:private`, `geoip:private`)도 직접 연결하며, 프록시 예외 규칙이 우선합니다.
이란 템플릿은 로컬 호스트 이름과 IP 주소(`geosite:private`, `geoip:private`), 이란 도메인(`geosite:category-ir`), 이란 IP 주소(`geoip:ir`)를 직접 연결하고 나머지 트래픽은 프록시를 사용합니다. `category-ir`가 포함된 `geosite.dat`가 필요합니다.
저장하면 실행 중인 코어가 새 규칙을 다시 불러옵니다. 코어가 규칙을 거부하면 v2rayA는 이전 규칙으로 되돌리고 문제가 된 텍스트가 명시된 코어 오류를 표시합니다. 중지된 코어는 다음 시작 시 규칙을 적용합니다.
## 사용자 지정 인바운드
+2
View File
@@ -48,6 +48,8 @@ O modelo para a Rússia encaminha `geosite:category-ru` diretamente, exceto pelo
Os endereços IP russos (`geoip:ru`) e os nomes e endereços IP privados (`geosite:private`, `geoip:private`) também usam conexão direta; as exceções de proxy têm prioridade.
O modelo para o Irã encaminha diretamente os nomes e endereços IP privados (`geosite:private`, `geoip:private`), os domínios iranianos (`geosite:category-ir`) e os endereços IP iranianos (`geoip:ir`); todo o restante usa o proxy. Ele requer um `geosite.dat` com `category-ir`.
Salvar recarrega um núcleo em execução com as novas regras; quando o núcleo as rejeita, o v2rayA restaura as regras anteriores e mostra o erro do núcleo, que indica o texto problemático. Um núcleo parado adota as regras na próxima inicialização.
## Entradas personalizadas
+2
View File
@@ -48,6 +48,8 @@ domain(domain: corp.example) -> office
Российские IP-адреса (`geoip:ru`), локальные имена и IP-адреса (`geosite:private`, `geoip:private`) тоже направляются напрямую; домены-исключения имеют приоритет и идут через прокси.
Шаблон для Ирана направляет напрямую локальные имена и IP-адреса (`geosite:private`, `geoip:private`), иранские домены (`geosite:category-ir`) и иранские IP-адреса (`geoip:ir`); остальной трафик идёт через прокси. Для него нужен `geosite.dat` с категорией `category-ir`.
При сохранении работающее ядро перезагружается с новыми правилами; если ядро их отклоняет, v2rayA возвращает предыдущие правила и показывает ошибку ядра с указанием некорректного текста. Остановленное ядро применяет правила при следующем запуске.
## Пользовательские входящие порты
+2
View File
@@ -48,6 +48,8 @@ domain(domain: corp.example) -> office
俄罗斯 IP 地址(`geoip:ru`)以及局域网域名和 IP 地址(`geosite:private`、`geoip:private`)也直连;代理例外规则优先。
伊朗模板让局域网域名和 IP 地址(`geosite:private`、`geoip:private`)、伊朗域名(`geosite:category-ir`)以及伊朗 IP 地址(`geoip:ir`)直连;其余流量走代理。此模板需要包含 `category-ir` 的 `geosite.dat`。
保存后运行中的内核以新规则重新加载;内核拒绝规则时 v2rayA 恢复原规则并显示内核的错误,错误信息指出出错的内容。已停止的内核在下次启动时读取新规则。
## 自定义入站
+1
View File
@@ -513,6 +513,7 @@ export default {
"Only common foreign services through the proxy, everything else direct",
russia:
"Russian sites direct, listed exceptions and the rest through the proxy",
iran: "Iranian sites direct, everything else through the proxy",
ads: "Block advertising domains",
streaming:
"Streaming through the proxy (Netflix, Disney, HBO, Prime Video, YouTube, Spotify, TikTok)",
+1
View File
@@ -507,6 +507,7 @@ export default {
global: "همه از پروکسی، شبکهٔ محلی مستقیم",
minimal: "فقط سرویس‌های خارجی رایج از پروکسی، بقیه مستقیم",
russia: "سایت‌های روسیه مستقیم، استثناها و بقیه از پروکسی",
iran: "سایت‌های ایران مستقیم، بقیه از پروکسی",
ads: "مسدود کردن دامنه‌های تبلیغاتی",
streaming:
"پخش ویدئو و موسیقی از پروکسی (Netflix، Disney، HBO، Prime Video، YouTube، Spotify، TikTok)",
+1
View File
@@ -505,6 +505,7 @@ export default {
global: "모두 프록시, LAN은 직접 연결",
minimal: "자주 쓰는 해외 서비스만 프록시, 나머지는 직접 연결",
russia: "러시아 사이트는 직접 연결, 예외와 나머지는 프록시",
iran: "이란 사이트는 직접 연결, 나머지는 프록시",
ads: "광고 도메인 차단",
streaming:
"스트리밍은 프록시 (Netflix, Disney, HBO, Prime Video, YouTube, Spotify, TikTok)",
+1
View File
@@ -518,6 +518,7 @@ export default {
global: "Tudo pelo proxy, rede local direto",
minimal: "Só os serviços estrangeiros comuns pelo proxy, o resto direto",
russia: "Sites russos direto, exceções e o restante pelo proxy",
iran: "Sites iranianos direto, o restante pelo proxy",
ads: "Bloquear domínios de publicidade",
streaming:
"Streaming pelo proxy (Netflix, Disney, HBO, Prime Video, YouTube, Spotify, TikTok)",
+1
View File
@@ -513,6 +513,7 @@ export default {
minimal:
"Только распространённые зарубежные сервисы через прокси, остальное напрямую",
russia: "Российские сайты напрямую, исключения и остальное через прокси",
iran: "Иранские сайты напрямую, остальное через прокси",
ads: "Блокировать рекламные домены",
streaming:
"Стриминг через прокси (Netflix, Disney, HBO, Prime Video, YouTube, Spotify, TikTok)",
+1
View File
@@ -494,6 +494,7 @@ export default {
global: "全部走代理,仅局域网直连",
minimal: "只让常用海外服务走代理,其余直连",
russia: "俄罗斯站点直连,例外及其余流量走代理",
iran: "伊朗站点直连,其余流量走代理",
ads: "拦截广告域名",
streaming:
"流媒体走代理(Netflix、Disney、HBO、Prime Video、YouTube、Spotify、TikTok)",