Rename some identifiers in tor-linkspec.

By convention, rust accessor functions don't start with 'get'.
This commit is contained in:
Nick Mathewson 2020-09-28 15:29:39 -04:00
parent 3b3a6736f6
commit 05da5a7f73
6 changed files with 33 additions and 33 deletions

View File

@ -27,7 +27,7 @@ use rand::thread_rng;
/// Launch an authenticated channel to a relay.
async fn connect<C: ChanTarget>(target: &C) -> Result<Channel> {
let addr = target
.get_addrs()
.addrs()
.get(0) // Instead we might want to try multiple addresses in parallel
.ok_or(Error::Misc("No addresses for chosen relay‽"))?;

View File

@ -12,11 +12,11 @@ use tor_llcrypto::pk;
pub trait ChanTarget {
/// Return the addresses at which you can connect to this relay
// TODO: bad API
fn get_addrs(&self) -> &[SocketAddr];
fn addrs(&self) -> &[SocketAddr];
/// Return the ed25519 identity for this relay.
fn get_ed_identity(&self) -> &pk::ed25519::PublicKey;
fn ed_identity(&self) -> &pk::ed25519::PublicKey;
/// Return the RSA identity for this relay.
fn get_rsa_identity(&self) -> &pk::rsa::RSAIdentity;
fn rsa_identity(&self) -> &pk::rsa::RSAIdentity;
}
/// Information about a Tor relay used to extend a circuit to it.
@ -26,17 +26,17 @@ pub trait ChanTarget {
pub trait CircTarget: ChanTarget {
/// Return a new vector of link specifiers for this relay.
// TODO: bad API
fn get_linkspecs(&self) -> Vec<crate::LinkSpec> {
fn linkspecs(&self) -> Vec<crate::LinkSpec> {
let mut result = Vec::new();
result.push(self.get_ed_identity().clone().into());
result.push(self.get_rsa_identity().clone().into());
for addr in self.get_addrs().iter() {
result.push(self.ed_identity().clone().into());
result.push(self.rsa_identity().clone().into());
for addr in self.addrs().iter() {
result.push(addr.into());
}
result
}
/// Return the ntor onion key for this relay
fn get_ntor_onion_key(&self) -> &pk::curve25519::PublicKey;
fn ntor_onion_key(&self) -> &pk::curve25519::PublicKey;
/// Return the subprotocols implemented by this relay.
fn get_protovers(&self) -> &tor_protover::Protocols;
fn protovers(&self) -> &tor_protover::Protocols;
}

View File

@ -405,7 +405,7 @@ impl<'a> Relay<'a> {
}
/// Return the RSAIdentity for this relay.
pub fn get_rsa_id(&self) -> &RSAIdentity {
self.rs.get_rsa_identity()
self.rs.rsa_identity()
}
/// Return true if this relay and `other` seem to be the same relay.
///
@ -433,25 +433,25 @@ impl<'a> Relay<'a> {
}
impl<'a> tor_linkspec::ChanTarget for Relay<'a> {
fn get_addrs(&self) -> &[std::net::SocketAddr] {
self.rs.get_addrs()
fn addrs(&self) -> &[std::net::SocketAddr] {
self.rs.addrs()
}
fn get_ed_identity(&self) -> &ll::pk::ed25519::PublicKey {
fn ed_identity(&self) -> &ll::pk::ed25519::PublicKey {
self.get_id().unwrap()
}
fn get_rsa_identity(&self) -> &RSAIdentity {
fn rsa_identity(&self) -> &RSAIdentity {
self.get_rsa_id()
}
}
impl<'a> tor_linkspec::CircTarget for Relay<'a> {
fn get_ntor_onion_key(&self) -> &ll::pk::curve25519::PublicKey {
fn ntor_onion_key(&self) -> &ll::pk::curve25519::PublicKey {
// XXXX unwrap might fail if is_usable is false
self.md.unwrap().get_ntor_key()
}
/// Return the subprotocols implemented by this relay.
fn get_protovers(&self) -> &tor_protover::Protocols {
fn protovers(&self) -> &tor_protover::Protocols {
// XXXX unwrap might fail if is_usable is false
self.rs.get_protovers().as_ref().unwrap()
self.rs.protovers().as_ref().unwrap()
}
}

View File

@ -218,7 +218,7 @@ impl MDConsensusRouterStatus {
&self.md_digest
}
/// Return the expected microdescriptor digest for this routerstatus
pub fn get_rsa_identity(&self) -> &RSAIdentity {
pub fn rsa_identity(&self) -> &RSAIdentity {
&self.identity
}
/// Return an iterator of ORPort addresses for this routerstatus
@ -230,11 +230,11 @@ impl MDConsensusRouterStatus {
&self.weight
}
/// Return the ORPort addresses of this routerstatus
pub fn get_addrs(&self) -> &[net::SocketAddr] {
pub fn addrs(&self) -> &[net::SocketAddr] {
&self.addrs[..]
}
/// Return the protovers that this routerstatus says it implements.
pub fn get_protovers(&self) -> &Option<Protocols> {
pub fn protovers(&self) -> &Option<Protocols> {
&self.protos
}
}

View File

@ -173,15 +173,15 @@ impl<T: AsyncRead + AsyncWrite + Send + Unpin + 'static> UnverifiedChannel<T> {
// We need to check the following lines of authentication:
//
// First, to bind the ed identity to the channel.
// peer.get_ed_identity() matches the key in...
// peer.ed_identity() matches the key in...
// IDENTITY_V_SIGNING cert, which signs...
// SIGNING_V_TLS_CERT cert, which signs peer_cert.
//
// Second, to bind the rsa identity to the ed identity:
// peer.get_rsa_identity() matches the key in...
// peer.rsa_identity() matches the key in...
// the x.509 RSA identity certificate (type 2), which signs...
// the RSA->Ed25519 crosscert (type 7), which signs...
// peer.get_ed_identity().
// peer.ed_identity().
let c = &self.certs_cell;
let id_sk = c.parse_ed_cert(CertType::IDENTITY_V_SIGNING)?;
@ -265,11 +265,11 @@ impl<T: AsyncRead + AsyncWrite + Send + Unpin + 'static> UnverifiedChannel<T> {
// We do this _last_, since "this is the wrong peer" is
// usually a different situation than "this peer couldn't even
// identify itself right."
if identity_key != peer.get_ed_identity() {
if identity_key != peer.ed_identity() {
return Err(Error::ChanProto("Peer ed25519 id not as expected".into()));
}
if &pkrsa.to_rsa_identity() != peer.get_rsa_identity() {
if &pkrsa.to_rsa_identity() != peer.rsa_identity() {
return Err(Error::ChanProto("Peer RSA id not as expected".into()));
}

View File

@ -274,12 +274,12 @@ impl ClientCirc {
use crate::crypto::cell::Tor1RelayCrypto;
use crate::crypto::handshake::ntor::{NtorClient, NtorPublicKey};
let key = NtorPublicKey {
id: target.get_rsa_identity().clone(),
pk: *target.get_ntor_onion_key(),
id: target.rsa_identity().clone(),
pk: *target.ntor_onion_key(),
};
let linkspecs = target.get_linkspecs();
let linkspecs = target.linkspecs();
let supports_flowctrl_1 = target
.get_protovers()
.protovers()
.supports_known_subver(tor_protover::ProtoKind::FlowCtrl, 1);
self.extend_impl::<R, Tor1RelayCrypto, NtorClient>(
rng,
@ -595,11 +595,11 @@ impl PendingClientCirc {
handshake_type: 0x0002, // ntor
};
let key = NtorPublicKey {
id: target.get_rsa_identity().clone(),
pk: *target.get_ntor_onion_key(),
id: target.rsa_identity().clone(),
pk: *target.ntor_onion_key(),
};
let supports_flowctrl_1 = target
.get_protovers()
.protovers()
.supports_known_subver(tor_protover::ProtoKind::FlowCtrl, 1);
self.create_impl::<R, Tor1RelayCrypto, NtorClient, _>(rng, &wrap, &key, supports_flowctrl_1)
.await