Ready for first release
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
dc0c66bc3c
commit
cc6dac666e
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -70,7 +70,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "actix-remote-ip"
|
||||
version = "0.1.0-alpha"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"actix-web",
|
||||
"futures-util",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "actix-remote-ip"
|
||||
version = "0.1.0-alpha"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
authors = ["Pierre HUBERT <pierre.git@communiquons.org>"]
|
||||
description = "Tiny extractor to get real client IP address, parsing X-Forwarded-For header"
|
||||
|
30
README.md
30
README.md
@ -1,2 +1,30 @@
|
||||
# Actix Remote IP extractor
|
||||
Tiny extractor of remote user IP address
|
||||
Tiny extractor of remote user IP address, that handles reverse proxy.
|
||||
|
||||
The `X-Forwarded-For` header is automatically parsed when the request comes from a defined proxy, to determine the real remote client IP Address.
|
||||
|
||||
Note : regarding IPv6 addresses, the local part of the address is discarded. For example, the IPv6 client `2001:0db8:85a3:0000:0000:8a2e:0370:7334` will be returned as `2001:0db8:85a3:0000:0000:0000:0000:0000`
|
||||
|
||||
## Configuration
|
||||
Configure it when you configure your Actix server:
|
||||
|
||||
```rust
|
||||
HttpServer::new(move || {
|
||||
App::new()
|
||||
.app_data(web::Data::new(RemoteIPConfig {
|
||||
proxy: Some("IP".to_string())
|
||||
}))
|
||||
// ...
|
||||
})
|
||||
```
|
||||
|
||||
## Usage
|
||||
In your route, add a `RemoteIP` parameter:
|
||||
|
||||
```rust
|
||||
#[get("/")]
|
||||
async fn home(remote_ip: RemoteIP) -> HttpResponse {
|
||||
let ip: IpAddr = remote_ip.0;
|
||||
// ...
|
||||
}
|
||||
```
|
Loading…
Reference in New Issue
Block a user