mirror of
https://github.com/jedisct1/iptoasn-webservice
synced 2025-04-11 22:55:50 +02:00
up
This commit is contained in:
parent
41a4950ff3
commit
9c1eb2a7e4
@ -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"] }
|
||||
|
11
src/asns.rs
11
src/asns.rs
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user