From 7f4ee70cb7dc46ccd0904c4c604a7162add20f21 Mon Sep 17 00:00:00 2001 From: nite07 Date: Mon, 18 Mar 2024 22:32:33 +0800 Subject: [PATCH] fix: docker --- .goreleaser.yaml | 11 +- Dockerfile | 12 +- LICENSE.txt => LICENSE | 0 docker-compose.yaml | 7 +- entrypoint.sh | 9 + internal/model/country_code_map.go | 1044 +++++++++++++++++ pkg/util/convert.go | 40 +- .../tun-fakeip-with-dns-leaks.json | 0 .../tun-fakeip-without-dns-leaks.json | 0 .../tun-with-dns-leaks.json | 0 .../tun-without-dns-leaks.json | 0 11 files changed, 1107 insertions(+), 16 deletions(-) rename LICENSE.txt => LICENSE (100%) create mode 100644 entrypoint.sh create mode 100644 internal/model/country_code_map.go rename {template => templates}/tun-fakeip-with-dns-leaks.json (100%) rename {template => templates}/tun-fakeip-without-dns-leaks.json (100%) rename {template => templates}/tun-with-dns-leaks.json (100%) rename {template => templates}/tun-without-dns-leaks.json (100%) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index aec47d1..2aea47c 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -16,6 +16,13 @@ builds: flags: - -trimpath no_unique_dist_dir: true - binary: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}" archives: - - format: binary \ No newline at end of file + - format: tar.gz + format_overrides: + - format: zip + goos: windows + wrap_in_directory: true + files: + - LICENSE + - README.md + - templates diff --git a/Dockerfile b/Dockerfile index 08881d6..628043e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,9 +10,17 @@ ARG version RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X sub2clash/config.Version=${version}" -o sub2sing-box main.go +WORKDIR /app + FROM alpine:latest COPY --from=builder /app/sub2sing-box /app/sub2sing-box -COPY --from=builder /app/template /app/template +COPY --from=builder /app/templates /app/templates-origin +COPY --from=builder /app/entrypoint.sh /app/entrypoint.sh -ENTRYPOINT ["/app/sub2sing-box","server"] +RUN chmod +x /app/entrypoint.sh + +VOLUME [ "/app/templates" ] +EXPOSE 8080 + +ENTRYPOINT ["/app/entrypoint.sh"] diff --git a/LICENSE.txt b/LICENSE similarity index 100% rename from LICENSE.txt rename to LICENSE diff --git a/docker-compose.yaml b/docker-compose.yaml index 993f734..448019d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,8 +1,9 @@ +version: "3.8" services: sub2sing-box: - image: nite07/sub2sing-box:latest + image: nite07/sub2sing-box:dev # nite07/sub2sing-box:latest container_name: sub2sing-box volumes: - - ./template:/app/template + - ./templates:/app/templates ports: - - 8080:8080 \ No newline at end of file + - 8080:8080 diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..f8a85c8 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/sh +if [ ! -d "/app/templates" ]; then + mkdir /app/templates +fi +if [ -z "$(ls -A /app/templates)" ]; then + cp -r /app/templates-origin/* /app/templates +fi +cd /app +/app/sub2sing-box server diff --git a/internal/model/country_code_map.go b/internal/model/country_code_map.go new file mode 100644 index 0000000..76673fe --- /dev/null +++ b/internal/model/country_code_map.go @@ -0,0 +1,1044 @@ +package model + +// https://zh.wikipedia.org/wiki/%E5%8C%BA%E5%9F%9F%E6%8C%87%E7%A4%BA%E7%AC%A6 +// https://zh.wikipedia.org/zh-sg/ISO_3166-1%E4%BA%8C%E4%BD%8D%E5%AD%97%E6%AF%8D%E4%BB%A3%E7%A0%81 + +var CountryEnglishName = map[string]string{ + "Andorra": "安道尔(AD)", + "United Arab Emirates": "阿联酋(AE)", + "Afghanistan": "阿富汗(AF)", + "Antigua and Barbuda": "安提瓜和巴布达(AG)", + "Anguilla": "安圭拉(AI)", + "Albania": "阿尔巴尼亚(AL)", + "Armenia": "亚美尼亚(AM)", + "Angola": "安哥拉(AO)", + "Antarctica": "南极洲(AQ)", + "Argentina": "阿根廷(AR)", + "American Samoa": "美属萨摩亚(AS)", + "Austria": "奥地利(AT)", + "Australia": "澳大利亚(AU)", + "Aruba": "阿鲁巴(AW)", + "Åland Islands": "奥兰(AX)", + "Azerbaijan": "阿塞拜疆(AZ)", + "Bosnia and Herzegovina": "波黑(BA)", + "Barbados": "巴巴多斯(BB)", + "Bangladesh": "孟加拉(BD)", + "Belgium": "比利时(BE)", + "Burkina Faso": "布基纳法索(BF)", + "Bulgaria": "保加利亚(BG)", + "Bahrain": "巴林(BH)", + "Burundi": "布隆迪(BI)", + "Benin": "贝宁(BJ)", + "Saint Barthélemy": "圣巴泰勒米(BL)", + "Bermuda": "百慕大(BM)", + "Brunei Darussalam": "汶莱(BN)", + "Bolivia": "玻利维亚(BO)", + "Plurinational State of": "玻利维亚(BO)", + "Bonaire": "荷兰加勒比区(BQ)", + "Sint Eustatius and Saba": "荷兰加勒比区(BQ)", + "Brazil": "巴西(BR)", + "Bahamas": "巴哈马(BS)", + "Bhutan": "不丹(BT)", + "Bouvet Island": "布韦岛(BV)", + "Botswana": "博茨瓦纳(BW)", + "Belarus": "白俄罗斯(BY)", + "Belize": "伯利兹(BZ)", + "Canada": "加拿大(CA)", + "Cocos (Keeling) Islands": "科科斯(基林)群岛(CC)", + "DR Congo": "刚果民主共和国(CD)", + "the Democratic Republic of the": "刚果民主共和国(CD)", + "Central African Republic": "中非(CF)", + "Congo": "刚果共和国(CG)", + "Switzerland": "瑞士(CH)", + "Côte d'Ivoire": "象牙海岸(CI)", + "Cook Islands": "库克群岛(CK)", + "Chile": "智利(CL)", + "Cameroon": "喀麦隆(CM)", + "China": "中国(CN)", + "Colombia": "哥伦比亚(CO)", + "Costa Rica": "哥斯达黎加(CR)", + "Cuba": "古巴(CU)", + "Cabo Verde": "佛得角(CV)", + "Curaçao": "库拉索(CW)", + "Christmas Island": "圣诞岛(CX)", + "Cyprus": "塞浦路斯(CY)", + "Czechia": "捷克(CZ)", + "Germany": "德国(DE)", + "Djibouti": "吉布提(DJ)", + "Denmark": "丹麦(DK)", + "Dominica": "多米尼克(DM)", + "Dominican Republic": "多米尼加(DO)", + "Algeria": "阿尔及利亚(DZ)", + "Ecuador": "厄瓜多尔(EC)", + "Estonia": "爱沙尼亚(EE)", + "Egypt": "埃及(EG)", + "Western Sahara": "西撒哈拉(EH)", + "Eritrea": "厄立特里亚(ER)", + "Spain": "西班牙(ES)", + "Ethiopia": "埃塞俄比亚(ET)", + "Finland": "芬兰(FI)", + "Fiji": "斐济(FJ)", + "Falkland Islands (Malvinas)": "福克兰群岛(FK)", + "Micronesia": "密克罗尼西亚联邦(FM)", + "Federated States of": "密克罗尼西亚联邦(FM)", + "Faroe Islands": "法罗群岛(FO)", + "France": "法国(FR)", + "Gabon": "加蓬(GA)", + "United Kingdom of Great Britain and Northern Ireland": "英国(UK)", + "Grenada": "格林纳达(GD)", + "Georgia": "格鲁吉亚(GE)", + "French Guiana": "法属圭亚那(GF)", + "Guernsey": "根西(GG)", + "Ghana": "加纳(GH)", + "Gibraltar": "直布罗陀(GI)", + "Greenland": "格陵兰(GL)", + "Gambia": "冈比亚(GM)", + "Guinea": "几内亚(GN)", + "Guadeloupe": "瓜德罗普(GP)", + "Equatorial Guinea": "赤道几内亚(GQ)", + "Greece": "希腊(GR)", + "South Georgia and the South Sandwich Islands": "南乔治亚和南桑威奇群岛(GS)", + "Guatemala": "危地马拉(GT)", + "Guam": "关岛(GU)", + "Guinea-Bissau": "几内亚比绍(GW)", + "Guyana": "圭亚那(GY)", + "Hong Kong": "香港(HK)", + "Heard Island and McDonald Islands": "赫德岛和麦克唐纳群岛(HM)", + "Honduras": "洪都拉斯(HN)", + "Croatia": "克罗地亚(HR)", + "Haiti": "海地(HT)", + "Hungary": "匈牙利(HU)", + "Indonesia": "印度尼西亚(ID)", + "Ireland": "爱尔兰(IE)", + "Israel": "以色列(IL)", + "Isle of Man": "马恩岛(IM)", + "India": "印度(IN)", + "British Indian Ocean Territory": "英属印度洋领地(IO)", + "Iraq": "伊拉克(IQ)", + "Iran": "伊朗(IR)", + "Iceland": "冰岛(IS)", + "Italy": "意大利(IT)", + "Jersey": "泽西(JE)", + "Jamaica": "牙买加(JM)", + "Jordan": "约旦(JO)", + "Japan": "日本(JP)", + "Kenya": "肯尼亚(KE)", + "Kyrgyzstan": "吉尔吉斯斯坦(KG)", + "Cambodia": "柬埔寨(KH)", + "Kiribati": "基里巴斯(KI)", + "Comoros": "科摩罗(KM)", + "Saint Kitts and Nevis": "圣基茨和尼维斯(KN)", + "North Korea": "北韩(KP)", + "South Korea": "韩国(KR)", + "Kuwait": "科威特(KW)", + "Cayman Islands": "开曼群岛(KY)", + "Kazakhstan": "哈萨克斯坦(KZ)", + "Lao People's Democratic Republic": "寮国(LA)", + "Lebanon": "黎巴嫩(LB)", + "Saint Lucia": "圣卢西亚(LC)", + "Liechtenstein": "列支敦士登(LI)", + "Sri Lanka": "斯里兰卡(LK)", + "Liberia": "利比里亚(LR)", + "Lesotho": "莱索托(LS)", + "Lithuania": "立陶宛(LT)", + "Luxembourg": "卢森堡(LU)", + "Latvia": "拉脱维亚(LV)", + "Libya": "利比亚(LY)", + "Morocco": "摩洛哥(MA)", + "Monaco": "摩纳哥(MC)", + "Moldova, Republic of": "摩尔多瓦(MD)", + "Montenegro": "黑山(ME)", + "Saint Martin (French part)": "法属圣马丁(MF)", + "Madagascar": "马达加斯加(MG)", + "Marshall Islands": "马绍尔群岛(MH)", + "North Macedonia": "北马其顿(MK)", + "Mali": "马里(ML)", + "Myanmar": "缅甸(MM)", + "Mongolia": "蒙古(MN)", + "Macao": "澳门(MO)", + "Northern Mariana Islands": "北马里亚纳群岛(MP)", + "Martinique": "马提尼克(MQ)", + "Mauritania": "毛里塔尼亚(MR)", + "Montserrat": "蒙特塞拉特(MS)", + "Malta": "马耳他(MT)", + "Mauritius": "毛里求斯(MU)", + "Maldives": "马尔代夫(MV)", + "Malawi": "马拉维(MW)", + "Mexico": "墨西哥(MX)", + "Malaysia": "马来西亚(MY)", + "Mozambique": "莫桑比克(MZ)", + "Namibia": "那米比亚(NA)", + "New Caledonia": "新喀里多尼亚(NC)", + "Niger": "尼日尔(NE)", + "Norfolk Island": "诺福克岛(NF)", + "Nigeria": "尼日利亚(NG)", + "Nicaragua": "尼加拉瓜(NI)", + "Netherlands": "荷兰(NL)", + "Norway": "挪威(NO)", + "Nepal": "尼泊尔(NP)", + "Nauru": "瑙鲁(NR)", + "Niue": "纽埃(NU)", + "New Zealand": "新西兰(NZ)", + "Oman": "阿曼(OM)", + "Panama": "巴拿马(PA)", + "Peru": "秘鲁(PE)", + "French Polynesia": "法属波利尼西亚(PF)", + "Papua New Guinea": "巴布亚新几内亚(PG)", + "Philippines": "菲律宾(PH)", + "Pakistan": "巴基斯坦(PK)", + "Poland": "波兰(PL)", + "Saint Pierre and Miquelon": "圣皮埃尔和密克隆(PM)", + "Pitcairn": "皮特凯恩群岛(PN)", + "Puerto Rico": "波多黎各(PR)", + "Palestine": "巴勒斯坦(PS)", + "Portugal": "葡萄牙(PT)", + "Palau": "帕劳(PW)", + "Paraguay": "巴拉圭(PY)", + "Qatar": "卡塔尔(QA)", + "Réunion": "留尼汪(RE)", + "Romania": "罗马尼亚(RO)", + "Serbia": "塞尔维亚(RS)", + "Russian Federation": "俄罗斯(RU)", + "Rwanda": "卢旺达(RW)", + "Saudi Arabia": "沙特阿拉伯(SA)", + "Solomon Islands": "所罗门群岛(SB)", + "Seychelles": "塞舌尔(SC)", + "Sudan": "苏丹(SD)", + "Sweden": "瑞典(SE)", + "Singapore": "新加坡(SG)", + "Saint Helena": "圣赫勒拿、阿森松和特里斯坦-达库尼亚(SH)", + "Slovenia": "斯洛文尼亚(SI)", + "Svalbard and Jan Mayen": "斯瓦尔巴和扬马延(SJ)", + "Slovakia": "斯洛伐克(SK)", + "Sierra Leone": "塞拉利昂(SL)", + "San Marino": "圣马力诺(SM)", + "Senegal": "塞内加尔(SN)", + "Somalia": "索马里(SO)", + "Suriname": "苏里南(SR)", + "South Sudan": "南苏丹(SS)", + "Sao Tome and Principe": "圣多美和普林西比(ST)", + "El Salvador": "萨尔瓦多(SV)", + "Sint Maarten (Dutch part)": "荷属圣马丁(SX)", + "Syrian Arab Republic": "叙利亚(SY)", + "Eswatini": "斯威士兰(SZ)", + "Turks and Caicos Islands": "特克斯和凯科斯群岛(TC)", + "Chad": "乍得(TD)", + "French Southern Territories": "法属南部和南极领地(TF)", + "Togo": "多哥(TG)", + "Thailand": "泰国(TH)", + "Tajikistan": "塔吉克斯坦(TJ)", + "Tokelau": "托克劳(TK)", + "Timor-Leste": "东帝汶(TL)", + "Turkmenistan": "土库曼斯坦(TM)", + "Tunisia": "突尼斯(TN)", + "Tonga": "汤加(TO)", + "Turkey": "土耳其(TR)", + "Trinidad and Tobago": "特立尼达和多巴哥(TT)", + "Tuvalu": "图瓦卢(TV)", + "Taiwan": "台湾(TW)", + "Tanzania": "坦桑尼亚(TZ)", + "Ukraine": "乌克兰(UA)", + "Uganda": "乌干达(UG)", + "United States Minor Outlying Islands": "美国本土外小岛屿(UM)", + "United States of America": "美国(US)", + "Uruguay": "乌拉圭(UY)", + "Uzbekistan": "乌兹别克斯坦(UZ)", + "Holy See": "梵蒂冈(VA)", + "Saint Vincent and the Grenadines": "圣文森特和格林纳丁斯(VC)", + "Venezuela": "委内瑞拉(VE)", + "Virgin Islands, British": "英属维尔京群岛(VG)", + "Virgin Islands, U.S.": "美属维尔京群岛(VI)", + "Viet Nam": "越南(VN)", + "Vanuatu": "瓦努阿图(VU)", + "Wallis and Futuna": "瓦利斯和富图纳(WF)", + "Samoa": "萨摩亚(WS)", + "Yemen": "也门(YE)", + "Mayotte": "马约特(YT)", + "South Africa": "南非(ZA)", + "Zambia": "赞比亚(ZM)", + "Zimbabwe": "津巴布韦(ZW)", +} + +var CountryChineseName = map[string]string{ + "阿森松岛": "阿森松岛(AC)", + "安道尔": "安道尔(AD)", + "阿联酋": "阿联酋(AE)", + "阿富汗": "阿富汗(AF)", + "安提瓜和巴布达": "安提瓜和巴布达(AG)", + "安圭拉": "安圭拉(AI)", + "阿尔巴尼亚": "阿尔巴尼亚(AL)", + "亚美尼亚": "亚美尼亚(AM)", + "安哥拉": "安哥拉(AO)", + "南极洲": "南极洲(AQ)", + "阿根廷": "阿根廷(AR)", + "美属萨摩亚": "美属萨摩亚(AS)", + "奥地利": "奥地利(AT)", + "澳大利亚": "澳大利亚(AU)", + "阿鲁巴": "阿鲁巴(AW)", + "奥兰": "奥兰(AX)", + "阿塞拜疆": "阿塞拜疆(AZ)", + "波黑": "波黑(BA)", + "巴巴多斯": "巴巴多斯(BB)", + "孟加拉国": "孟加拉国(BD)", + "比利时": "比利时(BE)", + "布基纳法索": "布基纳法索(BF)", + "保加利亚": "保加利亚(BG)", + "巴林": "巴林(BH)", + "布隆迪": "布隆迪(BI)", + "贝宁": "贝宁(BJ)", + "圣巴泰勒米": "圣巴泰勒米(BL)", + "百慕大": "百慕大(BM)", + "文莱": "文莱(BN)", + "玻利维亚": "玻利维亚(BO)", + "荷兰加勒比区": "荷兰加勒比区(BQ)", + "巴西": "巴西(BR)", + "巴哈马": "巴哈马(BS)", + "不丹": "不丹(BT)", + "布韦岛": "布韦岛(BV)", + "博茨瓦纳": "博茨瓦纳(BW)", + "白俄罗斯": "白俄罗斯(BY)", + "伯利兹": "伯利兹(BZ)", + "加拿大": "加拿大(CA)", + "科科斯(基林)群岛": "科科斯(基林)群岛(CC)", + "刚果民主共和国": "刚果民主共和国(CD)", + "中非": "中非(CF)", + "刚果共和国": "刚果共和国(CG)", + "瑞士": "瑞士(CH)", + "科特迪瓦": "科特迪瓦(CI)", + "库克群岛": "库克群岛(CK)", + "智利": "智利(CL)", + "喀麦隆": "喀麦隆(CM)", + "中国": "中国(CN)", + "哥伦比亚": "哥伦比亚(CO)", + "克利珀顿岛": "克利珀顿岛(CP)", + "哥斯达黎加": "哥斯达黎加(CR)", + "古巴": "古巴(CU)", + "佛得角": "佛得角(CV)", + "库拉索": "库拉索(CW)", + "圣诞岛": "圣诞岛(CX)", + "塞浦路斯": "塞浦路斯(CY)", + "捷克": "捷克(CZ)", + "德国": "德国(DE)", + "迪戈加西亚岛": "迪戈加西亚岛(DG)", + "吉布提": "吉布提(DJ)", + "丹麦": "丹麦(DK)", + "多米尼克": "多米尼克(DM)", + "多米尼加": "多米尼加(DO)", + "阿尔及利亚": "阿尔及利亚(DZ)", + "休达": "休达(EA)", + "厄瓜多尔": "厄瓜多尔(EC)", + "爱沙尼亚": "爱沙尼亚(EE)", + "埃及": "埃及(EG)", + "西撒哈拉": "西撒哈拉(EH)", + "厄立特里亚": "厄立特里亚(ER)", + "西班牙": "西班牙(ES)", + "埃塞俄比亚": "埃塞俄比亚(ET)", + "欧盟": "欧盟(EU)", + "芬兰": "芬兰(FI)", + "斐济": "斐济(FJ)", + "福克兰群岛": "福克兰群岛(FK)", + "密克罗尼西亚联邦": "密克罗尼西亚联邦(FM)", + "法罗群岛": "法罗群岛(FO)", + "法国": "法国(FR)", + "加蓬": "加蓬(GA)", + "英国": "英国(UK)", + "格林纳达": "格林纳达(GD)", + "格鲁吉亚": "格鲁吉亚(GE)", + "法属圭亚那": "法属圭亚那(GF)", + "根西": "根西(GG)", + "加纳": "加纳(GH)", + "直布罗陀": "直布罗陀(GI)", + "格陵兰": "格陵兰(GL)", + "冈比亚": "冈比亚(GM)", + "几内亚": "几内亚(GN)", + "瓜德罗普": "瓜德罗普(GP)", + "赤道几内亚": "赤道几内亚(GQ)", + "希腊": "希腊(GR)", + "南乔治亚和南桑威奇群岛": "南乔治亚和南桑威奇群岛(GS)", + "危地马拉": "危地马拉(GT)", + "关岛": "关岛(GU)", + "几内亚比绍": "几内亚比绍(GW)", + "圭亚那": "圭亚那(GY)", + "香港": "香港(HK)", + "赫德岛和麦克唐纳群岛": "赫德岛和麦克唐纳群岛(HM)", + "洪都拉斯": "洪都拉斯(HN)", + "克罗地亚": "克罗地亚(HR)", + "海地": "海地(HT)", + "匈牙利": "匈牙利(HU)", + "加纳利群岛": "加纳利群岛(IC)", + "印尼": "印尼(ID)", + "爱尔兰": "爱尔兰(IE)", + "以色列": "以色列(IL)", + "马恩岛": "马恩岛(IM)", + "印度": "印度(IN)", + "英属印度洋领地": "英属印度洋领地(IO)", + "伊拉克": "伊拉克(IQ)", + "伊朗": "伊朗(IR)", + "冰岛": "冰岛(IS)", + "意大利": "意大利(IT)", + "泽西": "泽西(JE)", + "牙买加": "牙买加(JM)", + "约旦": "约旦(JO)", + "日本": "日本(JP)", + "肯尼亚": "肯尼亚(KE)", + "吉尔吉斯斯坦": "吉尔吉斯斯坦(KG)", + "柬埔寨": "柬埔寨(KH)", + "基里巴斯": "基里巴斯(KI)", + "科摩罗": "科摩罗(KM)", + "圣基茨和尼维斯": "圣基茨和尼维斯(KN)", + "朝鲜": "朝鲜(KP)", + "韩国": "韩国(KR)", + "科威特": "科威特(KW)", + "开曼群岛": "开曼群岛(KY)", + "哈萨克斯坦": "哈萨克斯坦(KZ)", + "老挝": "老挝(LA)", + "黎巴嫩": "黎巴嫩(LB)", + "圣卢西亚": "圣卢西亚(LC)", + "列支敦士登": "列支敦士登(LI)", + "斯里兰卡": "斯里兰卡(LK)", + "利比里亚": "利比里亚(LR)", + "莱索托": "莱索托(LS)", + "立陶宛": "立陶宛(LT)", + "卢森堡": "卢森堡(LU)", + "拉脱维亚": "拉脱维亚(LV)", + "利比亚": "利比亚(LY)", + "摩洛哥": "摩洛哥(MA)", + "摩纳哥": "摩纳哥(MC)", + "摩尔多瓦": "摩尔多瓦(MD)", + "黑山": "黑山(ME)", + "法属圣马丁": "法属圣马丁(MF)", + "马达加斯加": "马达加斯加(MG)", + "马绍尔群岛": "马绍尔群岛(MH)", + "北马其顿": "北马其顿(MK)", + "马里": "马里(ML)", + "缅甸": "缅甸(MM)", + "蒙古国": "蒙古国(MN)", + "澳门": "澳门(MO)", + "北马里亚纳群岛": "北马里亚纳群岛(MP)", + "马提尼克": "马提尼克(MQ)", + "毛里塔尼亚": "毛里塔尼亚(MR)", + "蒙特塞拉特": "蒙特塞拉特(MS)", + "马耳他": "马耳他(MT)", + "毛里求斯": "毛里求斯(MU)", + "马尔代夫": "马尔代夫(MV)", + "马拉维": "马拉维(MW)", + "墨西哥": "墨西哥(MX)", + "马来西亚": "马来西亚(MY)", + "莫桑比克": "莫桑比克(MZ)", + "纳米比亚": "纳米比亚(NA)", + "新喀里多尼亚": "新喀里多尼亚(NC)", + "尼日尔": "尼日尔(NE)", + "诺福克岛": "诺福克岛(NF)", + "尼日利亚": "尼日利亚(NG)", + "尼加拉瓜": "尼加拉瓜(NI)", + "荷兰": "荷兰(NL)", + "挪威": "挪威(NO)", + "尼泊尔": "尼泊尔(NP)", + "瑙鲁": "瑙鲁(NR)", + "纽埃": "纽埃(NU)", + "新西兰": "新西兰(NZ)", + "阿曼": "阿曼(OM)", + "巴拿马": "巴拿马(PA)", + "秘鲁": "秘鲁(PE)", + "法属波利尼西亚": "法属波利尼西亚(PF)", + "巴布亚新几内亚": "巴布亚新几内亚(PG)", + "菲律宾": "菲律宾(PH)", + "巴基斯坦": "巴基斯坦(PK)", + "波兰": "波兰(PL)", + "圣皮埃尔和密克隆": "圣皮埃尔和密克隆(PM)", + "皮特凯恩群岛": "皮特凯恩群岛(PN)", + "波多黎各": "波多黎各(PR)", + "巴勒斯坦国|巴勒斯坦": "巴勒斯坦国|巴勒斯坦(PS)", + "葡萄牙": "葡萄牙(PT)", + "帕劳": "帕劳(PW)", + "巴拉圭": "巴拉圭(PY)", + "卡塔尔": "卡塔尔(QA)", + "留尼旺": "留尼旺(RE)", + "罗马尼亚": "罗马尼亚(RO)", + "塞尔维亚": "塞尔维亚(RS)", + "俄罗斯": "俄罗斯(RU)", + "卢旺达": "卢旺达(RW)", + "沙特阿拉伯": "沙特阿拉伯(SA)", + "所罗门群岛": "所罗门群岛(SB)", + "塞舌尔": "塞舌尔(SC)", + "苏丹": "苏丹(SD)", + "瑞典": "瑞典(SE)", + "新加坡": "新加坡(SG)", + "圣赫勒拿": "圣赫勒拿(SH)", + "斯洛文尼亚": "斯洛文尼亚(SI)", + "斯瓦尔巴和扬马延": "斯瓦尔巴和扬马延(SJ)", + "斯洛伐克": "斯洛伐克(SK)", + "塞拉利昂": "塞拉利昂(SL)", + "圣马力诺": "圣马力诺(SM)", + "塞内加尔": "塞内加尔(SN)", + "索马里": "索马里(SO)", + "苏里南": "苏里南(SR)", + "南苏丹": "南苏丹(SS)", + "圣多美和普林西比": "圣多美和普林西比(ST)", + "萨尔瓦多": "萨尔瓦多(SV)", + "荷属圣马丁": "荷属圣马丁(SX)", + "叙利亚": "叙利亚(SY)", + "斯威士兰": "斯威士兰(SZ)", + "特里斯坦-达库尼亚": "特里斯坦-达库尼亚(TA)", + "特克斯和凯科斯群岛": "特克斯和凯科斯群岛(TC)", + "乍得": "乍得(TD)", + "法属南部和南极领地": "法属南部和南极领地(TF)", + "多哥": "多哥(TG)", + "泰国": "泰国(TH)", + "塔吉克斯坦": "塔吉克斯坦(TJ)", + "托克劳": "托克劳(TK)", + "东帝汶": "东帝汶(TL)", + "土库曼斯坦": "土库曼斯坦(TM)", + "突尼斯": "突尼斯(TN)", + "汤加": "汤加(TO)", + "土耳其": "土耳其(TR)", + "特立尼达和多巴哥": "特立尼达和多巴哥(TT)", + "图瓦卢": "图瓦卢(TV)", + "台湾": "台湾(TW)", + "坦桑尼亚": "坦桑尼亚(TZ)", + "乌克兰": "乌克兰(UA)", + "乌干达": "乌干达(UG)", + "美国本土外小岛屿": "美国本土外小岛屿(UM)", + "联合国": "联合国(UN)", + "美国": "美国(US)", + "乌拉圭": "乌拉圭(UY)", + "乌兹别克斯坦": "乌兹别克斯坦(UZ)", + "梵蒂冈": "梵蒂冈(VA)", + "圣文森特和格林纳丁斯": "圣文森特和格林纳丁斯(VC)", + "委内瑞拉": "委内瑞拉(VE)", + "英属维尔京群岛": "英属维尔京群岛(VG)", + "美属维尔京群岛": "美属维尔京群岛(VI)", + "越南": "越南(VN)", + "瓦努阿图": "瓦努阿图(VU)", + "瓦利斯和富图纳": "瓦利斯和富图纳(WF)", + "萨摩亚": "萨摩亚(WS)", + "科索沃": "科索沃(XK)", + "也门": "也门(YE)", + "马约特": "马约特(YT)", + "南非": "南非(ZA)", + "赞比亚": "赞比亚(ZM)", + "津巴布韦": "津巴布韦(ZW)", +} + +var CountryFlag = map[string]string{ + "🇦🇨": "阿森松岛(AC)", + "🇦🇩": "安道尔(AD)", + "🇦🇪": "阿联酋(AE)", + "🇦🇫": "阿富汗(AF)", + "🇦🇬": "安提瓜和巴布达(AG)", + "🇦🇮": "安圭拉(AI)", + "🇦🇱": "阿尔巴尼亚(AL)", + "🇦🇲": "亚美尼亚(AM)", + "🇦🇴": "安哥拉(AO)", + "🇦🇶": "南极洲(AQ)", + "🇦🇷": "阿根廷(AR)", + "🇦🇸": "美属萨摩亚(AS)", + "🇦🇹": "奥地利(AT)", + "🇦🇺": "澳大利亚(AU)", + "🇦🇼": "阿鲁巴(AW)", + "🇦🇽": "奥兰(AX)", + "🇦🇿": "阿塞拜疆(AZ)", + "🇧🇦": "波黑(BA)", + "🇧🇧": "巴巴多斯(BB)", + "🇧🇩": "孟加拉国(BD)", + "🇧🇪": "比利时(BE)", + "🇧🇫": "布基纳法索(BF)", + "🇧🇬": "保加利亚(BG)", + "🇧🇭": "巴林(BH)", + "🇧🇮": "布隆迪(BI)", + "🇧🇯": "贝宁(BJ)", + "🇧🇱": "圣巴泰勒米(BL)", + "🇧🇲": "百慕大(BM)", + "🇧🇳": "文莱(BN)", + "🇧🇴": "玻利维亚(BO)", + "🇧🇶": "荷兰加勒比区(BQ)", + "🇧🇷": "巴西(BR)", + "🇧🇸": "巴哈马(BS)", + "🇧🇹": "不丹(BT)", + "🇧🇻": "布韦岛(BV)", + "🇧🇼": "博茨瓦纳(BW)", + "🇧🇾": "白俄罗斯(BY)", + "🇧🇿": "伯利兹(BZ)", + "🇨🇦": "加拿大(CA)", + "🇨🇨": "科科斯(基林)群岛(CC)", + "🇨🇩": "刚果民主共和国(CD)", + "🇨🇫": "中非(CF)", + "🇨🇬": "刚果共和国(CG)", + "🇨🇭": "瑞士(CH)", + "🇨🇮": "科特迪瓦(CI)", + "🇨🇰": "库克群岛(CK)", + "🇨🇱": "智利(CL)", + "🇨🇲": "喀麦隆(CM)", + "🇨🇳": "中国(CN)", + "🇨🇴": "哥伦比亚(CO)", + "🇨🇵": "克利珀顿岛(CP)", + "🇨🇷": "哥斯达黎加(CR)", + "🇨🇺": "古巴(CU)", + "🇨🇻": "佛得角(CV)", + "🇨🇼": "库拉索(CW)", + "🇨🇽": "圣诞岛(CX)", + "🇨🇾": "塞浦路斯(CY)", + "🇨🇿": "捷克(CZ)", + "🇩🇪": "德国(DE)", + "🇩🇬": "迪戈加西亚岛(DG)", + "🇩🇯": "吉布提(DJ)", + "🇩🇰": "丹麦(DK)", + "🇩🇲": "多米尼克(DM)", + "🇩🇴": "多米尼加(DO)", + "🇩🇿": "阿尔及利亚(DZ)", + "🇪🇦": "休达(EA)", + "🇪🇨": "厄瓜多尔(EC)", + "🇪🇪": "爱沙尼亚(EE)", + "🇪🇬": "埃及(EG)", + "🇪🇭": "西撒哈拉(EH)", + "🇪🇷": "厄立特里亚(ER)", + "🇪🇸": "西班牙(ES)", + "🇪🇹": "埃塞俄比亚(ET)", + "🇪🇺": "欧盟(EU)", + "🇫🇮": "芬兰(FI)", + "🇫🇯": "斐济(FJ)", + "🇫🇰": "福克兰群岛(FK)", + "🇫🇲": "密克罗尼西亚联邦(FM)", + "🇫🇴": "法罗群岛(FO)", + "🇫🇷": "法国(FR)", + "🇬🇦": "加蓬(GA)", + "🇺🇰": "英国(UK)", + "🇬🇧": "英国(UK)", + "🇬🇩": "格林纳达(GD)", + "🇬🇪": "格鲁吉亚(GE)", + "🇬🇫": "法属圭亚那(GF)", + "🇬🇬": "根西(GG)", + "🇬🇭": "加纳(GH)", + "🇬🇮": "直布罗陀(GI)", + "🇬🇱": "格陵兰(GL)", + "🇬🇲": "冈比亚(GM)", + "🇬🇳": "几内亚(GN)", + "🇬🇵": "瓜德罗普(GP)", + "🇬🇶": "赤道几内亚(GQ)", + "🇬🇷": "希腊(GR)", + "🇬🇸": "南乔治亚和南桑威奇群岛(GS)", + "🇬🇹": "危地马拉(GT)", + "🇬🇺": "关岛(GU)", + "🇬🇼": "几内亚比绍(GW)", + "🇬🇾": "圭亚那(GY)", + "🇭🇰": "香港(HK)", + "🇭🇲": "赫德岛和麦克唐纳群岛(HM)", + "🇭🇳": "洪都拉斯(HN)", + "🇭🇷": "克罗地亚(HR)", + "🇭🇹": "海地(HT)", + "🇭🇺": "匈牙利(HU)", + "🇮🇨": "加纳利群岛(IC)", + "🇮🇩": "印尼(ID)", + "🇮🇪": "爱尔兰(IE)", + "🇮🇱": "以色列(IL)", + "🇮🇲": "马恩岛(IM)", + "🇮🇳": "印度(IN)", + "🇮🇴": "英属印度洋领地(IO)", + "🇮🇶": "伊拉克(IQ)", + "🇮🇷": "伊朗(IR)", + "🇮🇸": "冰岛(IS)", + "🇮🇹": "意大利(IT)", + "🇯🇪": "泽西(JE)", + "🇯🇲": "牙买加(JM)", + "🇯🇴": "约旦(JO)", + "🇯🇵": "日本(JP)", + "🇰🇪": "肯尼亚(KE)", + "🇰🇬": "吉尔吉斯斯坦(KG)", + "🇰🇭": "柬埔寨(KH)", + "🇰🇮": "基里巴斯(KI)", + "🇰🇲": "科摩罗(KM)", + "🇰🇳": "圣基茨和尼维斯(KN)", + "🇰🇵": "朝鲜(KP)", + "🇰🇷": "韩国(KR)", + "🇰🇼": "科威特(KW)", + "🇰🇾": "开曼群岛(KY)", + "🇰🇿": "哈萨克斯坦(KZ)", + "🇱🇦": "老挝(LA)", + "🇱🇧": "黎巴嫩(LB)", + "🇱🇨": "圣卢西亚(LC)", + "🇱🇮": "列支敦士登(LI)", + "🇱🇰": "斯里兰卡(LK)", + "🇱🇷": "利比里亚(LR)", + "🇱🇸": "莱索托(LS)", + "🇱🇹": "立陶宛(LT)", + "🇱🇺": "卢森堡(LU)", + "🇱🇻": "拉脱维亚(LV)", + "🇱🇾": "利比亚(LY)", + "🇲🇦": "摩洛哥(MA)", + "🇲🇨": "摩纳哥(MC)", + "🇲🇩": "摩尔多瓦(MD)", + "🇲🇪": "黑山(ME)", + "🇲🇫": "法属圣马丁(MF)", + "🇲🇬": "马达加斯加(MG)", + "🇲🇭": "马绍尔群岛(MH)", + "🇲🇰": "北马其顿(MK)", + "🇲🇱": "马里(ML)", + "🇲🇲": "缅甸(MM)", + "🇲🇳": "蒙古国(MN)", + "🇲🇴": "澳门(MO)", + "🇲🇵": "北马里亚纳群岛(MP)", + "🇲🇶": "马提尼克(MQ)", + "🇲🇷": "毛里塔尼亚(MR)", + "🇲🇸": "蒙特塞拉特(MS)", + "🇲🇹": "马耳他(MT)", + "🇲🇺": "毛里求斯(MU)", + "🇲🇻": "马尔代夫(MV)", + "🇲🇼": "马拉维(MW)", + "🇲🇽": "墨西哥(MX)", + "🇲🇾": "马来西亚(MY)", + "🇲🇿": "莫桑比克(MZ)", + "🇳🇦": "纳米比亚(NA)", + "🇳🇨": "新喀里多尼亚(NC)", + "🇳🇪": "尼日尔(NE)", + "🇳🇫": "诺福克岛(NF)", + "🇳🇬": "尼日利亚(NG)", + "🇳🇮": "尼加拉瓜(NI)", + "🇳🇱": "荷兰(NL)", + "🇳🇴": "挪威(NO)", + "🇳🇵": "尼泊尔(NP)", + "🇳🇷": "瑙鲁(NR)", + "🇳🇺": "纽埃(NU)", + "🇳🇿": "新西兰(NZ)", + "🇴🇲": "阿曼(OM)", + "🇵🇦": "巴拿马(PA)", + "🇵🇪": "秘鲁(PE)", + "🇵🇫": "法属波利尼西亚(PF)", + "🇵🇬": "巴布亚新几内亚(PG)", + "🇵🇭": "菲律宾(PH)", + "🇵🇰": "巴基斯坦(PK)", + "🇵🇱": "波兰(PL)", + "🇵🇲": "圣皮埃尔和密克隆(PM)", + "🇵🇳": "皮特凯恩群岛(PN)", + "🇵🇷": "波多黎各(PR)", + "🇵🇸": "巴勒斯坦国|巴勒斯坦(PS)", + "🇵🇹": "葡萄牙(PT)", + "🇵🇼": "帕劳(PW)", + "🇵🇾": "巴拉圭(PY)", + "🇶🇦": "卡塔尔(QA)", + "🇷🇪": "留尼旺(RE)", + "🇷🇴": "罗马尼亚(RO)", + "🇷🇸": "塞尔维亚(RS)", + "🇷🇺": "俄罗斯(RU)", + "🇷🇼": "卢旺达(RW)", + "🇸🇦": "沙特阿拉伯(SA)", + "🇸🇧": "所罗门群岛(SB)", + "🇸🇨": "塞舌尔(SC)", + "🇸🇩": "苏丹(SD)", + "🇸🇪": "瑞典(SE)", + "🇸🇬": "新加坡(SG)", + "🇸🇭": "圣赫勒拿(SH)", + "🇸🇮": "斯洛文尼亚(SI)", + "🇸🇯": "斯瓦尔巴和扬马延(SJ)", + "🇸🇰": "斯洛伐克(SK)", + "🇸🇱": "塞拉利昂(SL)", + "🇸🇲": "圣马力诺(SM)", + "🇸🇳": "塞内加尔(SN)", + "🇸🇴": "索马里(SO)", + "🇸🇷": "苏里南(SR)", + "🇸🇸": "南苏丹(SS)", + "🇸🇹": "圣多美和普林西比(ST)", + "🇸🇻": "萨尔瓦多(SV)", + "🇸🇽": "荷属圣马丁(SX)", + "🇸🇾": "叙利亚(SY)", + "🇸🇿": "斯威士兰(SZ)", + "🇹🇦": "特里斯坦-达库尼亚(TA)", + "🇹🇨": "特克斯和凯科斯群岛(TC)", + "🇹🇩": "乍得(TD)", + "🇹🇫": "法属南部和南极领地(TF)", + "🇹🇬": "多哥(TG)", + "🇹🇭": "泰国(TH)", + "🇹🇯": "塔吉克斯坦(TJ)", + "🇹🇰": "托克劳(TK)", + "🇹🇱": "东帝汶(TL)", + "🇹🇲": "土库曼斯坦(TM)", + "🇹🇳": "突尼斯(TN)", + "🇹🇴": "汤加(TO)", + "🇹🇷": "土耳其(TR)", + "🇹🇹": "特立尼达和多巴哥(TT)", + "🇹🇻": "图瓦卢(TV)", + "🇹🇼": "台湾(TW)", + "🇹🇿": "坦桑尼亚(TZ)", + "🇺🇦": "乌克兰(UA)", + "🇺🇬": "乌干达(UG)", + "🇺🇲": "美国本土外小岛屿(UM)", + "🇺🇳": "联合国(UN)", + "🇺🇸": "美国(US)", + "🇺🇾": "乌拉圭(UY)", + "🇺🇿": "乌兹别克斯坦(UZ)", + "🇻🇦": "梵蒂冈(VA)", + "🇻🇨": "圣文森特和格林纳丁斯(VC)", + "🇻🇪": "委内瑞拉(VE)", + "🇻🇬": "英属维尔京群岛(VG)", + "🇻🇮": "美属维尔京群岛(VI)", + "🇻🇳": "越南(VN)", + "🇻🇺": "瓦努阿图(VU)", + "🇼🇫": "瓦利斯和富图纳(WF)", + "🇼🇸": "萨摩亚(WS)", + "🇽🇰": "科索沃(XK)", + "🇾🇪": "也门(YE)", + "🇾🇹": "马约特(YT)", + "🇿🇦": "南非(ZA)", + "🇿🇲": "赞比亚(ZM)", + "🇿🇼": "津巴布韦(ZW)", +} + +var CountryISO = map[string]string{ + "AC": "阿森松岛(AC)", + "AD": "安道尔(AD)", + "AE": "阿联酋(AE)", + "AF": "阿富汗(AF)", + "AG": "安提瓜和巴布达(AG)", + "AI": "安圭拉(AI)", + "AL": "阿尔巴尼亚(AL)", + "AM": "亚美尼亚(AM)", + "AO": "安哥拉(AO)", + "AQ": "南极洲(AQ)", + "AR": "阿根廷(AR)", + "AS": "美属萨摩亚(AS)", + "AT": "奥地利(AT)", + "AU": "澳大利亚(AU)", + "AW": "阿鲁巴(AW)", + "AX": "奥兰(AX)", + "AZ": "阿塞拜疆(AZ)", + "BA": "波黑(BA)", + "BB": "巴巴多斯(BB)", + "BD": "孟加拉国(BD)", + "BE": "比利时(BE)", + "BF": "布基纳法索(BF)", + "BG": "保加利亚(BG)", + "BH": "巴林(BH)", + "BI": "布隆迪(BI)", + "BJ": "贝宁(BJ)", + "BL": "圣巴泰勒米(BL)", + "BM": "百慕大(BM)", + "BN": "文莱(BN)", + "BO": "玻利维亚(BO)", + "BQ": "荷兰加勒比区(BQ)", + "BR": "巴西(BR)", + "BS": "巴哈马(BS)", + "BT": "不丹(BT)", + "BV": "布韦岛(BV)", + "BW": "博茨瓦纳(BW)", + "BY": "白俄罗斯(BY)", + "BZ": "伯利兹(BZ)", + "CA": "加拿大(CA)", + "CC": "科科斯(基林)群岛(CC)", + "CD": "刚果民主共和国(CD)", + "CF": "中非(CF)", + "CG": "刚果共和国(CG)", + "CH": "瑞士(CH)", + "CI": "科特迪瓦(CI)", + "CK": "库克群岛(CK)", + "CL": "智利(CL)", + "CM": "喀麦隆(CM)", + "CN": "中国(CN)", + "CO": "哥伦比亚(CO)", + "CP": "克利珀顿岛(CP)", + "CR": "哥斯达黎加(CR)", + "CU": "古巴(CU)", + "CV": "佛得角(CV)", + "CW": "库拉索(CW)", + "CX": "圣诞岛(CX)", + "CY": "塞浦路斯(CY)", + "CZ": "捷克(CZ)", + "DE": "德国(DE)", + "DG": "迪戈加西亚岛(DG)", + "DJ": "吉布提(DJ)", + "DK": "丹麦(DK)", + "DM": "多米尼克(DM)", + "DO": "多米尼加(DO)", + "DZ": "阿尔及利亚(DZ)", + "EA": "休达(EA)", + "EC": "厄瓜多尔(EC)", + "EE": "爱沙尼亚(EE)", + "EG": "埃及(EG)", + "EH": "西撒哈拉(EH)", + "ER": "厄立特里亚(ER)", + "ES": "西班牙(ES)", + "ET": "埃塞俄比亚(ET)", + "EU": "欧盟(EU)", + "FI": "芬兰(FI)", + "FJ": "斐济(FJ)", + "FK": "福克兰群岛(FK)", + "FM": "密克罗尼西亚联邦(FM)", + "FO": "法罗群岛(FO)", + "FR": "法国(FR)", + "GA": "加蓬(GA)", + "UK": "英国(UK)", + "GD": "格林纳达(GD)", + "GE": "格鲁吉亚(GE)", + "GF": "法属圭亚那(GF)", + "GG": "根西(GG)", + "GH": "加纳(GH)", + "GI": "直布罗陀(GI)", + "GL": "格陵兰(GL)", + "GM": "冈比亚(GM)", + "GN": "几内亚(GN)", + "GP": "瓜德罗普(GP)", + "GQ": "赤道几内亚(GQ)", + "GR": "希腊(GR)", + "GS": "南乔治亚和南桑威奇群岛(GS)", + "GT": "危地马拉(GT)", + "GU": "关岛(GU)", + "GW": "几内亚比绍(GW)", + "GY": "圭亚那(GY)", + "HK": "香港(HK)", + "HM": "赫德岛和麦克唐纳群岛(HM)", + "HN": "洪都拉斯(HN)", + "HR": "克罗地亚(HR)", + "HT": "海地(HT)", + "HU": "匈牙利(HU)", + "IC": "加纳利群岛(IC)", + "ID": "印尼(ID)", + "IE": "爱尔兰(IE)", + "IL": "以色列(IL)", + "IM": "马恩岛(IM)", + "IN": "印度(IN)", + "IO": "英属印度洋领地(IO)", + "IQ": "伊拉克(IQ)", + "IR": "伊朗(IR)", + "IS": "冰岛(IS)", + "IT": "意大利(IT)", + "JE": "泽西(JE)", + "JM": "牙买加(JM)", + "JO": "约旦(JO)", + "JP": "日本(JP)", + "KE": "肯尼亚(KE)", + "KG": "吉尔吉斯斯坦(KG)", + "KH": "柬埔寨(KH)", + "KI": "基里巴斯(KI)", + "KM": "科摩罗(KM)", + "KN": "圣基茨和尼维斯(KN)", + "KP": "朝鲜(KP)", + "KR": "韩国(KR)", + "KW": "科威特(KW)", + "KY": "开曼群岛(KY)", + "KZ": "哈萨克斯坦(KZ)", + "LA": "老挝(LA)", + "LB": "黎巴嫩(LB)", + "LC": "圣卢西亚(LC)", + "LI": "列支敦士登(LI)", + "LK": "斯里兰卡(LK)", + "LR": "利比里亚(LR)", + "LS": "莱索托(LS)", + "LT": "立陶宛(LT)", + "LU": "卢森堡(LU)", + "LV": "拉脱维亚(LV)", + "LY": "利比亚(LY)", + "MA": "摩洛哥(MA)", + "MC": "摩纳哥(MC)", + "MD": "摩尔多瓦(MD)", + "ME": "黑山(ME)", + "MF": "法属圣马丁(MF)", + "MG": "马达加斯加(MG)", + "MH": "马绍尔群岛(MH)", + "MK": "北马其顿(MK)", + "ML": "马里(ML)", + "MM": "缅甸(MM)", + "MN": "蒙古国(MN)", + "MO": "澳门(MO)", + "MP": "北马里亚纳群岛(MP)", + "MQ": "马提尼克(MQ)", + "MR": "毛里塔尼亚(MR)", + "MS": "蒙特塞拉特(MS)", + "MT": "马耳他(MT)", + "MU": "毛里求斯(MU)", + "MV": "马尔代夫(MV)", + "MW": "马拉维(MW)", + "MX": "墨西哥(MX)", + "MY": "马来西亚(MY)", + "MZ": "莫桑比克(MZ)", + "NA": "纳米比亚(NA)", + "NC": "新喀里多尼亚(NC)", + "NE": "尼日尔(NE)", + "NF": "诺福克岛(NF)", + "NG": "尼日利亚(NG)", + "NI": "尼加拉瓜(NI)", + "NL": "荷兰(NL)", + "NO": "挪威(NO)", + "NP": "尼泊尔(NP)", + "NR": "瑙鲁(NR)", + "NU": "纽埃(NU)", + "NZ": "新西兰(NZ)", + "OM": "阿曼(OM)", + "PA": "巴拿马(PA)", + "PE": "秘鲁(PE)", + "PF": "法属波利尼西亚(PF)", + "PG": "巴布亚新几内亚(PG)", + "PH": "菲律宾(PH)", + "PK": "巴基斯坦(PK)", + "PL": "波兰(PL)", + "PM": "圣皮埃尔和密克隆(PM)", + "PN": "皮特凯恩群岛(PN)", + "PR": "波多黎各(PR)", + "PS": "巴勒斯坦国|巴勒斯坦(PS)", + "PT": "葡萄牙(PT)", + "PW": "帕劳(PW)", + "PY": "巴拉圭(PY)", + "QA": "卡塔尔(QA)", + "RE": "留尼旺(RE)", + "RO": "罗马尼亚(RO)", + "RS": "塞尔维亚(RS)", + "RU": "俄罗斯(RU)", + "RW": "卢旺达(RW)", + "SA": "沙特阿拉伯(SA)", + "SB": "所罗门群岛(SB)", + "SC": "塞舌尔(SC)", + "SD": "苏丹(SD)", + "SE": "瑞典(SE)", + "SG": "新加坡(SG)", + "SH": "圣赫勒拿(SH)", + "SI": "斯洛文尼亚(SI)", + "SJ": "斯瓦尔巴和扬马延(SJ)", + "SK": "斯洛伐克(SK)", + "SL": "塞拉利昂(SL)", + "SM": "圣马力诺(SM)", + "SN": "塞内加尔(SN)", + "SO": "索马里(SO)", + "SR": "苏里南(SR)", + "SS": "南苏丹(SS)", + "ST": "圣多美和普林西比(ST)", + "SV": "萨尔瓦多(SV)", + "SX": "荷属圣马丁(SX)", + "SY": "叙利亚(SY)", + "SZ": "斯威士兰(SZ)", + "TA": "特里斯坦-达库尼亚(TA)", + "TC": "特克斯和凯科斯群岛(TC)", + "TD": "乍得(TD)", + "TF": "法属南部和南极领地(TF)", + "TG": "多哥(TG)", + "TH": "泰国(TH)", + "TJ": "塔吉克斯坦(TJ)", + "TK": "托克劳(TK)", + "TL": "东帝汶(TL)", + "TM": "土库曼斯坦(TM)", + "TN": "突尼斯(TN)", + "TO": "汤加(TO)", + "TR": "土耳其(TR)", + "TT": "特立尼达和多巴哥(TT)", + "TV": "图瓦卢(TV)", + "TW": "台湾(TW)", + "TZ": "坦桑尼亚(TZ)", + "UA": "乌克兰(UA)", + "UG": "乌干达(UG)", + "UM": "美国本土外小岛屿(UM)", + "UN": "联合国(UN)", + "US": "美国(US)", + "UY": "乌拉圭(UY)", + "UZ": "乌兹别克斯坦(UZ)", + "VA": "梵蒂冈(VA)", + "VC": "圣文森特和格林纳丁斯(VC)", + "VE": "委内瑞拉(VE)", + "VG": "英属维尔京群岛(VG)", + "VI": "美属维尔京群岛(VI)", + "VN": "越南(VN)", + "VU": "瓦努阿图(VU)", + "WF": "瓦利斯和富图纳(WF)", + "WS": "萨摩亚(WS)", + "XK": "科索沃(XK)", + "YE": "也门(YE)", + "YT": "马约特(YT)", + "ZA": "南非(ZA)", + "ZM": "赞比亚(ZM)", + "ZW": "津巴布韦(ZW)", +} diff --git a/pkg/util/convert.go b/pkg/util/convert.go index acf227d..eb4d3bf 100644 --- a/pkg/util/convert.go +++ b/pkg/util/convert.go @@ -7,6 +7,7 @@ import ( "io" "net/http" "os" + "path/filepath" "regexp" "strings" @@ -97,6 +98,11 @@ func Convert(subscriptions []string, proxies []string, template string, delete s } func MergeTemplate(proxies []model.Proxy, template string) (string, error) { + if !strings.Contains(template, string(filepath.Separator)) { + if _, err := os.Stat(template); os.IsNotExist(err) { + template = filepath.Join("templates", template) + } + } config, err := ReadTemplate(template) proxyTags := make([]string, 0) if err != nil { @@ -115,19 +121,18 @@ func MergeTemplate(proxies []model.Proxy, template string) (string, error) { return "", err } for i, outbound := range config.Outbounds { - if outbound.Type == "urltest" || outbound.Type == "selector" { - var parsedOutbound []string = make([]string, 0) - for _, o := range outbound.Outbounds { - if o == "" { - parsedOutbound = append(parsedOutbound, proxyTags...) - } else { - parsedOutbound = append(parsedOutbound, o) - } + var parsedOutbound []string = make([]string, 0) + for _, o := range outbound.Outbounds { + if o == "" { + parsedOutbound = append(parsedOutbound, proxyTags...) + } else { + parsedOutbound = append(parsedOutbound, o) } - config.Outbounds[i].Outbounds = parsedOutbound } + config.Outbounds[i].Outbounds = parsedOutbound } config.Outbounds = append(config.Outbounds, newOutbounds...) + //TODO: 国家策略组 data, err := json.Marshal(config) if err != nil { return "", err @@ -257,3 +262,20 @@ func RenameProxy(proxies []model.Proxy, regex string, replaceText string) ([]mod } return proxies, nil } + +func GetContryName(proxyName string) string { + countryMaps := []map[string]string{ + model.CountryFlag, + model.CountryChineseName, + model.CountryISO, + model.CountryEnglishName, + } + for _, countryMap := range countryMaps { + for k, v := range countryMap { + if strings.Contains(proxyName, k) { + return v + } + } + } + return "其他地区" +} diff --git a/template/tun-fakeip-with-dns-leaks.json b/templates/tun-fakeip-with-dns-leaks.json similarity index 100% rename from template/tun-fakeip-with-dns-leaks.json rename to templates/tun-fakeip-with-dns-leaks.json diff --git a/template/tun-fakeip-without-dns-leaks.json b/templates/tun-fakeip-without-dns-leaks.json similarity index 100% rename from template/tun-fakeip-without-dns-leaks.json rename to templates/tun-fakeip-without-dns-leaks.json diff --git a/template/tun-with-dns-leaks.json b/templates/tun-with-dns-leaks.json similarity index 100% rename from template/tun-with-dns-leaks.json rename to templates/tun-with-dns-leaks.json diff --git a/template/tun-without-dns-leaks.json b/templates/tun-without-dns-leaks.json similarity index 100% rename from template/tun-without-dns-leaks.json rename to templates/tun-without-dns-leaks.json