Skip to content

Commit 88bf1e0

Browse files
committed
Merged pull request DeNA#44 from WheresWardy/master.
Authentication support for libhsclient
2 parents 7828d17 + b60f4e8 commit 88bf1e0

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);
@@ -197,6 +198,21 @@ hstcpcli::request_buf_open_index(size_t pst_id, const char *dbn,
197198
++num_req_bufd;
198199
}
199200

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

202218
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)