1
0
mirror of https://github.com/jedisct1/iptoasn-webservice synced 2025-04-11 22:55:50 +02:00
This commit is contained in:
Frank Denis 2025-04-06 20:06:04 +02:00
parent 41a4950ff3
commit 9c1eb2a7e4
2 changed files with 8 additions and 5 deletions

View File

@ -17,7 +17,7 @@ hyper = { version = "1.6", features = ["server", "http1", "client"] }
hyper-util = { version = "0.1", features = ["tokio", "client", "http1"] }
http-body-util = "0.1"
tokio = { version = "1.44", features = ["full"] }
hyper-rustls = { version = "0.26", features = ["http1", "http2", "tls12", "webpki-roots"] }
hyper-rustls = { version = "0.26", features = ["http1", "http2", "webpki-roots"] }
log = "0.4"
env_logger = "0.11"
serde = { version = "1.0", features = ["derive"] }

View File

@ -5,6 +5,7 @@ use hyper::body::Bytes;
use hyper::{Method, StatusCode};
use hyper_rustls::HttpsConnectorBuilder;
use hyper_util::client::legacy::Client;
use hyper_util::rt::TokioExecutor;
use std::cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd};
use std::collections::BTreeSet;
use std::io::prelude::*;
@ -76,15 +77,17 @@ impl Asns {
// Handle HTTP or HTTPS URL
info!("Loading the database from {}", url);
// Create an HTTPS connector that can handle both HTTP and HTTPS with TLS 1.3 support
// Create an HTTPS connector with TLS 1.3 support
let https = HttpsConnectorBuilder::new()
.with_native_roots()
.expect("Failed to load native roots")
.https_or_http()
.enable_http1()
.enable_http2() // Enable HTTP/2 for better performance
.build();
let client = Client::builder(hyper_util::rt::TokioExecutor::new())
.build::<_, Empty<Bytes>>(https);
// Create a client with the HTTPS connector
let client = Client::builder(TokioExecutor::new()).build::<_, Empty<Bytes>>(https);
// Create the request
let req = Request::builder()
@ -97,7 +100,7 @@ impl Asns {
"Failed to create request"
})?;
// Try to send the request and get the response
// Send the request and get the response
match client.request(req).await {
Ok(res) => {
if res.status() != StatusCode::OK {