@@ -6,52 +6,25 @@ use crate::statistics::repository::Repository;
6
6
/// This function panics if the IP version does not match the event type.
7
7
pub async fn handle_event ( event : Event , stats_repository : & Repository ) {
8
8
match event {
9
- // UDP4
10
- Event :: Udp4Connect { context } => match context. client_socket_addr . ip ( ) {
9
+ Event :: UdpConnect { context } => match context. client_socket_addr . ip ( ) {
11
10
std:: net:: IpAddr :: V4 ( _) => {
12
11
stats_repository. increase_udp4_connections ( ) . await ;
13
12
}
14
- std:: net:: IpAddr :: V6 ( _) => {
15
- panic ! ( "IP Version 6 does not match the event type for connect" ) ;
16
- }
17
- } ,
18
- Event :: Udp4Announce { context } => match context. client_socket_addr . ip ( ) {
19
- std:: net:: IpAddr :: V4 ( _) => {
20
- stats_repository. increase_udp4_announces ( ) . await ;
21
- }
22
- std:: net:: IpAddr :: V6 ( _) => {
23
- panic ! ( "IP Version 6 does not match the event type for announce" ) ;
24
- }
25
- } ,
26
- Event :: Udp4Scrape { context } => match context. client_socket_addr . ip ( ) {
27
- std:: net:: IpAddr :: V4 ( _) => {
28
- stats_repository. increase_udp4_scrapes ( ) . await ;
29
- }
30
- std:: net:: IpAddr :: V6 ( _) => {
31
- panic ! ( "IP Version 6 does not match the event type for scrape" ) ;
32
- }
33
- } ,
34
-
35
- // UDP6
36
- Event :: Udp6Connect { context } => match context. client_socket_addr . ip ( ) {
37
- std:: net:: IpAddr :: V4 ( _) => {
38
- panic ! ( "IP Version 4 does not match the event type for connect" ) ;
39
- }
40
13
std:: net:: IpAddr :: V6 ( _) => {
41
14
stats_repository. increase_udp6_connections ( ) . await ;
42
15
}
43
16
} ,
44
- Event :: Udp6Announce { context } => match context. client_socket_addr . ip ( ) {
17
+ Event :: UdpAnnounce { context } => match context. client_socket_addr . ip ( ) {
45
18
std:: net:: IpAddr :: V4 ( _) => {
46
- panic ! ( "IP Version 4 does not match the event type for announce" ) ;
19
+ stats_repository . increase_udp4_announces ( ) . await ;
47
20
}
48
21
std:: net:: IpAddr :: V6 ( _) => {
49
22
stats_repository. increase_udp6_announces ( ) . await ;
50
23
}
51
24
} ,
52
- Event :: Udp6Scrape { context } => match context. client_socket_addr . ip ( ) {
25
+ Event :: UdpScrape { context } => match context. client_socket_addr . ip ( ) {
53
26
std:: net:: IpAddr :: V4 ( _) => {
54
- panic ! ( "IP Version 4 does not match the event type for scrape" ) ;
27
+ stats_repository . increase_udp4_scrapes ( ) . await ;
55
28
}
56
29
std:: net:: IpAddr :: V6 ( _) => {
57
30
stats_repository. increase_udp6_scrapes ( ) . await ;
@@ -75,7 +48,7 @@ mod tests {
75
48
let stats_repository = Repository :: new ( ) ;
76
49
77
50
handle_event (
78
- Event :: Udp4Connect {
51
+ Event :: UdpConnect {
79
52
context : ConnectionContext :: new (
80
53
SocketAddr :: new ( IpAddr :: V4 ( Ipv4Addr :: new ( 203 , 0 , 113 , 195 ) ) , 8080 ) ,
81
54
SocketAddr :: new ( IpAddr :: V4 ( Ipv4Addr :: new ( 203 , 0 , 113 , 196 ) ) , 6969 ) ,
@@ -95,7 +68,7 @@ mod tests {
95
68
let stats_repository = Repository :: new ( ) ;
96
69
97
70
handle_event (
98
- Event :: Udp4Announce {
71
+ Event :: UdpAnnounce {
99
72
context : ConnectionContext :: new (
100
73
SocketAddr :: new ( IpAddr :: V4 ( Ipv4Addr :: new ( 203 , 0 , 113 , 195 ) ) , 8080 ) ,
101
74
SocketAddr :: new ( IpAddr :: V4 ( Ipv4Addr :: new ( 203 , 0 , 113 , 196 ) ) , 6969 ) ,
@@ -115,7 +88,7 @@ mod tests {
115
88
let stats_repository = Repository :: new ( ) ;
116
89
117
90
handle_event (
118
- Event :: Udp4Scrape {
91
+ Event :: UdpScrape {
119
92
context : ConnectionContext :: new (
120
93
SocketAddr :: new ( IpAddr :: V4 ( Ipv4Addr :: new ( 203 , 0 , 113 , 195 ) ) , 8080 ) ,
121
94
SocketAddr :: new ( IpAddr :: V4 ( Ipv4Addr :: new ( 203 , 0 , 113 , 196 ) ) , 6969 ) ,
@@ -135,7 +108,7 @@ mod tests {
135
108
let stats_repository = Repository :: new ( ) ;
136
109
137
110
handle_event (
138
- Event :: Udp6Connect {
111
+ Event :: UdpConnect {
139
112
context : ConnectionContext :: new (
140
113
SocketAddr :: new ( IpAddr :: V6 ( Ipv6Addr :: new ( 0 , 0 , 0 , 0 , 203 , 0 , 113 , 195 ) ) , 8080 ) ,
141
114
SocketAddr :: new ( IpAddr :: V6 ( Ipv6Addr :: new ( 0 , 0 , 0 , 0 , 203 , 0 , 113 , 196 ) ) , 6969 ) ,
@@ -155,7 +128,7 @@ mod tests {
155
128
let stats_repository = Repository :: new ( ) ;
156
129
157
130
handle_event (
158
- Event :: Udp6Announce {
131
+ Event :: UdpAnnounce {
159
132
context : ConnectionContext :: new (
160
133
SocketAddr :: new ( IpAddr :: V6 ( Ipv6Addr :: new ( 0 , 0 , 0 , 0 , 203 , 0 , 113 , 195 ) ) , 8080 ) ,
161
134
SocketAddr :: new ( IpAddr :: V6 ( Ipv6Addr :: new ( 0 , 0 , 0 , 0 , 203 , 0 , 113 , 196 ) ) , 6969 ) ,
@@ -175,7 +148,7 @@ mod tests {
175
148
let stats_repository = Repository :: new ( ) ;
176
149
177
150
handle_event (
178
- Event :: Udp6Scrape {
151
+ Event :: UdpScrape {
179
152
context : ConnectionContext :: new (
180
153
SocketAddr :: new ( IpAddr :: V6 ( Ipv6Addr :: new ( 0 , 0 , 0 , 0 , 203 , 0 , 113 , 195 ) ) , 8080 ) ,
181
154
SocketAddr :: new ( IpAddr :: V6 ( Ipv6Addr :: new ( 0 , 0 , 0 , 0 , 203 , 0 , 113 , 196 ) ) , 6969 ) ,
0 commit comments