forked from jason5ng32/MyIP
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c3f7eb
commit ac283a4
Showing
32 changed files
with
229 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
BING_MAP_API_KEY="" | ||
ALLOWED_DOMAINS="" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
.DS_Store | ||
bingMapAPIKEY | ||
bingMapAPIKEY | ||
.env | ||
node_modules | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
FROM nginx:alpine | ||
COPY . /usr/share/nginx/html | ||
EXPOSE 80 | ||
CMD ["nginx", "-g", "daemon off;"] | ||
FROM node:20-alpine | ||
WORKDIR /usr/src/app | ||
COPY package*.json ./ | ||
RUN npm install | ||
COPY . . | ||
EXPOSE 8966 | ||
CMD ["node", "server.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const https = require('https'); | ||
|
||
module.exports = (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: 'No referer header' }); | ||
} | ||
|
||
const { latitude, longitude, language } = req.params; | ||
const mapSize = '800,640'; | ||
const pp = `${latitude},${longitude};66`; | ||
const fmt = 'jpeg'; | ||
const dpi = 'Large'; | ||
const apiKey = process.env.BING_MAP_API_KEY; | ||
|
||
const url = `https://dev.virtualearth.net/REST/v1/Imagery/Map/Road/${latitude},${longitude}/5?mapSize=${mapSize}&pp=${pp}&key=${apiKey}&fmt=${fmt}&dpi=${dpi}&c=${language}`; | ||
|
||
https.get(url, apiRes => { | ||
apiRes.pipe(res); | ||
}).on('error', (e) => { | ||
res.status(500).json({ error: e.message }); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = (req, res) => { | ||
if (process.env.BING_MAP_API_KEY) { | ||
res.status(200).json({ isValid: true }); | ||
} else { | ||
res.status(200).json({ isValid: false }); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "myip", | ||
"version": "2.1.0", | ||
"description": "A better IP Toolbox", | ||
"main": "server.js", | ||
"scripts": { | ||
"start": "node server.js", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/jason5ng32/MyIP.git" | ||
}, | ||
"author": "Jason Ng", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/jason5ng32/MyIP/issues" | ||
}, | ||
"homepage": "https://github.com/jason5ng32/MyIP#readme", | ||
"dependencies": { | ||
"dotenv": "^16.3.1", | ||
"express": "^4.18.2", | ||
"http-proxy-middleware": "^2.0.6" | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.