Skip to content

Commit

Permalink
Merge pull request #206 from jason5ng32/dev
Browse files Browse the repository at this point in the history
Improvements
  • Loading branch information
jason5ng32 authored May 14, 2024
2 parents 18b2842 + 4e6a40e commit 296fefb
Showing 54 changed files with 419 additions and 344 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -26,4 +26,4 @@ dist-ssr
.vscode/extensions.json

package-lock.json
res
localtest
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 🧰 MyIP - A Better IP Toolbox

![IPCheck.ing Banner](https://raw.githubusercontent.com/jason5ng32/MyIP/main/public/gh_banner.png)
![IPCheck.ing Banner](https://raw.githubusercontent.com/jason5ng32/MyIP/main/public/github/gh_banner.png)

![GitHub Repo stars](https://img.shields.io/github/stars/jason5ng32/MyIP)
![GitHub forks](https://img.shields.io/github/forks/jason5ng32/myip)
@@ -23,8 +23,8 @@

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/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/Docker.svg)](https://hub.docker.com/r/jason5ng32/myip)
[![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

6 changes: 3 additions & 3 deletions README_FR.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 🧰 MyIP - Une meilleure boîte à outils IP

![IPCheck.ing Banner](https://raw.githubusercontent.com/jason5ng32/MyIP/main/public/gh_banner.png)
![IPCheck.ing Banner](https://raw.githubusercontent.com/jason5ng32/MyIP/main/public/github/gh_banner.png)

![GitHub Repo stars](https://img.shields.io/github/stars/jason5ng32/MyIP)
![GitHub forks](https://img.shields.io/github/forks/jason5ng32/myip)
@@ -23,8 +23,8 @@

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/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/Docker.svg)](https://hub.docker.com/r/jason5ng32/myip)
[![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

6 changes: 3 additions & 3 deletions README_ZH.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 🧰 IP 工具箱

![IPCheck.ing Banner](https://raw.githubusercontent.com/jason5ng32/MyIP/main/public/gh_banner.png)
![IPCheck.ing Banner](https://raw.githubusercontent.com/jason5ng32/MyIP/main/public/github/gh_banner.png)

![GitHub Repo stars](https://img.shields.io/github/stars/jason5ng32/MyIP)
![GitHub forks](https://img.shields.io/github/forks/jason5ng32/myip)
@@ -23,8 +23,8 @@

备注:你可以直接用我已经搭建好的服务,也可以自行搭建。

[![Deploy with Vercel](https://raw.githubusercontent.com/jason5ng32/MyIP/main/public/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/Docker.svg)](https://hub.docker.com/r/jason5ng32/myip)
[![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 练手的项目。我……只是一个普通的产品经理。

30 changes: 28 additions & 2 deletions api/cfradar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import { refererCheck } from '../lib/referer-check.js';
import { parse } from 'dotenv';
import { refererCheck } from '../common/referer-check.js';

// 创建一个用于设置 headers 的通用函数
function createFetchOptions() {
@@ -91,6 +92,30 @@ function isValidASN(asn) {
return /^[0-9]+$/.test(asn);
};


// 格式化输出

function formatData(data) {
const { asnName, asnOrgName, estimatedUsers, IPv4_Pct, IPv6_Pct, HTTP_Pct, HTTPS_Pct, Desktop_Pct, Mobile_Pct, Bot_Pct, Human_Pct } = data;
const formattedData = {
asnName,
asnOrgName,
estimatedUsers: parseFloat(estimatedUsers).toLocaleString(),
IPv4_Pct: `${parseFloat(IPv4_Pct).toFixed(2)}%`,
IPv6_Pct: `${parseFloat(IPv6_Pct).toFixed(2)}%`,
HTTP_Pct: `${parseFloat(HTTP_Pct).toFixed(2)}%`,
HTTPS_Pct: `${parseFloat(HTTPS_Pct).toFixed(2)}%`,
Desktop_Pct: `${parseFloat(Desktop_Pct).toFixed(2)}%`,
Mobile_Pct: `${parseFloat(Mobile_Pct).toFixed(2)}%`,
Bot_Pct: `${parseFloat(Bot_Pct).toFixed(2)}%`,
Human_Pct: `${parseFloat(Human_Pct).toFixed(2)}%`
};

return formattedData;

}


// 导出函数
export default async (req, res) => {

@@ -140,8 +165,9 @@ export default async (req, res) => {
}

const cleanedResponse = cleanUpResponseData(response);
const finalResponse = formatData(cleanedResponse);

res.json(cleanedResponse);
res.json(finalResponse);
} catch (error) {
console.error(error);
res.status(500).json({ error: 'Internal server error' });
2 changes: 1 addition & 1 deletion api/configs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { refererCheck } from '../lib/referer-check.js';
import { refererCheck } from '../common/referer-check.js';

// 验证环境变量是否存在,以进行前端功能的开启和关闭
export default (req, res) => {
2 changes: 1 addition & 1 deletion api/dnsresolver.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// api/dnsresolver.js
import { Resolver } from 'dns';
import { promisify } from 'util';
import { refererCheck } from '../lib/referer-check.js';
import { refererCheck } from '../common/referer-check.js';

// 普通 DNS 服务器列表
const dnsServers = {
2 changes: 1 addition & 1 deletion api/invisibilitytest.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { get } from 'https';
import { refererCheck } from '../lib/referer-check.js';
import { refererCheck } from '../common/referer-check.js';

// 如果长度不等于 28 且不是字母与数字的组合,则返回 false
function isValidUserID(userID) {
4 changes: 2 additions & 2 deletions api/ipapicom.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { get } from 'http';
import { isValidIP } from '../lib/valid-ip.js';
import { refererCheck } from '../lib/referer-check.js';
import { isValidIP } from '../common/valid-ip.js';
import { refererCheck } from '../common/referer-check.js';

export default (req, res) => {
// 限制只能从指定域名访问
4 changes: 2 additions & 2 deletions api/ipapiis.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { get } from 'https';
import { isValidIP } from '../lib/valid-ip.js';
import { refererCheck } from '../lib/referer-check.js';
import { isValidIP } from '../common/valid-ip.js';
import { refererCheck } from '../common/referer-check.js';

export default (req, res) => {
// 限制只能从指定域名访问
4 changes: 2 additions & 2 deletions api/ipchecking.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { get } from 'https';
import { isValidIP } from '../lib/valid-ip.js';
import { refererCheck } from '../lib/referer-check.js';
import { isValidIP } from '../common/valid-ip.js';
import { refererCheck } from '../common/referer-check.js';

export default (req, res) => {

4 changes: 2 additions & 2 deletions api/ipinfo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { get } from 'https';
import { isValidIP } from '../lib/valid-ip.js';
import { refererCheck } from '../lib/referer-check.js';
import { isValidIP } from '../common/valid-ip.js';
import { refererCheck } from '../common/referer-check.js';

// 国家代码
async function loadCountryCodes() {
15 changes: 4 additions & 11 deletions api/ipsb.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
import { get } from 'https';
import { isValidIP } from '../lib/valid-ip.js';
import { refererCheck } from '../lib/referer-check.js';
import { isValidIP } from '../common/valid-ip.js';
import { refererCheck } from '../common/referer-check.js';

export default (req, res) => {

// 限制只能从指定域名访问
const allowedDomains = ['localhost', ...(process.env.ALLOWED_DOMAINS || '').split(',')];
const referer = req.headers.referer;

if (referer) {
const domain = new URL(referer).hostname;
if (!allowedDomains.includes(domain)) {
return res.status(403).json({ error: 'Access denied' });
}
} else {
return res.status(403).json({ error: 'What are you doing?' });
if (!refererCheck(referer)) {
return res.status(403).json({ error: referer ? 'Access denied' : 'What are you doing?' });
}

const ipAddress = req.query.ip;
4 changes: 2 additions & 2 deletions api/keycdn.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { get } from 'https';
import { isValidIP } from '../lib/valid-ip.js';
import { refererCheck } from '../lib/referer-check.js';
import { isValidIP } from '../common/valid-ip.js';
import { refererCheck } from '../common/referer-check.js';

export default (req, res) => {
// 限制只能从指定域名访问
2 changes: 1 addition & 1 deletion api/map.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { get } from 'https';
import { refererCheck } from '../lib/referer-check.js';
import { refererCheck } from '../common/referer-check.js';

// 验证请求合法性

4 changes: 2 additions & 2 deletions api/whois.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import whoiser from 'whoiser';
import { isValidIP } from '../lib/valid-ip.js';
import { refererCheck } from '../lib/referer-check.js';
import { isValidIP } from '../common/valid-ip.js';
import { refererCheck } from '../common/referer-check.js';

function isValidDomain(domain) {
const domainPattern = /^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i;
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion frontend/App.vue
Original file line number Diff line number Diff line change
@@ -312,7 +312,7 @@ const ShortcutKeys = (isOriginalSite) => {
}
const card = IPCheckRef.value.ipDataCards[num - 1];
scrollToElement("IPInfo-" + num, 171);
IPCheckRef.value.refreshCard(card);
IPCheckRef.value.refreshCard(card, num - 1);
trackEvent('ShortCut', 'ShortCut', 'IPCheck');
},
description: t('shortcutKeys.RefreshIPCard'),
Loading

0 comments on commit 296fefb

Please sign in to comment.