6 #include "SockBuffer.hpp"
10 constexpr auto read_timeout_default
= std::chrono::seconds(30);
11 constexpr auto write_timeout_default
= std::chrono::seconds(30);
12 constexpr auto starttls_timeout_default
= std::chrono::seconds(30);
17 Sock(const Sock
&) = delete;
18 Sock
& operator=(const Sock
&) = delete;
22 std::function
<void(void)> read_hook
= []() {},
23 std::chrono::milliseconds read_timeout
= Config::read_timeout_default
,
24 std::chrono::milliseconds write_timeout
= Config::write_timeout_default
,
25 std::chrono::milliseconds starttls_timeout
26 = Config::starttls_timeout_default
);
28 char const* us_c_str() const { return us_addr_str_
; }
29 char const* them_c_str() const { return them_addr_str_
; }
30 std::string
const& us_address_literal() const { return us_address_literal_
; }
31 std::string
const& them_address_literal() const
33 return them_address_literal_
;
35 bool has_peername() const { return them_addr_str_
[0] != '\0'; }
36 bool input_ready(std::chrono::milliseconds wait
)
38 return iostream_
->input_ready(wait
);
40 bool maxed_out() { return iostream_
->maxed_out(); }
41 bool timed_out() { return iostream_
->timed_out(); }
43 std::istream
& in() { return iostream_
; }
44 std::ostream
& out() { return iostream_
; }
46 bool starttls_server(fs::path config_path
)
48 return iostream_
->starttls_server(config_path
);
50 bool starttls_client(fs::path config_path
,
51 char const* client_name
,
52 char const* server_name
,
53 DNS::RR_collection
const& tlsa_rrs
,
56 return iostream_
->starttls_client(config_path
, client_name
, server_name
,
57 tlsa_rrs
, enforce_dane
);
59 bool tls() { return iostream_
->tls(); }
60 std::string
tls_info() { return iostream_
->tls_info(); }
61 bool verified() { return iostream_
->verified(); };
63 void set_max_read(std::streamsize max
) { iostream_
->set_max_read(max
); }
65 void log_stats() { return iostream_
->log_stats(); }
66 void log_totals() { return iostream_
->log_totals(); }
68 void close_fds() { iostream_
->close_fds(); }
71 boost::iostreams::stream
<SockBuffer
> iostream_
;
73 socklen_t us_addr_len_
{sizeof us_addr_
};
74 socklen_t them_addr_len_
{sizeof them_addr_
};
76 sa::sockaddrs us_addr_
{};
77 sa::sockaddrs them_addr_
{};
79 char us_addr_str_
[INET6_ADDRSTRLEN
]{'\0'};
80 char them_addr_str_
[INET6_ADDRSTRLEN
]{'\0'};
82 std::string us_address_literal_
;
83 std::string them_address_literal_
;
86 #endif // SOCK_DOT_HPP