use hostname instead of internal IP
Some checks are pending
ci/woodpecker/push/publish Pipeline is pending
Some checks are pending
ci/woodpecker/push/publish Pipeline is pending
This commit is contained in:
parent
fef44a592f
commit
b0d1402431
1 changed files with 7 additions and 5 deletions
|
@ -1,6 +1,5 @@
|
|||
use actix_web::{get, routes, web, HttpRequest, HttpResponse, Responder};
|
||||
use actix_web::{dev::ConnectionInfo, get, routes, web, HttpRequest, HttpResponse, Responder};
|
||||
use askama::Template;
|
||||
use std::net::SocketAddr;
|
||||
|
||||
use crate::config::Config;
|
||||
|
||||
|
@ -8,7 +7,10 @@ use crate::config::Config;
|
|||
#[get("/.well-known/security.txt")]
|
||||
#[get("/security.txt")]
|
||||
pub async fn security(req: HttpRequest, config: web::Data<Config>) -> impl Responder {
|
||||
HttpResponse::Ok().body(get_security(config.get_ref().clone(), req.peer_addr()))
|
||||
HttpResponse::Ok().body(get_security(
|
||||
config.get_ref().clone(),
|
||||
req.connection_info().to_owned(),
|
||||
))
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
|
@ -19,11 +21,11 @@ struct SecurityTemplate {
|
|||
url: String,
|
||||
}
|
||||
|
||||
fn get_security(config: Config, addr: Option<SocketAddr>) -> String {
|
||||
fn get_security(config: Config, info: ConnectionInfo) -> String {
|
||||
let data = SecurityTemplate {
|
||||
contact: config.mail.unwrap_or_default(),
|
||||
pref_lang: config.lang.unwrap_or_default(),
|
||||
url: format!("{}/.well-known/security.txt", addr.unwrap().ip()),
|
||||
url: format!("{}/.well-known/security.txt", info.host()),
|
||||
};
|
||||
|
||||
data.render().unwrap()
|
||||
|
|
Loading…
Reference in a new issue