E2SAR 0.4.0
Loading...
Searching...
No Matches
e2sarUtil.hpp
1#ifndef E2SARUTILHPP
2#define E2SARUTILHPP
3
4#include <fstream>
5#include <vector>
6#include <boost/url.hpp>
7#include <boost/algorithm/string.hpp>
8#include <boost/asio.hpp>
9#include <boost/chrono.hpp>
10#include <boost/thread.hpp>
11#include <boost/log/trivial.hpp>
12#include <boost/log/common.hpp>
13#include <boost/log/sinks.hpp>
14#include <boost/log/sources/logger.hpp>
15#include <boost/log/expressions.hpp>
16#include <boost/log/attributes.hpp>
17#include <boost/log/support/date_time.hpp>
18#include <boost/core/null_deleter.hpp>
19#include <boost/shared_ptr.hpp>
20
21#include "grpc/loadbalancer.grpc.pb.h"
22
23#include "e2sarError.hpp"
24
25using namespace boost::asio;
26using namespace std::string_literals;
27using namespace boost::log;
28
29#define BOOST_LOG_FLUSH() sink->flush()
30#define BOOST_MLL_START(PREF) { std::ostringstream PREF_ostr;
31#define BOOST_MLL_LOG(PREF) PREF_ostr
32#define BOOST_MLL_STOP(PREF) BOOST_LOG_SEV(lg, trivial::info) << PREF_ostr.str(); } BOOST_LOG_FLUSH();
33
34#define BOOST_LOG_INFO() BOOST_LOG_SEV(lg, trivial::info)
35#define BOOST_LOG_WARN() BOOST_LOG_SEV(lg, trivial::warning)
36#define BOOST_LOG_ERR() BOOST_LOG_SEV(lg, trivial::error)
37
38/***
39 * Supporting classes for E2SAR
40 */
41namespace e2sar
42{
43 typedef sinks::asynchronous_sink<sinks::text_ostream_backend> text_sink;
44 extern boost::shared_ptr<text_sink> sink;
45 extern sources::severity_logger_mt<trivial::severity_level> lg;
46
47 const u_int16_t DATAPLANE_PORT = 19522;
48 const u_int16_t DATAPLANE_PORT_MIN = 16384;
49 const u_int16_t DATAPLANE_PORT_MAX = 32767;
50
59 {
60 public:
61 enum class TokenType: u_int16_t {
62 // contains overloaded names according to old and new token type hierarchy
63 all=0, admin=1, load_balancer=admin, instance=2, reservation=instance, session=3, END
64 };
65 inline static constexpr size_t ttAsIdx(TokenType tt)
66 {
67 return static_cast<size_t>(tt);
68 }
69 inline static const std::string toString(TokenType tt)
70 {
71 switch(tt) {
72 case TokenType::all: return "ALL"s;
73 case TokenType::admin: return "LOAD_BALANCER"s;
74 case TokenType::instance: return "RESERVATION"s;
75 case TokenType::session: return "SESSION"s;
76 default: return "UNKNOWN"s;
77 }
78 }
79 static const size_t tokenTypeCardinality = static_cast<size_t>(TokenType::END);
80
81
82 enum class TokenPermission: u_int16_t {
83 // 'register' is a keyword in C++, so adding '_' to names
84 _read_only_, _register_, _reserve_, _update_, END
85 };
86 inline static const std::string toString(TokenPermission tt)
87 {
88 switch(tt) {
89 case TokenPermission::_read_only_: return "READ"s;
90 case TokenPermission::_register_: return "REGISTER"s;
91 case TokenPermission::_reserve_: return "RESERVE"s;
92 case TokenPermission::_update_: return "UPDATE"s;
93 default: return "UNKNOWN"s;
94 }
95 }
96 static const size_t tokenPermissionCardinality = static_cast<size_t>(TokenPermission::END);
97
98 private:
99 std::string rawURI;
101 bool haveDatav4;
102 bool haveDatav6;
104 bool haveSyncv4;
105 bool haveSyncv6;
107 bool useTls;
109 bool preferV6;
110
112 u_int16_t syncPortv4;
113 u_int16_t syncPortv6;
115 u_int16_t cpPort;
117 u_int16_t dataMinPort;
118 u_int16_t dataMaxPort;
119
121 std::string lbName;
123 std::string lbId;
125 std::array<std::string, tokenTypeCardinality> tokensByType;
127 std::string sessionId;
128
130 ip::address dataAddrv4;
131 ip::address dataAddrv6;
133 ip::address syncAddrv4;
134 ip::address syncAddrv6;
136 ip::address cpAddr;
137 std::string cpHost;
138
139 public:
146 EjfatURI(const std::string &uri, TokenType tt=TokenType::admin, bool preferV6=false);
147
150
151 friend bool operator== (const EjfatURI &u1, const EjfatURI &u2);
152
153 friend inline bool operator!= (const EjfatURI &u1, const EjfatURI &u2)
154 {
155 return !(u1 == u2);
156 }
157
159 inline bool get_useTls() const
160 {
161 return useTls;
162 }
163
165 inline void set_Token(const std::string &t, TokenType tt)
166 {
167 tokensByType[ttAsIdx(tt)] = t;
168 }
169
171 inline void set_InstanceToken(const std::string &t)
172 {
173 tokensByType[ttAsIdx(TokenType::instance)] = t;
174 }
175
177 inline void set_SessionToken(const std::string &t)
178 {
179 tokensByType[ttAsIdx(TokenType::session)] = t;
180 }
181
183 inline const result<std::string> get_InstanceToken() const
184 {
185 auto idx = ttAsIdx(TokenType::instance);
186 if (!tokensByType[idx].empty())
187 return tokensByType[idx];
188 else
189 return E2SARErrorInfo{E2SARErrorc::ParameterNotAvailable, "Instance token not available"s};
190 }
191
193 inline const result<std::string> get_SessionToken() const
194 {
195 auto idx = ttAsIdx(TokenType::session);
196 if (!tokensByType[idx].empty())
197 return tokensByType[idx];
198 else
199 return E2SARErrorInfo{E2SARErrorc::ParameterNotAvailable, "Session token not available"s};
200 }
201
203 inline const result<std::string> get_AdminToken() const
204 {
205 auto idx = ttAsIdx(TokenType::admin);
206 if (!tokensByType[idx].empty())
207 return tokensByType[idx];
208 else
209 return E2SARErrorInfo{E2SARErrorc::ParameterNotAvailable, "Admin token not available"s};
210 }
211
213 inline void set_lbName(const std::string &n)
214 {
215 lbName = n;
216 }
217
219 inline void set_lbId(const std::string &i)
220 {
221 lbId = i;
222 }
223
225 inline void set_sessionId(const std::string &i)
226 {
227 sessionId = i;
228 }
229
233 inline void set_syncAddr(const std::pair<ip::address, u_int16_t> &a)
234 {
235 if (a.first.is_v4()) {
236 syncAddrv4 = a.first;
237 syncPortv4 = a.second;
238 haveSyncv4 = true;
239 } else {
240 syncAddrv6 = a.first;
241 syncPortv6 = a.second;
242 haveSyncv6 = true;
243 }
244 }
245
250 inline void set_dataAddr(const std::pair<ip::address, std::pair<u_int16_t, u_int16_t>> &a)
251 {
252 if (a.first.is_v4()) {
253 dataAddrv4 = a.first;
254 haveDatav4 = true;
255 }
256 else {
257 dataAddrv6 = a.first;
258 haveDatav6 = true;
259 }
260 dataMinPort = a.second.first;
261 dataMaxPort = a.second.second;
262 }
263
267 inline void set_dataPortRange(u_int16_t minPort, u_int16_t maxPort)
268 {
269 dataMinPort = minPort;
270 dataMaxPort = maxPort;
271 }
272
274 inline const std::string get_lbName() const
275 {
276 return lbName;
277 }
278
280 inline const std::string get_lbId() const
281 {
282 return lbId;
283 }
284
286 inline const std::string get_sessionId() const
287 {
288 return sessionId;
289 }
290
292 inline const result<std::pair<ip::address, u_int16_t>> get_cpAddr() const
293 {
294 return std::pair<ip::address, u_int16_t>(cpAddr, cpPort);
295 }
296
298 inline const result<std::pair<std::string, u_int16_t>> get_cpHost() const
299 {
300 if (!cpHost.empty())
301 return std::pair<std::string, u_int16_t>(cpHost, cpPort);
302 else
303 return E2SARErrorInfo{E2SARErrorc::ParameterNotAvailable, "Control plane hostname not available"s};
304 }
305
307 inline const bool has_dataAddrv4() const
308 {
309 return haveDatav4;
310 }
311
313 inline const bool has_dataAddrv6() const
314 {
315 return haveDatav6;
316 }
317
319 inline const bool has_dataAddr() const
320 {
321 return haveDatav4 || haveDatav6;
322 }
323
325 inline const bool has_syncAddr() const
326 {
327 return haveSyncv4 || haveSyncv6;
328 }
329
331 inline const bool has_syncAddrv4() const
332 {
333 return haveSyncv4;
334 }
335
337 inline const bool has_syncAddrv6() const
338 {
339 return haveSyncv6;
340 }
341
343 inline const result<std::pair<ip::address, std::pair<u_int16_t, u_int16_t>>> get_dataAddrv4() const noexcept
344 {
345 if (haveDatav4)
346 return std::make_pair(dataAddrv4, std::make_pair(dataMinPort, dataMaxPort));
347 return E2SARErrorInfo{E2SARErrorc::ParameterNotAvailable, "Data plane address not available"s};
348 }
349
351 inline const result<std::pair<ip::address, std::pair<u_int16_t, u_int16_t>>> get_dataAddrv6() const noexcept
352 {
353 if (haveDatav6)
354 return std::make_pair(dataAddrv6, std::make_pair(dataMinPort, dataMaxPort));
355 return E2SARErrorInfo{E2SARErrorc::ParameterNotAvailable, "Data plane address not available"s};
356 }
357
359 inline const result<std::pair<u_int16_t, u_int16_t>> get_dataPortRange() const noexcept
360 {
361 if (haveDatav4 || haveDatav6)
362 return std::pair<u_int16_t, u_int16_t>(dataMinPort, dataMaxPort);
363 return E2SARErrorInfo{E2SARErrorc::ParameterNotAvailable, "Data plane address not available"s};
364 }
365
367 inline const result<std::pair<ip::address, u_int16_t>> get_syncAddrv4() const noexcept
368 {
369 if (haveSyncv4)
370 return std::pair<ip::address, u_int16_t>(syncAddrv4, syncPortv4);
371 return E2SARErrorInfo{E2SARErrorc::ParameterNotAvailable, "Sync v4 address not available"s};
372 }
373
375 inline const result<std::pair<ip::address, u_int16_t>> get_syncAddrv6() const noexcept
376 {
377 if (haveSyncv6)
378 return std::pair<ip::address, u_int16_t>(syncAddrv6, syncPortv6);
379 return E2SARErrorInfo{E2SARErrorc::ParameterNotAvailable, "Sync v6 address not available"s};
380 }
381
383 inline const result<std::pair<ip::address, u_int16_t>> get_syncAddr() const noexcept
384 {
385 if (preferV6 && haveSyncv6)
386 return std::pair<ip::address, u_int16_t>(syncAddrv6, syncPortv6);
387 if (haveSyncv4)
388 return std::pair<ip::address, u_int16_t>(syncAddrv4, syncPortv4);
389 if (haveSyncv6)
390 return std::pair<ip::address, u_int16_t>(syncAddrv6, syncPortv6);
391 return E2SARErrorInfo{E2SARErrorc::ParameterNotAvailable, "Sync address not available"s};
392 }
397 operator std::string() const;
398
399 const std::string to_string(TokenType tt = TokenType::admin) const;
400
406 static inline result<EjfatURI> getFromEnv(const std::string &envVar = "EJFAT_URI"s,
407 TokenType tt=TokenType::admin, bool preferV6=false) noexcept
408 {
409 const char *envStr = std::getenv(envVar.c_str());
410 if (envStr != nullptr)
411 {
412 try
413 {
414 return EjfatURI(envStr, tt, preferV6);
415 }
416 catch (const E2SARException &e)
417 {
418 return E2SARErrorInfo{E2SARErrorc::CaughtException, "Unable to parse EJFAT_URI from environment variable: "s + static_cast<std::string>(e)};
419 }
420 }
421 return E2SARErrorInfo{E2SARErrorc::Undefined, "Environment variable "s + envVar + " not defined."s};
422 }
423
429 static inline result<EjfatURI> getFromString(const std::string &uriStr,
430 TokenType tt=TokenType::admin, bool preferV6=false) noexcept
431 {
432 try
433 {
434 return EjfatURI(uriStr, tt, preferV6);
435 }
436 catch (const E2SARException &e)
437 {
438 return E2SARErrorInfo{E2SARErrorc::CaughtException, "Unable to parse URI from string: "s + static_cast<std::string>(e)};
439 }
440 }
441
447 static inline result<EjfatURI> getFromFile(const std::string &fileName = "/tmp/ejfat_uri"s,
448 TokenType tt=TokenType::admin, bool preferV6=false) noexcept
449 {
450 if (!fileName.empty())
451 {
452 std::ifstream file(fileName);
453 if (file.is_open())
454 {
455 std::string uriLine;
456 if (std::getline(file, uriLine))
457 {
458 file.close();
459 try
460 {
461 return EjfatURI(uriLine, tt, preferV6);
462 }
463 catch (const E2SARException &e)
464 {
465 return E2SARErrorInfo{E2SARErrorc::CaughtException, "Unable to parse URI: "s + static_cast<std::string>(e)};
466 }
467 }
468 file.close();
469 return E2SARErrorInfo{E2SARErrorc::Undefined, "Unable to parse URI."s};
470 }
471 }
472 return E2SARErrorInfo{E2SARErrorc::NotFound, "Unable to find file "s + fileName};
473 }
474
480 result<std::vector<ip::address>> getDataplaneLocalAddresses(bool v6=false) noexcept;
481 };
482
486 static inline const result<ip::address> string_to_ip(const std::string &addr) noexcept
487 {
488 try
489 {
490 if (addr[0] == '[')
491 {
492 // strip '[]' from IPv6
493 try
494 {
495 ip::make_address(addr.substr(1, addr.length() - 2));
496 }
497 catch (...)
498 {
499 ;
500 }
501 return ip::make_address(addr.substr(1, addr.length() - 2));
502 }
503 else
504 return ip::make_address(addr);
505 }
506 catch (boost::system::system_error &e)
507 {
508 return E2SARErrorInfo{E2SARErrorc::ParameterError, "Unable to convert IP address from "s + addr};
509 }
510 }
511
515 static inline const result<u_int16_t> string_to_port(const std::string &port_string) noexcept
516 {
517 try
518 {
519 u_int16_t port = std::stoi(port_string);
520 if (port < 1024 || port > 65535)
521 {
522 // port is out of range
523 return E2SARErrorInfo{E2SARErrorc::OutOfRange, "Port value "s + port_string + " is out of range"s};
524 }
525 return port;
526 }
527 catch (const std::exception &e)
528 {
529 return E2SARErrorInfo{E2SARErrorc::ParameterError, "Unable to convert "s + port_string + " to integer"s};
530 }
531 }
532
536 static inline const result<std::pair<ip::address, u_int16_t>> string_tuple_to_ip_and_port(const std::string &t) noexcept
537 {
538 // search for last ":" (ip:port) or "]" (ipv6 by itself) whichever comes last
539 auto const pos = t.find_last_of("]:");
540
541 // IPv4 or IPv6 by itself
542 if ((pos == std::string::npos) || (t[pos] == ']'))
543 {
544 auto r1 = string_to_ip(t);
545 if (r1)
546 return std::pair<ip::address, u_int16_t>(r1.value(), 0);
547 else
548 return E2SARErrorInfo{E2SARErrorc::ParameterError, "Unable to convert "s + t + " to ip address and port"s};
549 }
550
551 // port with either IPv4 or IPv6 address x.x.x.x:num or [x:x:x:x::y]:num
552 auto r1 = string_to_ip(t.substr(0, pos));
553 auto r2 = string_to_port(t.substr(pos + 1));
554 if (r1 && r2)
555 return std::pair<ip::address, int>(r1.value(), r2.value());
556 return E2SARErrorInfo{E2SARErrorc::ParameterError, "Unable to convert "s + t + " to ip address and port"s};
557 }
558
566 static inline const result<std::tuple<ip::address, u_int16_t, u_int16_t>> string_tuple_to_ip_and_port_range(const std::string &t) noexcept
567 {
568 auto const pos = t.find_last_of("]:");
569
570 // IP by itself (no port)
571 if ((pos == std::string::npos) || (t[pos] == ']'))
572 {
573 auto r1 = string_to_ip(t);
574 if (r1)
575 return std::tuple<ip::address, u_int16_t, u_int16_t>(r1.value(), 0, 0);
576 else
577 return E2SARErrorInfo{E2SARErrorc::ParameterError, "Unable to convert "s + t + " to ip address and port range"s};
578 }
579
580 auto r1 = string_to_ip(t.substr(0, pos));
581 if (!r1)
582 return E2SARErrorInfo{E2SARErrorc::ParameterError, "Unable to convert "s + t + " to ip address and port range"s};
583
584 std::string portStr = t.substr(pos + 1);
585 auto dashPos = portStr.find('-');
586 if (dashPos != std::string::npos)
587 {
588 // port range: minPort-maxPort
589 auto r2 = string_to_port(portStr.substr(0, dashPos));
590 auto r3 = string_to_port(portStr.substr(dashPos + 1));
591 if (r2 && r3)
592 {
593 if (r2.value() > r3.value())
594 return E2SARErrorInfo{E2SARErrorc::ParameterError, "Invalid port range: min > max in "s + t};
595 return std::tuple<ip::address, u_int16_t, u_int16_t>(r1.value(), r2.value(), r3.value());
596 }
597 return E2SARErrorInfo{E2SARErrorc::ParameterError, "Unable to convert "s + t + " to ip address and port range"s};
598 }
599 else
600 {
601 // single port
602 auto r2 = string_to_port(portStr);
603 if (r2)
604 return std::tuple<ip::address, u_int16_t, u_int16_t>(r1.value(), r2.value(), r2.value());
605 return E2SARErrorInfo{E2SARErrorc::ParameterError, "Unable to convert "s + t + " to ip address and port range"s};
606 }
607 }
608
615 static inline result<std::vector<ip::address>> resolveHost(const std::string &host_name) noexcept
616 {
617
618 std::vector<ip::address> addresses;
619 boost::asio::io_context io_context;
620
621 try
622 {
623 ip::udp::resolver resolver(io_context);
624 ip::udp::resolver::results_type results = resolver.resolve(host_name, "443");
625
626 for(auto i = results.begin(); i != results.end(); ++i)
627 {
628 ip::udp::endpoint endpoint = *i;
629 addresses.push_back(endpoint.address());
630 }
631 return addresses;
632 }
633 catch (...)
634 {
635 // anything happens - we can't find the host
636 return E2SARErrorInfo{E2SARErrorc::NotFound, "Unable to convert "s + host_name + " to ip address"s};
637 }
638 }
639
640 // to support unordered maps of pairs
641 struct pair_hash {
642 std::size_t operator()(const std::pair<u_int64_t, u_int16_t>& p) const {
643 u_int64_t hash1 = p.first;
644 u_int64_t tmp = p.second;
645 u_int64_t hash2 = tmp | tmp << 16 | tmp << 32 | tmp << 48;
646 return hash1 ^ hash2; // Combine the two hashes
647 }
648 };
649
650 struct pair_equal {
651 bool operator()(const std::pair<u_int64_t, u_int16_t>& lhs, const std::pair<u_int64_t, u_int16_t>& rhs) const {
652 return lhs.first == rhs.first && lhs.second == rhs.second;
653 }
654 };
655
664 static inline float clockEntropyTest(int totalTests = 1000, int sleepMs = 1)
665 {
666 std::vector<int_least64_t> points;
667 std::vector<int> bins(256, 0);
668
669 for (int i = 0; i < totalTests; i++)
670 {
671 auto now = boost::chrono::system_clock::now();
672 auto nowUsec = boost::chrono::duration_cast<boost::chrono::microseconds>(now.time_since_epoch()).count();
673 bins[nowUsec & 0xff]++;
674 auto until = now + boost::chrono::milliseconds(sleepMs);
675 boost::this_thread::sleep_until(until);
676 }
677
678 // compute the probabilities and entropy
679 float entropy{0.0};
680 for (size_t i = 0; i < bins.size(); i++)
681 {
682 float prob = static_cast<float>(bins[i])/(totalTests*1.0);
683 entropy += prob * std::log(prob);
684 }
685
686 // normalize into bits
687 entropy *= -1.0/std::log(2);
688 return entropy;
689 }
690
691 template<typename Container>
692 std::string concatWithSeparator(const Container& c, const std::string& sep=","s)
693 {
694 typename Container::const_iterator it = c.begin();
695 std::string rets{};
696 while(it != c.end())
697 {
698 rets += *it;
699 if (++it != c.end())
700 rets += sep;
701 }
702 return rets;
703 }
704
705 // busy wait for a given number of microseconds using high_resolution_clock timepoints
706 inline void busyWaitUsecs(const boost::chrono::steady_clock::time_point &tp, int64_t usecs)
707 {
708 while(true)
709 {
710 // busy wait checking the clock
711 if (boost::chrono::duration_cast<boost::chrono::microseconds>(boost::chrono::high_resolution_clock::now()
712 - tp).count() > usecs)
713 break;
714 }
715 }
716
717 using OptimizationsWord = u_int16_t;
723 public:
724 // go as powers of 2 to make calculations easier
725 enum class Code {
726 none = 0,
727 sendmmsg = 1,
728 liburing_send = 2,
729 liburing_recv = 3,
730 recvmmsg = 4,
731 // always last
732 unknown = 15
733 };
734 public:
735 inline static OptimizationsWord toWord(Code o)
736 {
737 return 1 << static_cast<int>(o);
738 }
739 inline static std::string toString(Code o)
740 {
741 switch(o)
742 {
743 case Code::none: return "none"s;
744 case Code::sendmmsg: return "sendmmsg";
745 case Code::liburing_recv: return "liburing_recv";
746 case Code::liburing_send: return "liburing_send";
747 case Code::recvmmsg: return "recvmmsg";
748 default: "unknown"s;
749 }
750 return "unknown"s;
751 }
752 inline static Code fromString(const std::string& opt)
753 {
754 if (opt == "none"s)
755 return Code::none;
756 else if (opt == "sendmmsg"s)
757 return Code::sendmmsg;
758 else if (opt == "liburing_recv"s)
759 return Code::liburing_recv;
760 else if (opt == "liburing_send"s)
761 return Code::liburing_send;
762 else if (opt == "recvmmsg"s)
763 return Code::recvmmsg;
764 return Code::unknown;
765 }
769 const static std::vector<std::string> availableAsStrings() noexcept;
770
774 const static OptimizationsWord availableAsWord() noexcept;
775
780 static result<int> select(std::vector<std::string>& opt) noexcept;
781
786 static result <int> select(std::vector<Code> &opt) noexcept;
787
791 const static std::vector<std::string> selectedAsStrings() noexcept;
792
796 const static OptimizationsWord selectedAsWord() noexcept;
797
801 const static std::vector<Code> selectedAsList() noexcept;
802
806 const static bool isSelected(Code o) noexcept;
807 private:
808 // all available compiled in optimizations
809 static const std::vector<Optimizations::Code> available;
810
811 // this is where we store selected optimizations;
812 OptimizationsWord selected_optimizations;
813
814 // c-tor is private
815 Optimizations():selected_optimizations{toWord(Code::none)}
816 {}
817 // d-tor doesn't exist
818 ~Optimizations() = delete;
819
820 static Optimizations* instance;
821 static inline Optimizations* _get()
822 {
823 if (not instance)
824 instance = new Optimizations();
825 return instance;
826 }
827 };
828
834 std::string expandTilde(const std::string& path);
835
839 void defineClogLogger();
840};
841#endif
Definition e2sarError.hpp:62
Definition e2sarUtil.hpp:59
EjfatURI(const std::string &uri, TokenType tt=TokenType::admin, bool preferV6=false)
Definition e2sarUtil.cpp:191
const result< std::pair< ip::address, u_int16_t > > get_syncAddr() const noexcept
Definition e2sarUtil.hpp:383
const result< std::string > get_SessionToken() const
Definition e2sarUtil.hpp:193
void set_lbName(const std::string &n)
Definition e2sarUtil.hpp:213
~EjfatURI()
Definition e2sarUtil.hpp:149
bool get_useTls() const
Definition e2sarUtil.hpp:159
const bool has_syncAddrv4() const
Definition e2sarUtil.hpp:331
const bool has_dataAddrv4() const
Definition e2sarUtil.hpp:307
void set_InstanceToken(const std::string &t)
Definition e2sarUtil.hpp:171
const std::string get_lbId() const
Definition e2sarUtil.hpp:280
const result< std::pair< std::string, u_int16_t > > get_cpHost() const
Definition e2sarUtil.hpp:298
static result< EjfatURI > getFromEnv(const std::string &envVar="EJFAT_URI"s, TokenType tt=TokenType::admin, bool preferV6=false) noexcept
Definition e2sarUtil.hpp:406
const result< std::pair< ip::address, u_int16_t > > get_syncAddrv6() const noexcept
Definition e2sarUtil.hpp:375
const bool has_syncAddr() const
Definition e2sarUtil.hpp:325
const bool has_syncAddrv6() const
Definition e2sarUtil.hpp:337
void set_dataPortRange(u_int16_t minPort, u_int16_t maxPort)
Definition e2sarUtil.hpp:267
void set_sessionId(const std::string &i)
Definition e2sarUtil.hpp:225
const result< std::string > get_AdminToken() const
Definition e2sarUtil.hpp:203
void set_dataAddr(const std::pair< ip::address, std::pair< u_int16_t, u_int16_t > > &a)
Definition e2sarUtil.hpp:250
void set_Token(const std::string &t, TokenType tt)
Definition e2sarUtil.hpp:165
const result< std::pair< ip::address, u_int16_t > > get_cpAddr() const
Definition e2sarUtil.hpp:292
const std::string get_sessionId() const
Definition e2sarUtil.hpp:286
const result< std::string > get_InstanceToken() const
Definition e2sarUtil.hpp:183
static result< EjfatURI > getFromFile(const std::string &fileName="/tmp/ejfat_uri"s, TokenType tt=TokenType::admin, bool preferV6=false) noexcept
Definition e2sarUtil.hpp:447
const result< std::pair< ip::address, std::pair< u_int16_t, u_int16_t > > > get_dataAddrv4() const noexcept
Definition e2sarUtil.hpp:343
void set_SessionToken(const std::string &t)
Definition e2sarUtil.hpp:177
const bool has_dataAddrv6() const
Definition e2sarUtil.hpp:313
const result< std::pair< ip::address, std::pair< u_int16_t, u_int16_t > > > get_dataAddrv6() const noexcept
Definition e2sarUtil.hpp:351
static result< EjfatURI > getFromString(const std::string &uriStr, TokenType tt=TokenType::admin, bool preferV6=false) noexcept
Definition e2sarUtil.hpp:429
result< std::vector< ip::address > > getDataplaneLocalAddresses(bool v6=false) noexcept
Definition e2sarUtil.cpp:451
const bool has_dataAddr() const
Definition e2sarUtil.hpp:319
const result< std::pair< u_int16_t, u_int16_t > > get_dataPortRange() const noexcept
Definition e2sarUtil.hpp:359
const result< std::pair< ip::address, u_int16_t > > get_syncAddrv4() const noexcept
Definition e2sarUtil.hpp:367
void set_syncAddr(const std::pair< ip::address, u_int16_t > &a)
Definition e2sarUtil.hpp:233
const std::string get_lbName() const
Definition e2sarUtil.hpp:274
void set_lbId(const std::string &i)
Definition e2sarUtil.hpp:219
Definition e2sarUtil.hpp:722
Definition e2sar.hpp:11
std::string expandTilde(const std::string &path)
Definition e2sarUtil.cpp:493
void defineClogLogger()
Definition e2sarUtil.cpp:515
Definition e2sarError.hpp:42
Definition e2sarUtil.hpp:650
Definition e2sarUtil.hpp:641