Skip to content

Commit b60f4e8

Browse files
committed
Added authentication functions to libhsclient to support authentication configuration in HandlerSocket for client libraries that use libhsclient
1 parent 0e63366 commit b60f4e8

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

libhsclient/hstcpcli.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct hstcpcli : public hstcpcli_i, private noncopyable {
3131
virtual bool stable_point();
3232
virtual void request_buf_open_index(size_t pst_id, const char *dbn,
3333
const char *tbl, const char *idx, const char *retflds, const char *filflds);
34+
virtual void request_buf_auth(const char *secret);
3435
#if 0
3536
virtual void request_buf_find(size_t pst_id, const string_ref& op,
3637
const string_ref *kvs, size_t kvslen, uint32_t limit, uint32_t skip);
@@ -196,6 +197,21 @@ hstcpcli::request_buf_open_index(size_t pst_id, const char *dbn,
196197
++num_req_bufd;
197198
}
198199

200+
void
201+
hstcpcli::request_buf_auth(const char *secret)
202+
{
203+
if (num_req_sent > 0 || num_req_rcvd > 0) {
204+
close();
205+
set_error(-1, "request_buf_auth: protocol out of sync");
206+
return;
207+
}
208+
const string_ref secret_ref(secret, strlen(secret));
209+
writebuf.append_literal("A\t1\t");
210+
writebuf.append(secret_ref.begin(), secret_ref.end());
211+
writebuf.append_literal("\n");
212+
++num_req_bufd;
213+
}
214+
199215
namespace {
200216

201217
void

libhsclient/hstcpcli.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ struct hstcpcli_i {
3737
virtual void close() = 0;
3838
virtual int reconnect() = 0;
3939
virtual bool stable_point() = 0;
40+
virtual void request_buf_auth(const char *secret) = 0;
4041
virtual void request_buf_open_index(size_t pst_id, const char *dbn,
4142
const char *tbl, const char *idx, const char *retflds,
4243
const char *filflds = 0) = 0;

0 commit comments

Comments
 (0)