Crates.io | getserviceip |
lib.rs | getserviceip |
version | 0.1.2 |
source | src |
created_at | 2024-09-21 20:41:58.283677 |
updated_at | 2024-09-26 16:54:22.98892 |
description | Web service to get IP addresses from devices. |
homepage | |
repository | https://github.com/sukkis/getserviceip |
max_upload_size | |
id | 1382458 |
size | 98,590 |
getserviceip is a Rust-based web service that provides an endpoint to validate and return IP information. It uses the Actix-web framework to handle HTTP requests.
As an example, you might have a Raspberry Pi in local network that gets IP assigned by DHCP, and you reach the device with ssh. If the address for you device changes, you might not be able to connect it. Instead you could set up a cronjob in the Raspberry Pi to frequently send the IP information to getserviceip. You will always know where your devices can be reached.
/health_check
GET
curl http://localhost:8087/health_check
Response:
OK
curl http://localhost:8087/list_all
Response:
[
{
"hostname": "example1.com",
"ip_v6": "2001:0db8:85a3:0000:0000:8a2e:0370:7334",
"ip_v4": "192.168.0.1"
},
{
"hostname": "example2.com",
"ip_v6": "2001:0db8:85a3:0000:0000:8a2e:0370:7335",
"ip_v4": "192.168.0.2"
}
]
curl -X POST http://localhost:8087/ip -H "Content-Type: application/json" -d '{
"hostname": "example.com",
"ip_v6": "2001:0db8:85a3:0000:0000:8a2e:0370:7334",
"ip_v4": "192.168.1.1"
}'
Response:
{
"hostname": "example.com",
"ip_v6": "2001:0db8:85a3:0000:0000:8a2e:0370:7334",
"ip_v4": "192.168.1.1"
}
To run the service, use the following command:
cargo run
The service will start on http://localhost:8087.
This project is licensed under the GPL v3 license. See the LICENSE file for details.