From 0d7a6922dcaeb2193dbc72fc775a276767bfd354 Mon Sep 17 00:00:00 2001 From: jason5ng32 Date: Thu, 11 Jul 2024 22:33:36 +0800 Subject: [PATCH 1/7] Add MAC lookup --- api/macchecker.js | 76 +++++ backend-server.js | 2 + frontend/components/Advanced.vue | 7 +- .../components/advanced-tools/MacChecker.vue | 272 ++++++++++++++++++ frontend/locales/en.json | 44 ++- frontend/locales/fr.json | 44 ++- frontend/locales/zh.json | 44 ++- frontend/router/index.js | 2 + 8 files changed, 487 insertions(+), 4 deletions(-) create mode 100644 api/macchecker.js create mode 100644 frontend/components/advanced-tools/MacChecker.vue diff --git a/api/macchecker.js b/api/macchecker.js new file mode 100644 index 00000000..1cf0d055 --- /dev/null +++ b/api/macchecker.js @@ -0,0 +1,76 @@ +import { get } from 'https'; +import { refererCheck } from '../common/referer-check.js'; + +const isValidMAC = (address) => { + const normalizedAddress = address.replace(/[:-]/g, ''); + return normalizedAddress.length >= 6 && normalizedAddress.length <= 12 && /^[0-9A-Fa-f]+$/.test(normalizedAddress); +} + +export default async (req, res) => { + // 限制只能从指定域名访问 + const referer = req.headers.referer; + if (!refererCheck(referer)) { + return res.status(403).json({ error: referer ? 'Access denied' : 'What are you doing?' }); + } + + // 从请求中获取 IP 地址 + let macAddress = req.query.mac; + if (!macAddress) { + return res.status(400).json({ error: 'No MAC address provided' }); + } else { + macAddress = macAddress.replace(/:/g, '').replace(/-/g, ''); + } + + // 检查 IP 地址是否合法 + if (!isValidMAC(macAddress)) { + return res.status(400).json({ error: 'Invalid MAC address' }); + } + + + const token = process.env.MAC_LOOKUP_API_KEY || ''; + + const url_hasToken = `https://api.maclookup.app/v2/macs/${macAddress}?apiKey=${token}`; + const url_noToken = `https://api.maclookup.app/v2/macs/${macAddress}`; + const url = token ? url_hasToken : url_noToken; + + get(url, apiRes => { + let data = ''; + apiRes.on('data', chunk => data += chunk); + apiRes.on('end', async () => { + try { + const originalJson = JSON.parse(data); + if (originalJson.success !== true) { + return res.json({ success: false, error: originalJson.error || 'Data not found' }); + } + const finalData = modifyData(originalJson); + res.json(finalData); + } catch (e) { + res.status(500).json({ error: 'Error parsing JSON' }); + } + }); + }).on('error', (e) => { + res.status(500).json({ error: e.message }); + }); +}; + + +const modifyData = (data) => { + // 检查单播/多播以及本地/全球地址 + const firstByte = parseInt(data.macPrefix.substring(0, 2), 16); + const isMulticast = (firstByte & 0x01) === 0x01; + const isLocal = (firstByte & 0x02) === 0x02; + + data.isMulticast = isMulticast ? true : false; + data.isLocal = isLocal ? true : false; + data.macPrefix = data.macPrefix? data.macPrefix : 'N/A'; + data.company = data.company? data.company : 'N/A'; + data.country = data.country? data.country : 'N/A'; + data.address = data.address? data.address : 'N/A'; + data.updated = data.updated? data.updated : 'N/A'; + data.blockStart = data.blockStart? data.blockStart : 'N/A'; + data.blockEnd = data.blockEnd? data.blockEnd : 'N/A'; + data.blockSize = data.blockSize? data.blockSize : 'N/A'; + data.blockType = data.blockType? data.blockType : 'N/A'; + + return data; +} \ No newline at end of file diff --git a/backend-server.js b/backend-server.js index 6880aca9..b358d5b1 100644 --- a/backend-server.js +++ b/backend-server.js @@ -17,6 +17,7 @@ import { slowDown } from 'express-slow-down' import whois from './api/whois.js'; import ipapiisHandler from './api/ipapiis.js'; import invisibilitytestHandler from './api/invisibilitytest.js'; +import macChecker from './api/macchecker.js'; dotenv.config(); @@ -135,6 +136,7 @@ app.get('/api/dnsresolver', dnsResolver); app.get('/api/whois', whois); app.get('/api/ipapiis', ipapiisHandler); app.get('/api/invisibility', invisibilitytestHandler); +app.get('/api/macchecker', macChecker); // 使用查询参数处理所有配置请求 app.get('/api/configs', validateConfigs); diff --git a/frontend/components/Advanced.vue b/frontend/components/Advanced.vue index e3dc7802..cc51f5d3 100644 --- a/frontend/components/Advanced.vue +++ b/frontend/components/Advanced.vue @@ -75,6 +75,7 @@ const cards = reactive([ { path: '/dnsresolver', icon: '🔦', titleKey: 'dnsresolver.Title', noteKey: 'advancedtools.DNSResolverNote' }, { path: '/censorshipcheck', icon: '🚧', titleKey: 'censorshipcheck.Title', noteKey: 'advancedtools.CensorshipCheck' }, { path: '/whois', icon: '📓', titleKey: 'whois.Title', noteKey: 'advancedtools.Whois' }, + { path: '/macchecker', icon: '📀', titleKey: 'macchecker.Title', noteKey: 'advancedtools.MacChecker' }, ]); const cardInvisibilityTest = { path: '/invisibilitytest', icon: '🫣', titleKey: 'invisibilitytest.Title', noteKey: 'advancedtools.InvisibilityTest' }; @@ -121,9 +122,13 @@ const navigateAndToggleOffcanvas = (routePath) => { trackEvent('Nav', 'NavClick', 'Whois'); openedCard.value = 5; break; + case '/macchecker': + trackEvent('Nav', 'NavClick', 'MacChecker'); + openedCard.value = 6; + break; case '/invisibilitytest': trackEvent('Nav', 'NavClick', 'InvisibilityTest'); - openedCard.value = 6; + openedCard.value = 7; break; } var offcanvas = new Offcanvas(document.getElementById('offcanvasTools')); diff --git a/frontend/components/advanced-tools/MacChecker.vue b/frontend/components/advanced-tools/MacChecker.vue new file mode 100644 index 00000000..41d6d853 --- /dev/null +++ b/frontend/components/advanced-tools/MacChecker.vue @@ -0,0 +1,272 @@ + + + + + \ No newline at end of file diff --git a/frontend/locales/en.json b/frontend/locales/en.json index 362c8420..45cbe013 100644 --- a/frontend/locales/en.json +++ b/frontend/locales/en.json @@ -139,7 +139,35 @@ "RuleTestNote": "Check the rule settings of proxy software", "CensorshipCheck": "Check if a website is blocked in some countries", "Whois": "Search for domain/IP registration information", - "InvisibilityTest": "Check if you are using a proxy or VPN" + "InvisibilityTest": "Check if you are using a proxy or VPN", + "MacChecker": "Query information of a physical address" + }, + "macchecker": { + "Title": "MAC Lookup", + "Note": "Query the manufacturer of a physical address (MAC address), whether it is unicast/multicast, global/local, etc. Supports querying with a complete 12-digit address or just the prefix. You can also use this tool to verify if the physical address you generated meets your needs.", + "Note2": "Please enter a physical address to start the query:", + "Run": "Query", + "Placeholder": "F0:2F:4B:01:0A:AA", + "invalidMAC": "Invalid physical address", + "fetchError": "Unable to fetch query results", + "company": "Manufacturer", + "macPrefix": "Physical address prefix", + "address": "Registered address", + "country": "Registered country/region", + "blockStart": "Start block", + "blockEnd": "End block", + "blockSize": "Block size", + "blockType": "Block type", + "blockRange": "Block range", + "isRand": "Random address", + "isPrivate": "Private data", + "isMulticast": "Multicast address", + "isUnicast": "Unicast address", + "isGlobal": "Global address", + "isLocal": "Local address", + "property": "Address property", + "value": "Value", + "manufacturer": "Manufacturer details" }, "whois": { "Title": "Whois Search", @@ -743,6 +771,20 @@ "change": "Optimized numerous details" } ] + }, + { + "version": "v4.1", + "date": "July 11, 2024", + "content": [ + { + "type": "add", + "change": "Added MAC address lookup feature" + }, + { + "type": "improve", + "change": "Optimized numerous details" + } + ] } ] } diff --git a/frontend/locales/fr.json b/frontend/locales/fr.json index 8ca5b2fb..f4a91091 100644 --- a/frontend/locales/fr.json +++ b/frontend/locales/fr.json @@ -139,7 +139,35 @@ "RuleTestNote": "Vérifiez les paramètres de règles du logiciel de proxy", "CensorshipCheck": "Vérifier si un site est bloqué dans certains pays", "Whois": "Recherche d'informations sur l'enregistrement de domaine/IP", - "InvisibilityTest": "Vérifiez si vous utilisez un proxy ou un VPN" + "InvisibilityTest": "Vérifiez si vous utilisez un proxy ou un VPN", + "MacChecker": "Requête d'informations d'une adresse physique" + }, + "macchecker": { + "Title": "Recherche MAC", + "Note": "Interroger le fabricant d'une adresse physique (adresse MAC), s'il s'agit d'une adresse unicast/multicast, globale/locale, etc. Prend en charge la requête avec une adresse complète de 12 chiffres ou juste le préfixe. Vous pouvez également utiliser cet outil pour vérifier si l'adresse physique que vous avez générée répond à vos besoins.", + "Note2": "Veuillez saisir une adresse physique pour commencer la requête:", + "Run": "Interroger", + "Placeholder": "F0:2F:4B:01:0A:AA", + "invalidMAC": "Adresse physique invalide", + "fetchError": "Impossible de récupérer les résultats de la requête", + "company": "Fabricant", + "macPrefix": "Préfixe d'adresse physique", + "address": "Adresse enregistrée", + "country": "Pays/région enregistré", + "blockStart": "Bloc de départ", + "blockEnd": "Bloc de fin", + "blockSize": "Taille du bloc", + "blockType": "Type de bloc", + "blockRange": "Plage du bloc", + "isRand": "Adresse aléatoire", + "isPrivate": "Données privées", + "isMulticast": "Adresse multicast", + "isUnicast": "Adresse unicast", + "isGlobal": "Adresse mondiale", + "isLocal": "Adresse locale", + "property": "Propriété de l'adresse", + "value": "Valeur", + "manufacturer": "Détails du fabricant" }, "whois": { "Title": "Recherche Whois", @@ -743,6 +771,20 @@ "change": "Optimisation de nombreux détails" } ] + }, + { + "version": "v4.1", + "date": "July 11, 2024", + "content": [ + { + "type": "add", + "change": "Ajout de la fonction de recherche MAC" + }, + { + "type": "improve", + "change": "Optimisation de nombreux détails" + } + ] } ] } diff --git a/frontend/locales/zh.json b/frontend/locales/zh.json index f76380df..6a9272f3 100644 --- a/frontend/locales/zh.json +++ b/frontend/locales/zh.json @@ -139,7 +139,35 @@ "RuleTestNote": "检查代理软件的规则设置", "CensorshipCheck": "检查一个网站在某些国家是否被封锁", "Whois": "对域名或 IP 进行 Whois 查询", - "InvisibilityTest": "猜猜看我是否知道你挂了代理" + "InvisibilityTest": "猜猜看我是否知道你挂了代理", + "MacChecker": "查询物理地址的归属信息" + }, + "macchecker": { + "Title": "MAC 地址查询", + "Note": "查询一个物理地址(MAC 地址)所属的制造商、是否单播/多播、是否广域/区域等信息。支持使用完整的 12 位进行查询,也支持前缀查询。当然,你也可以用本查询工具来验证你生成的物理地址是否符合自己的需求。", + "Note2": "请输入一个物理地址,开始查询:", + "Run": "查询", + "Placeholder": "F0:2F:4B:01:0A:AA", + "invalidMAC": "无效的物理地址", + "fetchError": "无法获取查询结果", + "company": "制造商", + "macPrefix": "物理地址前缀", + "address": "注册地址", + "country": "注册国家/地区", + "blockStart": "起始区块", + "blockEnd": "结束区块", + "blockSize": "区块大小", + "blockType": "区块类型", + "blockRange": "区块范围", + "isRand": "随机地址", + "isPrivate": "私有数据", + "isMulticast": "多播地址", + "isUnicast": "单播地址", + "isGlobal": "全球地址", + "isLocal": "本地地址", + "property": "地址属性", + "value": "值", + "manufacturer": "制造商信息" }, "whois": { "Title": "Whois 查询", @@ -743,6 +771,20 @@ "change": "优化了大量细节" } ] + }, + { + "version": "v4.1", + "date": "July 11, 2024", + "content": [ + { + "type": "add", + "change": "添加 MAC 地址查询功能" + }, + { + "type": "improve", + "change": "优化了部分程序细节" + } + ] } ] } diff --git a/frontend/router/index.js b/frontend/router/index.js index cb7efaa1..f69ac6e7 100644 --- a/frontend/router/index.js +++ b/frontend/router/index.js @@ -8,6 +8,7 @@ const DNSResolver = () => import('../components/advanced-tools/DnsResolver.vue') const CensorshipCheck = () => import('../components/advanced-tools/CensorshipCheck.vue'); const Whois = () => import('../components/advanced-tools/Whois.vue'); const InvisibilityTest = () => import('../components/advanced-tools/InvisibilityTest.vue'); +const MacChecker = () => import('../components/advanced-tools/MacChecker.vue'); const EmptyComponent = () => import('../components/advanced-tools/Empty.vue'); const routes = [ @@ -19,6 +20,7 @@ const routes = [ { path: '/censorshipcheck', component: CensorshipCheck }, { path: '/whois', component: Whois }, { path: '/invisibilitytest', component: InvisibilityTest }, + { path: '/macchecker', component: MacChecker }, ]; const router = createRouter({ From 714867fa443e822b681d9c5eba08291fb5b457a7 Mon Sep 17 00:00:00 2001 From: jason5ng32 Date: Thu, 11 Jul 2024 22:41:19 +0800 Subject: [PATCH 2/7] Add MAC lookup --- README.md | 1 + README_FR.md | 1 + README_ZH.md | 1 + 3 files changed, 3 insertions(+) diff --git a/README.md b/README.md index 8497b11e..a8eaee2d 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ Notes: You can use my demo for free, and you can also deploy it yourself. * 🔦 **DNS Resolver**: Performs DNS resolution of a domain name from multiple sources and obtains real-time resolution results that can be used for contamination determination. * 🚧 **Censorship Check**: Check if a website is blocked in some countries. * 📓 **Whois Search**: Perform whois information search for domain names or IP addresses +* 📀 **MAC Lookup**: Query information of a physical address * 🌗 **Dark Mode**: Automatically toggles between dark and daylight modes based on system settings, with an option for manual switching. * 📱 **Minimalist Mode**: A mobile-optimized mode that shortens page length for quick access to essential information.. * 🔍 **Search IP Information**: Provides a tool for querying information about any IP address. diff --git a/README_FR.md b/README_FR.md index e52e0d86..f5dc6fb4 100644 --- a/README_FR.md +++ b/README_FR.md @@ -41,6 +41,7 @@ Notes: Vous pouvez utiliser ma démo gratuitement et vous pouvez également la d * 🔦 **Résolveur DNS** : effectue la résolution DNS d'un nom de domaine à partir de plusieurs sources, obtient les résultats de la résolution en temps réel et peut être utilisé pour la détermination de la contamination. * 🚧 **Test de Censorship**: Vérifier si un site est bloqué dans certains pays. * 📓 **Recherche Whois** : Effectuer une recherche d'informations Whois pour les noms de domaine ou les adresses IP +* 📀 **Recherche MAC** : Requête d'informations d'une adresse physique * 🌗 **Mode sombre** : Bascule automatiquement entre les modes sombre et clair en fonction des paramètres du système, avec une option de basculement manuel. * 📱 **Mode minimaliste** : Un mode optimisé pour les mobiles qui réduit la longueur de la page pour un accès rapide aux informations essentielles. * 🔍 **Recherche d'informations sur l'adresse IP** : Fournit un outil pour interroger des informations sur n'importe quelle adresse IP. diff --git a/README_ZH.md b/README_ZH.md index 0033bdff..1f475f99 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -43,6 +43,7 @@ * 🔦 **DNS 解析器**:从多个渠道对域名进行 DNS 解析,获取实时的解析结果,可用于污染判断 * 🚧 **封锁测试**:检查特定的网站在部分国家是否被封锁 * 📓 **Whois 查询**:对域名或 IP 进行 whois 信息查询 +* 📀 **MAC 地址查询**:查询物理地址的归属信息 * 🌗 **暗黑模式**:根据系统设置自动切换暗黑/白天模式,也可以手动切换 * 📱 **简约模式**:为移动版提供的专门模式,缩短页面长度,快速查看最重要的信息 * 🔍 **查任意 IP 信息**:可以通过小工具查询任意 IP 的信息 From 7126c0f72236f17a9f53d11dac110aac19337be3 Mon Sep 17 00:00:00 2001 From: jason5ng32 Date: Thu, 11 Jul 2024 22:55:28 +0800 Subject: [PATCH 3/7] Add MAC lookup --- frontend/components/Advanced.vue | 2 +- frontend/components/advanced-tools/MacChecker.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/components/Advanced.vue b/frontend/components/Advanced.vue index cc51f5d3..f71e13f3 100644 --- a/frontend/components/Advanced.vue +++ b/frontend/components/Advanced.vue @@ -75,7 +75,7 @@ const cards = reactive([ { path: '/dnsresolver', icon: '🔦', titleKey: 'dnsresolver.Title', noteKey: 'advancedtools.DNSResolverNote' }, { path: '/censorshipcheck', icon: '🚧', titleKey: 'censorshipcheck.Title', noteKey: 'advancedtools.CensorshipCheck' }, { path: '/whois', icon: '📓', titleKey: 'whois.Title', noteKey: 'advancedtools.Whois' }, - { path: '/macchecker', icon: '📀', titleKey: 'macchecker.Title', noteKey: 'advancedtools.MacChecker' }, + { path: '/macchecker', icon: '🗄️', titleKey: 'macchecker.Title', noteKey: 'advancedtools.MacChecker' }, ]); const cardInvisibilityTest = { path: '/invisibilitytest', icon: '🫣', titleKey: 'invisibilitytest.Title', noteKey: 'advancedtools.InvisibilityTest' }; diff --git a/frontend/components/advanced-tools/MacChecker.vue b/frontend/components/advanced-tools/MacChecker.vue index 41d6d853..4f782302 100644 --- a/frontend/components/advanced-tools/MacChecker.vue +++ b/frontend/components/advanced-tools/MacChecker.vue @@ -2,7 +2,7 @@
-

📀 {{ t('macchecker.Title') }}

+

🗄️ {{ t('macchecker.Title') }}

From 793af7e73754040fea2ff0c1677d8bf13ab1a72a Mon Sep 17 00:00:00 2001 From: jason5ng32 Date: Thu, 11 Jul 2024 23:07:16 +0800 Subject: [PATCH 4/7] Add MAC lookup --- frontend/App.vue | 9 +++++++++ frontend/locales/en.json | 3 ++- frontend/locales/fr.json | 3 ++- frontend/locales/zh.json | 3 ++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/frontend/App.vue b/frontend/App.vue index b427cf8c..e142f8f8 100644 --- a/frontend/App.vue +++ b/frontend/App.vue @@ -367,6 +367,15 @@ const ShortcutKeys = (isOriginalSite) => { }, description: t('shortcutKeys.PingTest'), }, + { + keys: "M", + action: () => { + scrollToElement("AdvancedTools", 80); + advancedToolsRef.value.navigateAndToggleOffcanvas('/macchecker'); + trackEvent('Nav', 'NavClick', 'MacChecker'); + }, + description: t('shortcutKeys.MacChecker'), + }, { keys: "t", action: () => { diff --git a/frontend/locales/en.json b/frontend/locales/en.json index 45cbe013..c70e9f07 100644 --- a/frontend/locales/en.json +++ b/frontend/locales/en.json @@ -395,7 +395,8 @@ "Preferences": "Open Preferences", "About": "Open About panel", "Whois": "Open Whois Search panel", - "InvisibilityTest": "Open Invisibility Test panel" + "InvisibilityTest": "Open Invisibility Test panel", + "MacChecker": "Open MAC lookup panel" }, "page": { "title": "IPCheck.ing - Check My IP Address and Geolocation - Check WebRTC Connection IP - DNS Leak Test - Speed Test - Jason Ng Open Source", diff --git a/frontend/locales/fr.json b/frontend/locales/fr.json index f4a91091..96cb519a 100644 --- a/frontend/locales/fr.json +++ b/frontend/locales/fr.json @@ -395,7 +395,8 @@ "Preferences": "Ouvrir les Préférences", "About": "Ouvrir À propos", "Whois": "Ouvrir la Recherche Whois", - "InvisibilityTest": "Ouvrir le Test d'invisibilité" + "InvisibilityTest": "Ouvrir le Test d'invisibilité", + "MacChecker": "Ouvrir le Recherche de MAC" }, "page": { "title": "IPCheck.ing - Vérifier mon adresse IP et géolocalisation - Vérifier l'adresse IP de connexion WebRTC - Test de fuite DNS - Test de vitesse - Jason Ng Open Source", diff --git a/frontend/locales/zh.json b/frontend/locales/zh.json index 6a9272f3..f7f54b4f 100644 --- a/frontend/locales/zh.json +++ b/frontend/locales/zh.json @@ -395,7 +395,8 @@ "Preferences": "打开偏好设置面板", "About": "打开关于页面", "Whois": "打开 Whois 查询面板", - "InvisibilityTest": "打开隐身测试面板" + "InvisibilityTest": "打开隐身测试面板", + "MacChecker": "打开物理地址查询面板" }, "page": { "title": "IPCheck.ing - 查看我的 IP 地址 - 查询本机 IP 地址及归属地 - 查看 WebRTC 连接 IP - DNS 泄露检测 - 网速测试 - Jason Ng 阿禅开源作品", From d9d2949f99dff17ccc3140b52bdf72ff672dfe0d Mon Sep 17 00:00:00 2001 From: jason5ng32 Date: Thu, 11 Jul 2024 23:10:46 +0800 Subject: [PATCH 5/7] Add MAC lookup --- .env.example | 3 ++- README.md | 1 + README_FR.md | 1 + README_ZH.md | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 2ca3fac6..ad508865 100644 --- a/.env.example +++ b/.env.example @@ -9,4 +9,5 @@ CLOUDFLARE_API="" SECURITY_BLACKLIST_LOG_FILE_PATH="" SECURITY_RATE_LIMIT="" SECURITY_DELAY_AFTER="" -IPAPIIS_API_KEY="" \ No newline at end of file +IPAPIIS_API_KEY="" +MAC_LOOKUP_API_KEY="" \ No newline at end of file diff --git a/README.md b/README.md index a8eaee2d..98f38090 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,7 @@ You can use the program without adding any environment variables, but if you wan | `IPAPIIS_API_KEY` | No | `""` | API Key for IPAPI.is, used to obtain IP geolocation information through IPAPI.is | | `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 | +| `MAC_LOOKUP_API_KEY` | No | `""` | API Key for MAC Lookup, used to obtain MAC address information | ### Using Environment Variables in a Node Environment diff --git a/README_FR.md b/README_FR.md index f5dc6fb4..410d7fd5 100644 --- a/README_FR.md +++ b/README_FR.md @@ -102,6 +102,7 @@ Vous pouvez utiliser le programme sans ajouter de variables d'environnement, mai | `IPAPIIS_API_KEY` | Non | `""` | Clé API pour IPAPI.is, utilisée pour obtenir des informations de géolocalisation sur l'adresse IP via IPAPI.is | | `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 | +| `MAC_LOOKUP_API_KEY` | Non | `""` | Clé API pour MAC Lookup, utilisée pour obtenir des informations sur l'adresse MAC via MAC Lookup | ### Utilisation des variables d'environnement dans un environnement Node diff --git a/README_ZH.md b/README_ZH.md index 1f475f99..10b2047c 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -104,6 +104,7 @@ docker run -d -p 18966:18966 --name myip --restart always jason5ng32/myip:latest | `IPAPIIS_API_KEY` | 否 | `""` | IPAPI.is 的 API Key,用于通过 IPAPI.is 获取 IP 归属地信息 | | `KEYCDN_USER_AGENT` | 否 | `""` | 使用 KeyCDN 时的域名,需包含 https 前缀。用于通过 KeyCDN 获取 IP 归属地信息 | | `CLOUDFLARE_API` | 否 | `""` | Cloudflare 的 API Key,用于通过 Cloudflare 获取 AS 系统的信息 | +| `MAC_LOOKUP_API_KEY` | 否 | `""` | MAC 查询的 API Key,用于通过 MAC Lookup 获取 MAC 地址的归属信息 | ### 在 Node 环境里使用环境变量 From 3c84c01d4036dbf4fe5d5a56bffc5a9d4a680ac2 Mon Sep 17 00:00:00 2001 From: jason5ng32 Date: Thu, 11 Jul 2024 23:15:13 +0800 Subject: [PATCH 6/7] Add MAC lookup --- README_ZH.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README_ZH.md b/README_ZH.md index 10b2047c..85d1d01c 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -1,6 +1,6 @@ # 🧰 IP 工具箱 -jason5ng32%2FMyIP | Trendshift +jason5ng32%2FMyIP | Trendshift ![IPCheck.ing Banner](https://raw.githubusercontent.com/jason5ng32/MyIP/main/public/github/gh_banner.png) From 4effe3fae3356acd1d43d54ef1094e94557510cf Mon Sep 17 00:00:00 2001 From: jason5ng32 Date: Thu, 11 Jul 2024 23:44:28 +0800 Subject: [PATCH 7/7] Add MAC lookup --- api/macchecker.js | 2 + .../components/advanced-tools/MacChecker.vue | 108 +++++------------- 2 files changed, 30 insertions(+), 80 deletions(-) diff --git a/api/macchecker.js b/api/macchecker.js index 1cf0d055..978fc284 100644 --- a/api/macchecker.js +++ b/api/macchecker.js @@ -62,6 +62,8 @@ const modifyData = (data) => { data.isMulticast = isMulticast ? true : false; data.isLocal = isLocal ? true : false; + data.isGlobal = !isLocal ? true : false; + data.isUnicast = !isMulticast ? true : false; data.macPrefix = data.macPrefix? data.macPrefix : 'N/A'; data.company = data.company? data.company : 'N/A'; data.country = data.country? data.country : 'N/A'; diff --git a/frontend/components/advanced-tools/MacChecker.vue b/frontend/components/advanced-tools/MacChecker.vue index 4f782302..2bd879ee 100644 --- a/frontend/components/advanced-tools/MacChecker.vue +++ b/frontend/components/advanced-tools/MacChecker.vue @@ -41,52 +41,16 @@

{{ t('macchecker.manufacturer') }}

-
- - {{ t('macchecker.macPrefix') }} - - - {{ macCheckResult.macPrefix }} - -
- -
- - {{ t('macchecker.blockStart') }} - - - {{ macCheckResult.blockStart }} - -
- -
+
- {{ t('macchecker.blockEnd') }} + {{ t(`macchecker.${item.key}`) }} - {{ macCheckResult.blockEnd }} + {{ macCheckResult[item.key] }}
- -
- - {{ t('macchecker.blockSize') }} - - - {{ macCheckResult.blockSize }} - -
- -
- - {{ t('macchecker.blockType') }} - - - {{ macCheckResult.blockType }} - -
-
+
@@ -132,52 +96,16 @@ - - {{ t('macchecker.isRand') }} - - - - - - {{ t('macchecker.isPrivate') }} - - - - - - {{ t('macchecker.isMulticast') }} - - - - - - {{ t('macchecker.isUnicast') }} - - - - - - {{ t('macchecker.isLocal') }} + + {{ t(`macchecker.${item.key}`) }} - - - - {{ t('macchecker.isGlobal') }} - - + :class="macCheckResult[item.key] ? 'bi-check-circle-fill text-success' : 'bi-x-circle-fill text-secondary'">
-
@@ -210,6 +138,27 @@ const macCheckStatus = ref("idle"); const queryMAC = ref(''); const errorMsg = ref(''); +const leftItems = computed(() => { + return [ + { key: 'macPrefix' }, + { key: 'blockStart' }, + { key: 'blockEnd' }, + { key: 'blockSize' }, + { key: 'blockType' } + ]; +}); + +const tableItems = computed(() => { + return [ + { key: 'isRand' }, + { key: 'isPrivate' }, + { key: 'isMulticast' }, + { key: 'isUnicast' }, + { key: 'isLocal' }, + { key: 'isGlobal' } + ]; +}); + // 检查 MAC 是否有效 const validateInput = (input) => { if (!input) return null; @@ -253,7 +202,6 @@ const getMacInfo = async (query) => { } }; -