Skip to content

Commit 4bfdad5

Browse files
committed
bak
1 parent d3536ef commit 4bfdad5

File tree

6 files changed

+14
-18
lines changed

6 files changed

+14
-18
lines changed

server/src/admin_server.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,6 @@ pub mod service {
260260
_ => Ok(warp::reply::json(&domain_info).into_response()),
261261
},
262262
Err(e) => {
263-
let z = warp::reply();
264-
265263
let mut resp = e.to_string().into_response();
266264
*resp.status_mut() = StatusCode::BAD_REQUEST;
267265
Ok(resp)
@@ -470,7 +468,7 @@ pub mod service {
470468
pub(super) async fn revoke_version(
471469
domain_storage: Arc<DomainStorage>,
472470
query: DomainWithVersionOption,
473-
) -> Result<Response, Infallible> {
471+
) -> anyhow::Result<warp::reply::Response> {
474472
let DomainWithVersionOption { domain, version } = query;
475473
let resp = match domain_storage.get_domain_info_by_domain(&domain) {
476474
Some(info) => {
@@ -483,7 +481,7 @@ pub mod service {
483481
.upload_domain_with_version(domain, Some(version))
484482
.await
485483
{
486-
Ok(_) => Response::default(),
484+
Ok(_) => warp::reply::Response::default(),
487485
Err(e) => {
488486
let mut resp = e.to_string().into_response();
489487
*resp.status_mut() = StatusCode::BAD_REQUEST;

server/src/cors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub fn resp_cors_request<B:http_body::Body>(
4242
method: &Method,
4343
headers: &HeaderMap,
4444
origins: &Option<HashSet<HeaderValue>>,
45-
) -> Either<Validated, Response<B>> {
45+
) -> Either<Validated, warp::reply::Response> {
4646
match (headers.get(header::ORIGIN), method) {
4747
(Some(origin), &Method::OPTIONS) => {
4848
if !is_origin_allowed(origins, origin) {

server/src/service.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,13 @@ fn alias_redirect(uri: &Uri, https: bool, host: &str, external_port: u16) -> war
5656
}
5757

5858
// static file reply
59-
#[instrument(skip(uri, host, domain_storage, origin_opt))]
60-
async fn file_resp<A:http_body::Body, B:http_body::Body>(
59+
async fn file_resp<A:http_body::Body>(
6160
req: &Request<A>,
6261
uri: &Uri,
6362
host: &str,
6463
domain_storage: Arc<DomainStorage>,
6564
origin_opt: Option<Validated>,
66-
) -> Result<Response<B>, Infallible> {
65+
) -> Result<warp::reply::Response, Infallible> {
6766
let path = uri.path();
6867
let mut resp = match get_cache_file(path, host, domain_storage.clone()).await {
6968
Some(item) => {
@@ -117,7 +116,6 @@ fn get_authority<B:http_body::Body>(req: &Request<B>) -> Option<Authority> {
117116
})
118117
}
119118

120-
#[instrument(skip(service_config, domain_storage, challenge_path, external_port))]
121119
pub async fn create_http_service<B:http_body::Body>(
122120
req: Request<B>,
123121
service_config: Arc<ServiceConfig>,
@@ -180,7 +178,6 @@ pub async fn create_http_service<B:http_body::Body>(
180178
}
181179
}
182180

183-
#[instrument(skip(service_config, domain_storage, external_port))]
184181
pub async fn create_https_service<B:http_body::Body>(
185182
req: Request<B>,
186183
service_config: Arc<ServiceConfig>,
@@ -214,19 +211,19 @@ pub async fn create_https_service<B:http_body::Body>(
214211
}
215212
}
216213

217-
pub fn not_found<B:http_body::Body>() -> Response<B> {
214+
pub fn not_found<B:http_body::Body>() -> warp::reply::Response {
218215
let mut resp = Response::default();
219216
*resp.status_mut() = StatusCode::NOT_FOUND;
220217
resp
221218
}
222-
pub fn forbid<B:http_body::Body>() -> Response<B> {
219+
pub fn forbid() -> warp::reply::Response {
223220
let mut resp = Response::default();
224221
*resp.status_mut() = StatusCode::FORBIDDEN;
225222
resp
226223
}
227224

228225
pub fn resp(code: StatusCode, str: &'static str) -> warp::reply::Response {
229-
let mut response = str.into_response();
226+
let mut resp = str.into_response();
230227
*resp.status_mut() = code;
231228
resp
232229
}

server/src/static_file_filter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ pub async fn cache_or_file_reply<A:http_body::Body>(
223223
}
224224
}
225225

226-
fn cache_item_to_response_header<A:http_body::Body>(
227-
resp: &mut Response<A>,
226+
fn cache_item_to_response_header(
227+
resp: &mut Response<warp::reply::Response>,
228228
item: &CacheItem,
229229
modified: Option<LastModified>,
230230
) {

server/src/tls.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ pub(crate) fn load_ssl_file(
162162
Ok(CertifiedKey::new(certs, key))
163163
}
164164

165+
165166
/*
166167
enum State {
167168
Handshaking(tokio_rustls::Accept<AddrStream>),

server/src/web_server.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use futures_util::future::Either;
55
use hyper_util::server::conn::auto::Builder;
66
use hyper_util::rt::TokioIo;
77
use hyper::service::service_fn;
8-
use rustls::ServerConfig;
8+
use tokio_rustls::rustls::ServerConfig;
99
use socket2::{Domain, Socket, Type};
1010
use std::collections::HashMap;
1111
use std::convert::Infallible;
@@ -20,7 +20,7 @@ use crate::domain_storage::DomainStorage;
2020
use crate::service::{
2121
create_http_service, create_https_service, DomainServiceConfig, ServiceConfig,
2222
};
23-
use crate::tls::TlsAcceptor;
23+
//use crate::tls::TlsAcceptor;
2424

2525
async fn handler(rx: Receiver<()>, time: DateTime<Local>, http_or_https: &'static str) {
2626
rx.await.ok();
@@ -251,7 +251,7 @@ impl Server {
251251
});
252252
let server = HServer::from_tcp(listener)?.serve(make_svc);
253253
run_server!(server, rx);
254-
254+
255255
*/
256256
}
257257
Ok(())

0 commit comments

Comments
 (0)