projects
/
dnsseed-rust
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
852e939
)
Bump rand, drop SockAddr size by an additional 4 bytes
author
Matt Corallo
<git@bluematt.me>
Mon, 12 Jul 2021 01:28:41 +0000
(
01:28
+0000)
committer
Matt Corallo
<git@bluematt.me>
Mon, 12 Jul 2021 01:28:51 +0000
(
01:28
+0000)
Cargo.toml
patch
|
blob
|
history
src/datastore.rs
patch
|
blob
|
history
diff --git
a/Cargo.toml
b/Cargo.toml
index 7240bd1b9a19fda149aedb9545a9c81765a98599..ab04e15f4ef968cd59c5dbab9be0815a2b3d41f9 100644
(file)
--- a/
Cargo.toml
+++ b/
Cargo.toml
@@
-10,7
+10,7
@@
bgp-rs = "0.6"
tokio = "0.1"
bytes = "0.4"
futures = "0.1"
tokio = "0.1"
bytes = "0.4"
futures = "0.1"
-rand = "0.
6
"
+rand = "0.
8
"
regex = "1"
num_cpus = "1"
regex = "1"
num_cpus = "1"
diff --git
a/src/datastore.rs
b/src/datastore.rs
index 27987714d347f566ea79d662f6bc4343b9c314d8..1f2221029d6d2d76f79626f574c6fc64b066f86b 100644
(file)
--- a/
src/datastore.rs
+++ b/
src/datastore.rs
@@
-132,13
+132,17
@@
struct Node {
#[derive(Clone, PartialEq, Eq, Hash)]
enum SockAddr {
V4(SocketAddrV4),
#[derive(Clone, PartialEq, Eq, Hash)]
enum SockAddr {
V4(SocketAddrV4),
- V6((Ipv6Addr, u16)),
+ V6(([u16; 8], u16)),
+}
+#[inline]
+fn segs_to_ip6(segs: &[u16; 8]) -> Ipv6Addr {
+ Ipv6Addr::new(segs[0], segs[1], segs[2], segs[3], segs[4], segs[5], segs[6], segs[7])
}
impl From<SocketAddr> for SockAddr {
fn from(addr: SocketAddr) -> SockAddr {
match addr {
SocketAddr::V4(sa) => SockAddr::V4(sa),
}
impl From<SocketAddr> for SockAddr {
fn from(addr: SocketAddr) -> SockAddr {
match addr {
SocketAddr::V4(sa) => SockAddr::V4(sa),
- SocketAddr::V6(sa) => SockAddr::V6((sa.ip().
clone
(), sa.port())),
+ SocketAddr::V6(sa) => SockAddr::V6((sa.ip().
segments
(), sa.port())),
}
}
}
}
}
}
@@
-146,7
+150,7
@@
impl Into<SocketAddr> for &SockAddr {
fn into(self) -> SocketAddr {
match self {
&SockAddr::V4(sa) => SocketAddr::V4(sa),
fn into(self) -> SocketAddr {
match self {
&SockAddr::V4(sa) => SocketAddr::V4(sa),
- &SockAddr::V6(sa) => SocketAddr::V6(SocketAddrV6::new(s
a.0
, sa.1, 0, 0))
+ &SockAddr::V6(sa) => SocketAddr::V6(SocketAddrV6::new(s
egs_to_ip6(&sa.0)
, sa.1, 0, 0))
}
}
}
}
}
}
@@
-166,7
+170,7
@@
impl SockAddr {
pub fn ip(&self) -> IpAddr {
match *self {
SockAddr::V4(sa) => IpAddr::V4(sa.ip().clone()),
pub fn ip(&self) -> IpAddr {
match *self {
SockAddr::V4(sa) => IpAddr::V4(sa.ip().clone()),
- SockAddr::V6((ip, _)) => IpAddr::V6(
ip
),
+ SockAddr::V6((ip, _)) => IpAddr::V6(
segs_to_ip6(&ip)
),
}
}
}
}
}
}