Joedb 9.5.0
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Forward_Channel.cpp
Go to the documentation of this file.
2
3namespace joedb::ssh
4{
5 ///////////////////////////////////////////////////////////////////////////
7 ///////////////////////////////////////////////////////////////////////////
8 channel(ssh_channel_new(session.get()))
9 {
11 }
12
13 ///////////////////////////////////////////////////////////////////////////
15 ///////////////////////////////////////////////////////////////////////////
16 {
17 ssh_channel_free(channel);
18 }
19
20 ///////////////////////////////////////////////////////////////////////////
21 size_t Forward_Channel::write_some(const char *data, size_t size)
22 ///////////////////////////////////////////////////////////////////////////
23 {
24 const int result = ssh_channel_write(channel, data, uint32_t(size));
25
26 if (result == SSH_ERROR)
27 throw Exception("Error writing to channel");
28
29 return size_t(result);
30 }
31
32 ///////////////////////////////////////////////////////////////////////////
33 size_t Forward_Channel::read_some(char *data, size_t size)
34 ///////////////////////////////////////////////////////////////////////////
35 {
36 const int result = ssh_channel_read_timeout
37 (
38 channel,
39 data,
40 uint32_t(size),
41 0,
42 int(timeout.count())
43 );
44
45 if (result == SSH_ERROR)
46 throw Exception("Error reading from channel");
47
48 if (result == 0)
49 throw Exception("End of file when reading from channel");
50
51 return size_t(result);
52 }
53
54 ///////////////////////////////////////////////////////////////////////////
56 ///////////////////////////////////////////////////////////////////////////
57 (
58 Session &session,
59 const char *remote_host,
60 uint16_t remote_port
61 ):
63 {
64 session.check_result
65 (
66 ssh_channel_open_forward
67 (
68 channel,
69 remote_host,
70 remote_port,
71 "", // unused parameter
72 0 // unused parameter
73 )
74 );
75 }
76
77 ///////////////////////////////////////////////////////////////////////////
79 ///////////////////////////////////////////////////////////////////////////
80 (
81 Session &session,
82 const char *remote_path
83 ):
85 {
86 session.check_result
87 (
88 ssh_channel_open_forward_unix
89 (
90 channel,
91 remote_path,
92 "", // unused parameter
93 0 // unused parameter
94 )
95 );
96 }
97}
98
Forward_Channel(Session &session, const char *remote_host, uint16_t remote_port)
#define JOEDB_RELEASE_ASSERT(x)
Definition assert.h:24
C++ wrappers for libssh.
Definition Connector.h:8