crate::ix!();
#[derive(Debug,Serialize,Deserialize,Clone)]
pub struct Service {
pub base: NetAddr,
pub port: u16,
}
pub trait GetServiceRef {
fn service(&self) -> &Service;
}
pub trait GetServiceMut {
fn service_mut(&mut self) -> &mut Service;
}
impl Service {
delegate!{
to self.base {
pub fn is_relayable(&self) -> bool;
pub fn serialize<Stream>(&self, s: &mut Stream);
pub fn unserialize<Stream>(&mut self, s: &mut Stream);
pub fn serialize_v1array(&self, arr: &mut [u8; net_addr::V1_SERIALIZATION_SIZE]);
pub fn serialize_v1stream<Stream>(&self, s: &mut Stream);
pub fn serialize_v2stream<Stream>(&self, s: &mut Stream);
pub fn unserialize_v1array(&mut self, arr: &mut [u8; net_addr::V1_SERIALIZATION_SIZE]);
pub fn unserialize_v1stream<Stream>(&mut self, s: &mut Stream);
pub fn unserialize_v2stream<Stream>(&mut self, s: &mut Stream);
pub fn get_bip155network(&self) -> net_addr::BIP155Network;
pub fn set_net_from_bip155network(&mut self,
possible_bip155_net: u8,
address_size: usize) -> bool;
pub fn setip(&mut self, ip_in: &NetAddr);
pub fn set_legacy_ipv6(&mut self, ipv6: &[u8]);
pub fn set_internal(&mut self, name: &str) -> bool;
pub fn set_special(&mut self, addr: &String) -> bool;
pub fn set_tor(&mut self, addr: &String) -> bool;
pub fn seti2p(&mut self, addr: &String) -> bool;
pub fn is_bind_any(&self) -> bool;
pub fn is_ipv4(&self) -> bool;
pub fn is_ipv6(&self) -> bool;
pub fn isrfc1918(&self) -> bool;
pub fn isrfc2544(&self) -> bool;
pub fn isrfc3927(&self) -> bool;
pub fn isrfc6598(&self) -> bool;
pub fn isrfc5737(&self) -> bool;
pub fn isrfc3849(&self) -> bool;
pub fn isrfc3964(&self) -> bool;
pub fn isrfc6052(&self) -> bool;
pub fn isrfc4380(&self) -> bool;
pub fn isrfc4862(&self) -> bool;
pub fn isrfc4193(&self) -> bool;
pub fn isrfc6145(&self) -> bool;
pub fn isrfc4843(&self) -> bool;
pub fn isrfc7343(&self) -> bool;
pub fn is_he_net(&self) -> bool;
pub fn is_tor(&self) -> bool;
pub fn isi2p(&self) -> bool;
pub fn iscjdns(&self) -> bool;
pub fn is_local(&self) -> bool;
pub fn is_valid(&self) -> bool;
pub fn is_routable(&self) -> bool;
pub fn is_internal(&self) -> bool;
pub fn is_addr_v1compatible(&self) -> bool;
pub fn get_network(&self) -> Network;
pub fn get_in_addr(&self, pipv_4addr: *mut InAddr) -> bool;
pub fn get_in_6addr(&self, pipv_6addr: *mut In6Addr) -> bool;
pub fn has_linked_ipv4(&self) -> bool;
pub fn get_linked_ipv4(&self) -> u32;
pub fn get_net_class(&self) -> Network;
pub fn get_mappedas(&self, asmap: &Vec<bool>) -> u32;
pub fn get_group(&self, asmap: &Vec<bool>) -> Vec<u8>;
pub fn get_addr_bytes(&self) -> Vec<u8>;
pub fn get_hash(&self) -> u64;
pub fn get_reachability_from(&self, paddr_partner: *const NetAddr) -> i32;
}
}
}
impl Hash for Service {
fn hash<H: Hasher>(&self, state: &mut H) {
self.base.net.hash(state);
self.port.hash(state);
self.base.addr.hash(state);
}
}
lazy_static!{
}
impl PartialEq<Service> for Service {
#[inline] fn eq(&self, other: &Service) -> bool {
todo!();
}
}
impl Eq for Service {}
impl Ord for Service {
#[inline] fn cmp(&self, other: &Service) -> Ordering {
todo!();
}
}
impl PartialOrd<Service> for Service {
#[inline] fn partial_cmp(&self, other: &Service) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl From<&libc::sockaddr_in> for Service {
fn from(addr: &libc::sockaddr_in) -> Self {
todo!();
}
}
impl From<&libc::sockaddr_in6> for Service {
fn from(addr: &libc::sockaddr_in6) -> Self {
todo!();
}
}
impl Default for Service {
fn default() -> Self {
todo!();
}
}
impl Service {
pub fn new_from_net_addr(
cip: &NetAddr,
port_in: u16) -> Self {
todo!();
}
pub fn new_from_ip4(
ipv4_addr: &InAddr,
port_in: u16) -> Self {
todo!();
}
pub fn new_from_ip6(
ipv6_addr: &In6Addr,
port_in: u16) -> Self {
todo!();
}
pub fn set_sock_addr(&mut self, paddr: *const SocketAddr) -> bool {
todo!();
}
pub fn get_port(&self) -> u16 {
todo!();
}
pub fn get_sock_addr(&self,
paddr: *mut SocketAddr,
addrlen: *mut libc::socklen_t) -> bool {
todo!();
}
pub fn get_key(&self) -> Vec<u8> {
todo!();
}
pub fn to_string_port(&self) -> String {
todo!();
}
pub fn to_string_ip_port(&self) -> String {
todo!();
}
pub fn to_string(&self) -> String {
todo!();
}
}
pub struct ServiceHash {
salt_k0: u64,
salt_k1: u64,
}
impl Default for ServiceHash {
fn default() -> Self {
Self {
salt_k0: Self::get_rand_salt(),
salt_k1: Self::get_rand_salt(),
}
}
}
impl BuildHasher for ServiceHash {
type Hasher = SipHasher;
fn build_hasher(&self) -> Self::Hasher {
SipHasher::new_with_keys(self.salt_k0, self.salt_k1)
}
}
impl ServiceHash {
pub fn get_rand_salt() -> u64 {
get_rand(u64::MAX)
}
}