Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EllieCommsWeb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jellie
EllieCommsWeb
Commits
29450921
Commit
29450921
authored
3 months ago
by
Jellie
Browse files
Options
Downloads
Patches
Plain Diff
removed
parent
fe613ec0
Branches
main
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/ipTools.js
+0
-33
0 additions, 33 deletions
modules/ipTools.js
with
0 additions
and
33 deletions
modules/ipTools.js
deleted
100644 → 0
+
0
−
33
View file @
fe613ec0
const
express
=
require
(
'
express
'
);
const
router
=
express
.
Router
();
const
isLocalIp
=
(
ip
)
=>
{
// Remove IPv6 prefix if it exists
if
(
ip
.
startsWith
(
'
::ffff:
'
))
{
ip
=
ip
.
split
(
'
:
'
).
pop
();
}
// Check for localhost and private IP ranges
return
(
ip
===
'
127.0.0.1
'
||
// localhost
ip
===
'
::1
'
||
// IPv6 localhost
ip
.
startsWith
(
'
192.168.
'
)
||
// Private IPv4 range
ip
.
startsWith
(
'
10.
'
)
||
// Private IPv4 range
(
ip
.
startsWith
(
'
172.
'
)
&&
+
ip
.
split
(
'
.
'
)[
1
]
>=
16
&&
+
ip
.
split
(
'
.
'
)[
1
]
<=
31
)
// Private 172.16.0.0/12
);
}
router
.
get
(
'
/
'
,
(
req
,
res
)
=>
{
res
.
send
(
'
IP Module
'
);
});
router
.
get
(
'
/verify
'
,
(
req
,
res
)
=>
{
const
clientIp
=
req
.
headers
[
'
x-forwarded-for
'
]
||
req
.
ip
||
req
.
connection
.
remoteAddress
;
const
isLocal
=
isLocalIp
(
clientIp
);
return
res
.
json
({
success
:
isLocal
})
});
module
.
exports
=
router
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment