b32 i2p address; internal format not condensed/decoded.
More...
#include <i2p_address.h>
b32 i2p address; internal format not condensed/decoded.
Definition at line 51 of file i2p_address.h.
◆ i2p_address() [1/2]
| net::i2p_address::i2p_address |
( |
| ) |
|
|
noexcept |
An object with port() == 0 and host_str() == unknown_str().
Definition at line 99 of file i2p_address.cpp.
100 : port_(0)
101 {
102 static_assert(sizeof(unknown_host) <= sizeof(host_), "bad buffer size");
103 std::memcpy(host_, unknown_host, sizeof(unknown_host));
104 std::memset(host_ + sizeof(unknown_host), 0, sizeof(host_) - sizeof(unknown_host));
105 }
◆ i2p_address() [2/2]
| net::i2p_address::i2p_address |
( |
const i2p_address & | rhs | ) |
|
|
noexcept |
Definition at line 145 of file i2p_address.cpp.
146 : port_(rhs.port_)
147 {
148 std::memcpy(host_, rhs.host_, sizeof(host_));
149 }
◆ ~i2p_address()
| net::i2p_address::~i2p_address |
( |
| ) |
|
|
default |
◆ _load()
Load from epee p2p format, and.
- Returns
- false if not valid tor address
Definition at line 123 of file i2p_address.cpp.
124 {
126 if (
in._load(src, hparent) &&
in.host.size() <
sizeof(host_) && (
in.host == unknown_host || !host_check(
in.host).has_error()))
127 {
128 std::memcpy(host_,
in.host.data(),
in.host.size());
129 std::memset(host_ +
in.host.size(), 0,
sizeof(host_) -
in.host.size());
131 return true;
132 }
133 static_assert(sizeof(unknown_host) <= sizeof(host_), "bad buffer size");
134 std::memcpy(host_, unknown_host, sizeof(unknown_host));
135 port_ = 0;
136 return false;
137 }
◆ buffer_size()
| constexpr std::size_t net::i2p_address::buffer_size |
( |
| ) |
|
|
inlinestaticconstexprnoexcept |
- Returns
- Size of internal buffer for host.
Definition at line 61 of file i2p_address.h.
61{ return sizeof(host_); }
◆ equal()
| bool net::i2p_address::equal |
( |
const i2p_address & | rhs | ) |
const |
|
noexcept |
Definition at line 167 of file i2p_address.cpp.
168 {
170 }
bool is_same_host(const i2p_address &rhs) const noexcept
◆ get_type_id()
|
|
inlinestaticconstexprnoexcept |
◆ get_zone()
|
|
inlinestaticconstexprnoexcept |
◆ host_str()
| const char * net::i2p_address::host_str |
( |
| ) |
const |
|
inlinenoexcept |
◆ is_blockable()
| bool net::i2p_address::is_blockable |
( |
| ) |
const |
|
inlinenoexcept |
- Returns
- !is_unknown().
Definition at line 123 of file i2p_address.h.
bool is_unknown() const noexcept
◆ is_local()
| constexpr bool net::i2p_address::is_local |
( |
| ) |
|
|
inlinestaticconstexprnoexcept |
◆ is_loopback()
| constexpr bool net::i2p_address::is_loopback |
( |
| ) |
|
|
inlinestaticconstexprnoexcept |
◆ is_same_host()
| bool net::i2p_address::is_same_host |
( |
const i2p_address & | rhs | ) |
const |
|
noexcept |
- Returns
- True if i2p addresses are identical.
Definition at line 177 of file i2p_address.cpp.
178 {
179 return std::strcmp(
host_str(), rhs.host_str()) == 0;
180 }
const char * host_str() const noexcept
◆ is_unknown()
| bool net::i2p_address::is_unknown |
( |
| ) |
const |
|
noexcept |
- Returns
- True if default constructed or via unknown().
Definition at line 161 of file i2p_address.cpp.
162 {
163 static_assert(1 <= sizeof(host_), "host size too small");
164 return host_[0] == '<';
165 }
◆ less()
| bool net::i2p_address::less |
( |
const i2p_address & | rhs | ) |
const |
|
noexcept |
Definition at line 172 of file i2p_address.cpp.
173 {
174 return std::strcmp(
host_str(), rhs.host_str()) < 0 ||
port() < rhs.port();
175 }
std::uint16_t port() const noexcept
◆ make()
| expect< i2p_address > net::i2p_address::make |
( |
boost::string_ref | address, |
|
|
std::uint16_t | default_port = 0 ) |
|
static |
Parse address in b32 i2p format (i.e. x.b32.i2p:80) with default_port being used if port is not specified in address.
Definition at line 107 of file i2p_address.cpp.
108 {
110 const boost::string_ref
port =
111 address.substr(host.size() + (host.size() ==
address.size() ? 0 : 1));
112
114
115 std::uint16_t porti = default_port;
118
119 static_assert(b32_length + sizeof(tld) == sizeof(i2p_address::host_), "bad internal host size");
120 return i2p_address{host, porti};
121 }
#define ELECTRONEUM_CHECK(...)
Check expect<void> and return errors in current scope.
@ invalid_port
Outside of 0-65535 range.
◆ operator=()
| i2p_address & net::i2p_address::operator= |
( |
const i2p_address & | rhs | ) |
|
|
noexcept |
Definition at line 151 of file i2p_address.cpp.
152 {
153 if (this != std::addressof(rhs))
154 {
155 port_ = rhs.port_;
156 std::memcpy(host_, rhs.host_, sizeof(host_));
157 }
158 return *this;
159 }
◆ port()
| std::uint16_t net::i2p_address::port |
( |
| ) |
const |
|
inlinenoexcept |
- Returns
- Port value or 0 if unspecified.
Definition at line 107 of file i2p_address.h.
◆ store()
Store in epee p2p format.
Definition at line 139 of file i2p_address.cpp.
140 {
141 const i2p_serialized
out{std::string{host_}, port_};
142 return out.store(
dest, hparent);
143 }
CXA_THROW_INFO_T void(* dest)(void *))
◆ str()
| std::string net::i2p_address::str |
( |
| ) |
const |
- Returns
- x.b32.i2p or x.b32.i2p:z if port() != 0.
Definition at line 182 of file i2p_address.cpp.
183 {
184 const std::size_t host_length = std::strlen(
host_str());
185 const std::size_t port_length =
186 port_ == 0 ? 0 : std::numeric_limits<std::uint16_t>::digits10 + 2;
187
189 out.reserve(host_length + port_length);
191
192 if (port_ != 0)
193 {
195 namespace karma = boost::spirit::karma;
196 karma::generate(std::back_inserter(out), karma::ushort_,
port());
197 }
199 }
◆ unknown()
| i2p_address net::i2p_address::unknown |
( |
| ) |
|
|
inlinestaticnoexcept |
◆ unknown_str()
| const char * net::i2p_address::unknown_str |
( |
| ) |
|
|
staticnoexcept |
The documentation for this class was generated from the following files:
- /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/src/net/i2p_address.h
- /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/src/net/i2p_address.cpp