Skip to content
API Documentation
BastionGuard™
TunnelSession Struct Reference
Inheritance diagram for TunnelSession:

Public Member Functions

 TunnelSession (tcp::socket c, tcp::socket r)
void start ()

Public Attributes

tcp::socket client_
tcp::socket remote_
std::array< char, 64 *1024 > cbuf_ {}
std::array< char, 64 *1024 > rbuf_ {}

Private Member Functions

void pump_c2r ()
void pump_r2c ()
void shutdown ()

Private Attributes

std::atomic< bool > closed_ {false}

Detailed Description

Definition at line 185 of file bastionguard_cef.cpp.

Constructor & Destructor Documentation

◆ TunnelSession()

TunnelSession::TunnelSession ( tcp::socket c,
tcp::socket r )
inline

Definition at line 191 of file bastionguard_cef.cpp.

192 : client_(std::move(c)), remote_(std::move(r)) {}

References client_, and remote_.

Member Function Documentation

◆ pump_c2r()

void TunnelSession::pump_c2r ( )
inlineprivate

Definition at line 197 of file bastionguard_cef.cpp.

197 {
198 auto self = shared_from_this();
199 client_.async_read_some(asio::buffer(cbuf_),
200 [this, self](boost::system::error_code ec, std::size_t n) {
201 if (ec || n == 0) { shutdown(); return; }
202 asio::async_write(remote_, asio::buffer(cbuf_.data(), n),
203 [this, self](boost::system::error_code wec, std::size_t) {
204 if (wec) { shutdown(); return; }
205 pump_c2r();
206 });
207 });
208 }
std::array< char, 64 *1024 > cbuf_

References cbuf_, client_, pump_c2r(), remote_, and shutdown().

Referenced by pump_c2r(), and start().

◆ pump_r2c()

void TunnelSession::pump_r2c ( )
inlineprivate

Definition at line 210 of file bastionguard_cef.cpp.

210 {
211 auto self = shared_from_this();
212 remote_.async_read_some(asio::buffer(rbuf_),
213 [this, self](boost::system::error_code ec, std::size_t n) {
214 if (ec || n == 0) { shutdown(); return; }
215 asio::async_write(client_, asio::buffer(rbuf_.data(), n),
216 [this, self](boost::system::error_code wec, std::size_t) {
217 if (wec) { shutdown(); return; }
218 pump_r2c();
219 });
220 });
221 }
std::array< char, 64 *1024 > rbuf_

References client_, pump_r2c(), rbuf_, remote_, and shutdown().

Referenced by pump_r2c(), and start().

◆ shutdown()

void TunnelSession::shutdown ( )
inlineprivate

Definition at line 223 of file bastionguard_cef.cpp.

223 {
224 if (closed_.exchange(true)) return;
225 boost::system::error_code ignore;
226 client_.close(ignore);
227 remote_.close(ignore);
228 }
std::atomic< bool > closed_

References client_, closed_, and remote_.

Referenced by pump_c2r(), and pump_r2c().

◆ start()

void TunnelSession::start ( )
inline

Definition at line 194 of file bastionguard_cef.cpp.

194{ pump_c2r(); pump_r2c(); }

References pump_c2r(), and pump_r2c().

Member Data Documentation

◆ cbuf_

std::array<char, 64 * 1024> TunnelSession::cbuf_ {}

Definition at line 188 of file bastionguard_cef.cpp.

Referenced by pump_c2r().

◆ client_

tcp::socket TunnelSession::client_

Definition at line 186 of file bastionguard_cef.cpp.

Referenced by pump_c2r(), pump_r2c(), shutdown(), and TunnelSession().

◆ closed_

std::atomic<bool> TunnelSession::closed_ {false}
private

Definition at line 230 of file bastionguard_cef.cpp.

Referenced by shutdown().

◆ rbuf_

std::array<char, 64 * 1024> TunnelSession::rbuf_ {}

Definition at line 189 of file bastionguard_cef.cpp.

Referenced by pump_r2c().

◆ remote_

tcp::socket TunnelSession::remote_

Definition at line 187 of file bastionguard_cef.cpp.

Referenced by pump_c2r(), pump_r2c(), shutdown(), and TunnelSession().


The documentation for this struct was generated from the following file: