diff --git a/README.md b/README.md index 86f61d79..21c20288 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,6 @@ Notes: You can use my demo for free, and you can also deploy it yourself. -[![Deploy with Vercel](https://raw.githubusercontent.com/jason5ng32/MyIP/main/public/github/Vercel.svg)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fjason5ng32%2FMyIP&project-name=MyIP&repository-name=MyIP) [![Deploy with Docker](https://raw.githubusercontent.com/jason5ng32/MyIP/main/public/github/Docker.svg)](https://hub.docker.com/r/jason5ng32/myip) ## 👀 Main Features @@ -50,8 +49,6 @@ Notes: You can use my demo for free, and you can also deploy it yourself. ## 📕 How to Use -There are 3 Ways to deploy: - ### Deploying in a Node Environment Make sure you have Node.js installed. @@ -62,16 +59,10 @@ Clone the code: git clone https://github.com/jason5ng32/MyIP.git ``` -Install: - -```bash -npm install -``` - -Build: +Install and build: ```bash -npm run build +npm install && npm run build ``` Run: @@ -82,10 +73,6 @@ npm start The program will run on port 18966. -### Using Vercel - -Click the 'Deploy to Vercel' button at the top to complete the deployment. Note that some features are not available on Vercel (see the environment variable section for details). - ### Using Docker Click the 'Deploy to Docker' button at the top to complete the deployment. Or, use the following shell: @@ -113,10 +100,6 @@ You can use the program without adding any environment variables, but if you wan | `KEYCDN_USER_AGENT` | No | `""` | The domain name when using KeyCDN, must contain https prefix. Used to obtain IP address information through KeyCDN | | `CLOUDFLARE_API` | No | `""` | API Key for Cloudflare, used to obtain AS system information through Cloudflare | -> [!TIP] -> Environment variables starting with `SECURITY_` are only valid when deploying using npm or Docker. -> - ### Using Environment Variables in a Node Environment Create environment variables: @@ -137,10 +120,6 @@ IPCHECKING_API="YOUR_KEY_HERE" Then restart the backend service. -### Using Environment Variables in Vercel - -Please refer to the content in `.env.example` and add it to the environment variables in Vercel. - ### Using Environment Variables in Docker You can add environment variables when running Docker, for example: diff --git a/README_FR.md b/README_FR.md index ad8496ab..023124e7 100644 --- a/README_FR.md +++ b/README_FR.md @@ -23,7 +23,6 @@ Notes: Vous pouvez utiliser ma démo gratuitement et vous pouvez également la déployer vous-même. -[![Deploy with Vercel](https://raw.githubusercontent.com/jason5ng32/MyIP/main/public/github/Vercel.svg)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fjason5ng32%2FMyIP&project-name=MyIP&repository-name=MyIP) [![Deploy with Docker](https://raw.githubusercontent.com/jason5ng32/MyIP/main/public/github/Docker.svg)](https://hub.docker.com/r/jason5ng32/myip) ## 👀 Principales fonctionnalités @@ -50,8 +49,6 @@ Notes: Vous pouvez utiliser ma démo gratuitement et vous pouvez également la d ## 📕 Comment utiliser -Il existe 3 façons de déployer : - ### Déploiement dans un environnement Node Assurez-vous d'avoir Node.js installé. @@ -62,16 +59,10 @@ Clonez le code : git clone https://github.com/jason5ng32/MyIP.git ``` -Installer: - -```bash -npm install -``` - -Construire: +Installer & Construire : ```bash -npm run build +npm install && npm run build ``` Exécuter: @@ -82,10 +73,6 @@ npm start Le programme s'exécutera sur le port 18966. -### Using Vercel - -Cliquez sur le bouton 'Déployer sur Vercel' en haut pour terminer le déploiement. Veuillez noter que certaines fonctionnalités ne sont pas disponibles sur Vercel (voir la section des variables d'environnement pour plus de détails). - ### Using Docker Cliquez sur le bouton 'Déployer sur Docker' en haut pour terminer le déploiement. Ou utilisez le shell suivant : @@ -113,10 +100,6 @@ Vous pouvez utiliser le programme sans ajouter de variables d'environnement, mai | `KEYCDN_USER_AGENT` | Non | `""` | Le nom de domaine lorsque vous utilisez KeyCDN, doit contenir le préfixe https. Utilisé pour obtenir des informations sur l'adresse IP via KeyCDN | | `CLOUDFLARE_API` | Non | `""` | Clé API pour Cloudflare, utilisée pour obtenir des informations sur le système AS via Cloudflare | -> [!TIP] -> Les variables d'environnement commençant par `SECURITY_` ne sont valides que lors du déploiement à l'aide de npm ou de Docker. -> - ### Utilisation des variables d'environnement dans un environnement Node Créez les variables d'environnement : @@ -137,10 +120,6 @@ IPCHECKING_API="YOUR_KEY_HERE" Ensuite, redémarrez le service backend. -### Utilisation des variables d'environnement dans Vercel - -Veuillez vous référer au contenu de `.env.example` et ajoutez-le aux variables d'environnement dans Vercel. - ### Utilisation des variables d'environnement dans Docker Vous pouvez ajouter des variables d'environnement lors de l'exécution de Docker, par exemple : diff --git a/README_ZH.md b/README_ZH.md index ea6253d4..ce0c3e0c 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -23,7 +23,6 @@ 备注:你可以直接用我已经搭建好的服务,也可以自行搭建。 -[![Deploy with Vercel](https://raw.githubusercontent.com/jason5ng32/MyIP/main/public/github/Vercel.svg)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fjason5ng32%2FMyIP&project-name=MyIP&repository-name=MyIP) [![Deploy with Docker](https://raw.githubusercontent.com/jason5ng32/MyIP/main/public/github/Docker.svg)](https://hub.docker.com/r/jason5ng32/myip) 这是我第一次用 Vue.js 练手的项目。我……只是一个普通的产品经理。 @@ -52,8 +51,6 @@ ## 📕 如何使用 -3 种部署方式: - ### 在 Node 环境部署 确保你系统里已经有 Node.js 环境。 @@ -64,16 +61,10 @@ git clone https://github.com/jason5ng32/MyIP.git ``` -安装: - -```bash -npm install -``` - -构建: +安装与编译: ```bash -npm run build +npm install && npm run build ``` 运行: @@ -84,10 +75,6 @@ npm start 程序会运行在 18966 端口。 -### 使用 Vercel - -点击顶部的部署到 Vercel 按钮,即可完成部署。需要注意的是,部分功能在 Vercel 上不可用(详见环境变量部分说明)。 - ### 使用 Docker 点击顶部的部署到 Docker 按钮,即可完成部署,又或者,直接输入下面的命令: @@ -115,10 +102,6 @@ docker run -d -p 18966:18966 --name myip --restart always jason5ng32/myip:latest | `KEYCDN_USER_AGENT` | 否 | `""` | 使用 KeyCDN 时的域名,需包含 https 前缀。用于通过 KeyCDN 获取 IP 归属地信息 | | `CLOUDFLARE_API` | 否 | `""` | Cloudflare 的 API Key,用于通过 Cloudflare 获取 AS 系统的信息 | -> [!TIP] -> 以 `SECURITY_` 开头的环境变量仅在使用 npm 或 Docker 部署时有效。 -> - ### 在 Node 环境里使用环境变量 创建环境变量: @@ -139,10 +122,6 @@ IPCHECKING_API="YOUR_KEY_HERE" 然后重新启动后端服务。 -### 在 Vercel 里使用环境变量 - -请参考 `.env.example` 里的内容,添加到 Vercel 的环境变量里。 - ### 在 Docker 里使用环境变量 你可以在运行 Docker 的时候,添加环境变量,比如: diff --git a/api/ipinfo.js b/api/ipinfo.js index b2298c44..f4ed8e67 100644 --- a/api/ipinfo.js +++ b/api/ipinfo.js @@ -1,257 +1,7 @@ import { get } from 'https'; import { isValidIP } from '../common/valid-ip.js'; import { refererCheck } from '../common/referer-check.js'; - -// 国家代码 -async function loadCountryCodes() { - const countryCodes = { - "AF": "Afghanistan", - "AX": "Åland Islands", - "AL": "Albania", - "DZ": "Algeria", - "AS": "American Samoa", - "AD": "AndorrA", - "AO": "Angola", - "AI": "Anguilla", - "AQ": "Antarctica", - "AG": "Antigua and Barbuda", - "AR": "Argentina", - "AM": "Armenia", - "AW": "Aruba", - "AU": "Australia", - "AT": "Austria", - "AZ": "Azerbaijan", - "BS": "Bahamas", - "BH": "Bahrain", - "BD": "Bangladesh", - "BB": "Barbados", - "BY": "Belarus", - "BE": "Belgium", - "BZ": "Belize", - "BJ": "Benin", - "BM": "Bermuda", - "BT": "Bhutan", - "BO": "Bolivia", - "BA": "Bosnia and Herzegovina", - "BW": "Botswana", - "BV": "Bouvet Island", - "BR": "Brazil", - "IO": "British Indian Ocean Territory", - "BN": "Brunei Darussalam", - "BG": "Bulgaria", - "BF": "Burkina Faso", - "BI": "Burundi", - "KH": "Cambodia", - "CM": "Cameroon", - "CA": "Canada", - "CV": "Cape Verde", - "KY": "Cayman Islands", - "CF": "Central African Republic", - "TD": "Chad", - "CL": "Chile", - "CN": "China", - "CX": "Christmas Island", - "CC": "Cocos (Keeling) Islands", - "CO": "Colombia", - "KM": "Comoros", - "CG": "Congo", - "CD": "Congo, The Democratic Republic of the", - "CK": "Cook Islands", - "CR": "Costa Rica", - "CI": "Cote D'Ivoire", - "HR": "Croatia", - "CU": "Cuba", - "CY": "Cyprus", - "CZ": "Czech Republic", - "DK": "Denmark", - "DJ": "Djibouti", - "DM": "Dominica", - "DO": "Dominican Republic", - "EC": "Ecuador", - "EG": "Egypt", - "SV": "El Salvador", - "GQ": "Equatorial Guinea", - "ER": "Eritrea", - "EE": "Estonia", - "ET": "Ethiopia", - "FK": "Falkland Islands (Malvinas)", - "FO": "Faroe Islands", - "FJ": "Fiji", - "FI": "Finland", - "FR": "France", - "GF": "French Guiana", - "PF": "French Polynesia", - "TF": "French Southern Territories", - "GA": "Gabon", - "GM": "Gambia", - "GE": "Georgia", - "DE": "Germany", - "GH": "Ghana", - "GI": "Gibraltar", - "GR": "Greece", - "GL": "Greenland", - "GD": "Grenada", - "GP": "Guadeloupe", - "GU": "Guam", - "GT": "Guatemala", - "GG": "Guernsey", - "GN": "Guinea", - "GW": "Guinea-Bissau", - "GY": "Guyana", - "HT": "Haiti", - "HM": "Heard Island and Mcdonald Islands", - "VA": "Holy See (Vatican City State)", - "HN": "Honduras", - "HK": "Hong Kong", - "HU": "Hungary", - "IS": "Iceland", - "IN": "India", - "ID": "Indonesia", - "IR": "Iran, Islamic Republic Of", - "IQ": "Iraq", - "IE": "Ireland", - "IM": "Isle of Man", - "IL": "Israel", - "IT": "Italy", - "JM": "Jamaica", - "JP": "Japan", - "JE": "Jersey", - "JO": "Jordan", - "KZ": "Kazakhstan", - "KE": "Kenya", - "KI": "Kiribati", - "KP": "Korea, Democratic People'S Republic of", - "KR": "Korea, Republic of", - "KW": "Kuwait", - "KG": "Kyrgyzstan", - "LA": "Lao People'S Democratic Republic", - "LV": "Latvia", - "LB": "Lebanon", - "LS": "Lesotho", - "LR": "Liberia", - "LY": "Libyan Arab Jamahiriya", - "LI": "Liechtenstein", - "LT": "Lithuania", - "LU": "Luxembourg", - "MO": "Macao", - "MK": "Macedonia, The Former Yugoslav Republic of", - "MG": "Madagascar", - "MW": "Malawi", - "MY": "Malaysia", - "MV": "Maldives", - "ML": "Mali", - "MT": "Malta", - "MH": "Marshall Islands", - "MQ": "Martinique", - "MR": "Mauritania", - "MU": "Mauritius", - "YT": "Mayotte", - "MX": "Mexico", - "FM": "Micronesia, Federated States of", - "MD": "Moldova, Republic of", - "MC": "Monaco", - "MN": "Mongolia", - "MS": "Montserrat", - "MA": "Morocco", - "MZ": "Mozambique", - "MM": "Myanmar", - "NA": "Namibia", - "NR": "Nauru", - "NP": "Nepal", - "NL": "Netherlands", - "AN": "Netherlands Antilles", - "NC": "New Caledonia", - "NZ": "New Zealand", - "NI": "Nicaragua", - "NE": "Niger", - "NG": "Nigeria", - "NU": "Niue", - "NF": "Norfolk Island", - "MP": "Northern Mariana Islands", - "NO": "Norway", - "OM": "Oman", - "PK": "Pakistan", - "PW": "Palau", - "PS": "Palestinian Territory, Occupied", - "PA": "Panama", - "PG": "Papua New Guinea", - "PY": "Paraguay", - "PE": "Peru", - "PH": "Philippines", - "PN": "Pitcairn", - "PL": "Poland", - "PT": "Portugal", - "PR": "Puerto Rico", - "QA": "Qatar", - "RE": "Reunion", - "RO": "Romania", - "RU": "Russian Federation", - "RW": "RWANDA", - "SH": "Saint Helena", - "KN": "Saint Kitts and Nevis", - "LC": "Saint Lucia", - "PM": "Saint Pierre and Miquelon", - "VC": "Saint Vincent and the Grenadines", - "WS": "Samoa", - "SM": "San Marino", - "ST": "Sao Tome and Principe", - "SA": "Saudi Arabia", - "SN": "Senegal", - "CS": "Serbia and Montenegro", - "SC": "Seychelles", - "SL": "Sierra Leone", - "SG": "Singapore", - "SK": "Slovakia", - "SI": "Slovenia", - "SB": "Solomon Islands", - "SO": "Somalia", - "ZA": "South Africa", - "GS": "South Georgia and the South Sandwich Islands", - "ES": "Spain", - "LK": "Sri Lanka", - "SD": "Sudan", - "SR": "Suriname", - "SJ": "Svalbard and Jan Mayen", - "SZ": "Swaziland", - "SE": "Sweden", - "CH": "Switzerland", - "SY": "Syrian Arab Republic", - "TW": "Taiwan", - "TJ": "Tajikistan", - "TZ": "Tanzania, United Republic of", - "TH": "Thailand", - "TL": "Timor-Leste", - "TG": "Togo", - "TK": "Tokelau", - "TO": "Tonga", - "TT": "Trinidad and Tobago", - "TN": "Tunisia", - "TR": "Turkey", - "TM": "Turkmenistan", - "TC": "Turks and Caicos Islands", - "TV": "Tuvalu", - "UG": "Uganda", - "UA": "Ukraine", - "AE": "United Arab Emirates", - "GB": "United Kingdom", - "US": "United States", - "UM": "United States Minor Outlying Islands", - "UY": "Uruguay", - "UZ": "Uzbekistan", - "VU": "Vanuatu", - "VE": "Venezuela", - "VN": "Viet Nam", - "VG": "Virgin Islands, British", - "VI": "Virgin Islands, U.S.", - "WF": "Wallis and Futuna", - "EH": "Western Sahara", - "YE": "Yemen", - "ZM": "Zambia", - "ZW": "Zimbabwe" - }; - - return countryCodes; -} +import { loadCountryCodes } from '../common/country-codes.js'; export default async (req, res) => { // 限制只能从指定域名访问 diff --git a/common/country-codes.js b/common/country-codes.js new file mode 100644 index 00000000..60a72119 --- /dev/null +++ b/common/country-codes.js @@ -0,0 +1,251 @@ +async function loadCountryCodes() { + const countryCodes = { + "AF": "Afghanistan", + "AX": "Åland Islands", + "AL": "Albania", + "DZ": "Algeria", + "AS": "American Samoa", + "AD": "AndorrA", + "AO": "Angola", + "AI": "Anguilla", + "AQ": "Antarctica", + "AG": "Antigua and Barbuda", + "AR": "Argentina", + "AM": "Armenia", + "AW": "Aruba", + "AU": "Australia", + "AT": "Austria", + "AZ": "Azerbaijan", + "BS": "Bahamas", + "BH": "Bahrain", + "BD": "Bangladesh", + "BB": "Barbados", + "BY": "Belarus", + "BE": "Belgium", + "BZ": "Belize", + "BJ": "Benin", + "BM": "Bermuda", + "BT": "Bhutan", + "BO": "Bolivia", + "BA": "Bosnia and Herzegovina", + "BW": "Botswana", + "BV": "Bouvet Island", + "BR": "Brazil", + "IO": "British Indian Ocean Territory", + "BN": "Brunei Darussalam", + "BG": "Bulgaria", + "BF": "Burkina Faso", + "BI": "Burundi", + "KH": "Cambodia", + "CM": "Cameroon", + "CA": "Canada", + "CV": "Cape Verde", + "KY": "Cayman Islands", + "CF": "Central African Republic", + "TD": "Chad", + "CL": "Chile", + "CN": "China", + "CX": "Christmas Island", + "CC": "Cocos (Keeling) Islands", + "CO": "Colombia", + "KM": "Comoros", + "CG": "Congo", + "CD": "Congo, The Democratic Republic of the", + "CK": "Cook Islands", + "CR": "Costa Rica", + "CI": "Cote D'Ivoire", + "HR": "Croatia", + "CU": "Cuba", + "CY": "Cyprus", + "CZ": "Czech Republic", + "DK": "Denmark", + "DJ": "Djibouti", + "DM": "Dominica", + "DO": "Dominican Republic", + "EC": "Ecuador", + "EG": "Egypt", + "SV": "El Salvador", + "GQ": "Equatorial Guinea", + "ER": "Eritrea", + "EE": "Estonia", + "ET": "Ethiopia", + "FK": "Falkland Islands (Malvinas)", + "FO": "Faroe Islands", + "FJ": "Fiji", + "FI": "Finland", + "FR": "France", + "GF": "French Guiana", + "PF": "French Polynesia", + "TF": "French Southern Territories", + "GA": "Gabon", + "GM": "Gambia", + "GE": "Georgia", + "DE": "Germany", + "GH": "Ghana", + "GI": "Gibraltar", + "GR": "Greece", + "GL": "Greenland", + "GD": "Grenada", + "GP": "Guadeloupe", + "GU": "Guam", + "GT": "Guatemala", + "GG": "Guernsey", + "GN": "Guinea", + "GW": "Guinea-Bissau", + "GY": "Guyana", + "HT": "Haiti", + "HM": "Heard Island and Mcdonald Islands", + "VA": "Holy See (Vatican City State)", + "HN": "Honduras", + "HK": "Hong Kong", + "HU": "Hungary", + "IS": "Iceland", + "IN": "India", + "ID": "Indonesia", + "IR": "Iran, Islamic Republic Of", + "IQ": "Iraq", + "IE": "Ireland", + "IM": "Isle of Man", + "IL": "Israel", + "IT": "Italy", + "JM": "Jamaica", + "JP": "Japan", + "JE": "Jersey", + "JO": "Jordan", + "KZ": "Kazakhstan", + "KE": "Kenya", + "KI": "Kiribati", + "KP": "Korea, Democratic People'S Republic of", + "KR": "Korea, Republic of", + "KW": "Kuwait", + "KG": "Kyrgyzstan", + "LA": "Lao People'S Democratic Republic", + "LV": "Latvia", + "LB": "Lebanon", + "LS": "Lesotho", + "LR": "Liberia", + "LY": "Libyan Arab Jamahiriya", + "LI": "Liechtenstein", + "LT": "Lithuania", + "LU": "Luxembourg", + "MO": "Macao", + "MK": "Macedonia, The Former Yugoslav Republic of", + "MG": "Madagascar", + "MW": "Malawi", + "MY": "Malaysia", + "MV": "Maldives", + "ML": "Mali", + "MT": "Malta", + "MH": "Marshall Islands", + "MQ": "Martinique", + "MR": "Mauritania", + "MU": "Mauritius", + "YT": "Mayotte", + "MX": "Mexico", + "FM": "Micronesia, Federated States of", + "MD": "Moldova, Republic of", + "MC": "Monaco", + "MN": "Mongolia", + "MS": "Montserrat", + "MA": "Morocco", + "MZ": "Mozambique", + "MM": "Myanmar", + "NA": "Namibia", + "NR": "Nauru", + "NP": "Nepal", + "NL": "Netherlands", + "AN": "Netherlands Antilles", + "NC": "New Caledonia", + "NZ": "New Zealand", + "NI": "Nicaragua", + "NE": "Niger", + "NG": "Nigeria", + "NU": "Niue", + "NF": "Norfolk Island", + "MP": "Northern Mariana Islands", + "NO": "Norway", + "OM": "Oman", + "PK": "Pakistan", + "PW": "Palau", + "PS": "Palestinian Territory, Occupied", + "PA": "Panama", + "PG": "Papua New Guinea", + "PY": "Paraguay", + "PE": "Peru", + "PH": "Philippines", + "PN": "Pitcairn", + "PL": "Poland", + "PT": "Portugal", + "PR": "Puerto Rico", + "QA": "Qatar", + "RE": "Reunion", + "RO": "Romania", + "RU": "Russian Federation", + "RW": "RWANDA", + "SH": "Saint Helena", + "KN": "Saint Kitts and Nevis", + "LC": "Saint Lucia", + "PM": "Saint Pierre and Miquelon", + "VC": "Saint Vincent and the Grenadines", + "WS": "Samoa", + "SM": "San Marino", + "ST": "Sao Tome and Principe", + "SA": "Saudi Arabia", + "SN": "Senegal", + "CS": "Serbia and Montenegro", + "SC": "Seychelles", + "SL": "Sierra Leone", + "SG": "Singapore", + "SK": "Slovakia", + "SI": "Slovenia", + "SB": "Solomon Islands", + "SO": "Somalia", + "ZA": "South Africa", + "GS": "South Georgia and the South Sandwich Islands", + "ES": "Spain", + "LK": "Sri Lanka", + "SD": "Sudan", + "SR": "Suriname", + "SJ": "Svalbard and Jan Mayen", + "SZ": "Swaziland", + "SE": "Sweden", + "CH": "Switzerland", + "SY": "Syrian Arab Republic", + "TW": "Taiwan", + "TJ": "Tajikistan", + "TZ": "Tanzania, United Republic of", + "TH": "Thailand", + "TL": "Timor-Leste", + "TG": "Togo", + "TK": "Tokelau", + "TO": "Tonga", + "TT": "Trinidad and Tobago", + "TN": "Tunisia", + "TR": "Turkey", + "TM": "Turkmenistan", + "TC": "Turks and Caicos Islands", + "TV": "Tuvalu", + "UG": "Uganda", + "UA": "Ukraine", + "AE": "United Arab Emirates", + "GB": "United Kingdom", + "US": "United States", + "UM": "United States Minor Outlying Islands", + "UY": "Uruguay", + "UZ": "Uzbekistan", + "VU": "Vanuatu", + "VE": "Venezuela", + "VN": "Viet Nam", + "VG": "Virgin Islands, British", + "VI": "Virgin Islands, U.S.", + "WF": "Wallis and Futuna", + "EH": "Western Sahara", + "YE": "Yemen", + "ZM": "Zambia", + "ZW": "Zimbabwe" + }; + + return countryCodes; +} + +export { loadCountryCodes }; \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 4e7d6a02..181afae2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,4 +8,4 @@ services: tty: true # docker run -t 终端模式 restart: always # 重启策略 / on-failure:5 重启次数5次 / always 一直重启 / unless-stopped 除非停止 / no 从不重启 ports: - - "18966:18966" + - "18966:18966" \ No newline at end of file diff --git a/frontend/components/Advanced.vue b/frontend/components/Advanced.vue index b11a2d36..281940fa 100644 --- a/frontend/components/Advanced.vue +++ b/frontend/components/Advanced.vue @@ -51,7 +51,7 @@