|
@ -9,8 +9,9 @@ use bytes::{Buf, Bytes, IntoBuf}; |
|
|
use futures::future::Future;
|
|
|
use futures::future::Future;
|
|
|
|
|
|
|
|
|
use crate::server::error::APIError;
|
|
|
use crate::server::error::APIError;
|
|
|
|
|
|
use crate::server::router::AppState;
|
|
|
|
|
|
|
|
|
pub fn route(scope: Scope<()>) -> Scope<()> {
|
|
|
|
|
|
|
|
|
pub fn route(scope: Scope<AppState>) -> Scope<AppState> {
|
|
|
scope.resource("address", |r| r.method(Method::GET).f(get_address))
|
|
|
scope.resource("address", |r| r.method(Method::GET).f(get_address))
|
|
|
.nested("{root}/{zone}", |zone_scope| {
|
|
|
.nested("{root}/{zone}", |zone_scope| {
|
|
|
zone_scope
|
|
|
zone_scope
|
|
@ -44,7 +45,7 @@ fn parse_remote_info(remote_info: &str) -> Result<IpAddr, APIError> { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
fn get_address(req: &HttpRequest) -> HttpResponse {
|
|
|
|
|
|
|
|
|
fn get_address(req: &HttpRequest<AppState>) -> HttpResponse {
|
|
|
match req.connection_info().remote() {
|
|
|
match req.connection_info().remote() {
|
|
|
Some(remote_info) => {
|
|
|
Some(remote_info) => {
|
|
|
match parse_remote_info(remote_info) {
|
|
|
match parse_remote_info(remote_info) {
|
|
@ -61,7 +62,7 @@ fn get_address(req: &HttpRequest) -> HttpResponse { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
fn update_address_automatically(req: &HttpRequest) -> HttpResponse {
|
|
|
|
|
|
|
|
|
fn update_address_automatically(req: &HttpRequest<AppState>) -> HttpResponse {
|
|
|
match req.connection_info().remote() {
|
|
|
match req.connection_info().remote() {
|
|
|
Some(remote_info) => {
|
|
|
Some(remote_info) => {
|
|
|
match parse_remote_info(remote_info) {
|
|
|
match parse_remote_info(remote_info) {
|
|
@ -78,7 +79,7 @@ fn update_address_automatically(req: &HttpRequest) -> HttpResponse { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
fn update_address_manually(req: &HttpRequest) -> FutureResponse<HttpResponse> {
|
|
|
|
|
|
|
|
|
fn update_address_manually(req: &HttpRequest<AppState>) -> FutureResponse<HttpResponse> {
|
|
|
req.body()
|
|
|
req.body()
|
|
|
.limit(48)
|
|
|
.limit(48)
|
|
|
.from_err()
|
|
|
.from_err()
|
|
|