Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Added authentication functions to libhsclient to support authenticati…
…on configuration in HandlerSocket for client libraries that use libhsclient
  • Loading branch information
WheresWardy committed Mar 31, 2011
commit b60f4e877d9046c4e2611b3a9e4f6c136042e1bf
16 changes: 16 additions & 0 deletions libhsclient/hstcpcli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct hstcpcli : public hstcpcli_i, private noncopyable {
virtual bool stable_point();
virtual void request_buf_open_index(size_t pst_id, const char *dbn,
const char *tbl, const char *idx, const char *retflds, const char *filflds);
virtual void request_buf_auth(const char *secret);
#if 0
virtual void request_buf_find(size_t pst_id, const string_ref& op,
const string_ref *kvs, size_t kvslen, uint32_t limit, uint32_t skip);
Expand Down Expand Up @@ -196,6 +197,21 @@ hstcpcli::request_buf_open_index(size_t pst_id, const char *dbn,
++num_req_bufd;
}

void
hstcpcli::request_buf_auth(const char *secret)
{
if (num_req_sent > 0 || num_req_rcvd > 0) {
close();
set_error(-1, "request_buf_auth: protocol out of sync");
return;
}
const string_ref secret_ref(secret, strlen(secret));
writebuf.append_literal("A\t1\t");
writebuf.append(secret_ref.begin(), secret_ref.end());
writebuf.append_literal("\n");
++num_req_bufd;
}

namespace {

void
Expand Down
1 change: 1 addition & 0 deletions libhsclient/hstcpcli.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ struct hstcpcli_i {
virtual void close() = 0;
virtual int reconnect() = 0;
virtual bool stable_point() = 0;
virtual void request_buf_auth(const char *secret) = 0;
virtual void request_buf_open_index(size_t pst_id, const char *dbn,
const char *tbl, const char *idx, const char *retflds,
const char *filflds = 0) = 0;
Expand Down