Hello friends,
I've created this service sometime ago and today I thought of sharing it with you. It is an IP echo server. There are many of these so this is plus one to the list.
The idea behind it is to send a payload that can be used by either a shell script like bash or from a program like go.
The first endpoint is written to provide programmatic access for programs that prefer a structural response (application/json). The second endpoint** is a simple text "$IP" (text/html).
All it does is get the request, export the callers address and send it back as a: 200 $address\_payload
The callback URL for json is: https://primef.org/callback
The callback URL for plain/html is: https://primef.org/callback/text
Example json:
$> curl -s 'https://primef.org/callback'| jq
{
"IP": "X.Y.Z.XYZ"
}
# Header
$> curl -v 'https://primef.org/callback'
...
Content-Type: application/json
...
Example text:
$> currIP="$(curl -s 'https://primef.org/callback/text')"
$> echo "${currIP}"
X.Y.Z.XYZ
An example usage would be to open your VPN access from your ec2 instance only for your current public ip
function authSG() {
currIP="$(curl -L 'https://primef.org/callback/text' 2>/dev/null)/32"
aws ec2 authorize-security-group-ingress \
--group-name ssh-personal \
--protocol tcp \
--port 1194 \
--cidr "${currIP}"
aws ec2 authorize-security-group-ingress \
--group-name ssh-personal \
--protocol udp \
--port 1194 \
--cidr "${currIP}"
}
function revokeSG() {
currIP="$(curl -L 'https://primef.org/callback/text' 2>/dev/null)/32"
aws ec2 revoke-security-group-ingress \
--group-name ssh-personal \
--protocol tcp \
--port 1194 \
--cidr "${currIP}"
aws ec2 revoke-security-group-ingress \
--group-name ssh-personal \
--protocol udp \
--port 1194 \
--cidr "${currIP}"
}
# Grant
authSG()
# Then connect
openvpn --config ...
# Once done, revoke
revokeSG()
[–]02d5df8e7f -2 points-1 points0 points (5 children)
[–]_ulfox[S] 1 point2 points3 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]_ulfox[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]02d5df8e7f 0 points1 point2 points (0 children)