mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 02:35:31 +00:00
aquatic_udp: move more announce logic into common code
This commit is contained in:
parent
c1dd50d0c9
commit
32113ea2f3
5 changed files with 67 additions and 91 deletions
|
|
@ -28,7 +28,35 @@ impl Into<Response> for ConnectedResponse {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn handle_announce_request<I: Ip>(
|
||||
pub fn handle_announce_request(
|
||||
config: &Config,
|
||||
rng: &mut SmallRng,
|
||||
torrents: &mut TorrentMaps,
|
||||
request: AnnounceRequest,
|
||||
src: SocketAddr,
|
||||
peer_valid_until: ValidUntil,
|
||||
) -> AnnounceResponse {
|
||||
match convert_ipv4_mapped_ipv6(src.ip()) {
|
||||
IpAddr::V4(ip) => handle_announce_request_inner(
|
||||
config,
|
||||
rng,
|
||||
&mut torrents.ipv4,
|
||||
request,
|
||||
ip,
|
||||
peer_valid_until,
|
||||
),
|
||||
IpAddr::V6(ip) => handle_announce_request_inner(
|
||||
config,
|
||||
rng,
|
||||
&mut torrents.ipv6,
|
||||
request,
|
||||
ip,
|
||||
peer_valid_until,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_announce_request_inner<I: Ip>(
|
||||
config: &Config,
|
||||
rng: &mut SmallRng,
|
||||
torrents: &mut TorrentMap<I>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue