diff --git a/README.markdown b/README.markdown index 1c14b04..35fb346 100644 --- a/README.markdown +++ b/README.markdown @@ -25,9 +25,9 @@ curl -d "GET/hello" http://127.0.0.1:7379/ # Ideas, TODO... * Add meta-data info per key (MIME type in a second key, for instance). -* Support PUT, DELETE, HEAD? -* Support pub/sub. -* Disable MULTI/EXEC/DISCARD/WATCH. +* Support PUT, DELETE, HEAD? How? For which commands? +* Support pub/sub (waiting for HiRedis ticket \#17 in order to add this.) +* MULTI/EXEC/DISCARD/WATCH are disabled at the moment; find a way to use them. * Add logging. * Enrich config file: * Provide timeout (this needs to be added to hiredis first.) diff --git a/cmd.c b/cmd.c index b9e09b0..a32944a 100644 --- a/cmd.c +++ b/cmd.c @@ -38,6 +38,8 @@ cmd_free(struct cmd *c) { int cmd_authorized(struct conf *cfg, struct evhttp_request *rq, const char *verb, size_t verb_len) { + char *always_off[] = {"MULTI", "EXEC", "WATCH", "DISCARD", "SUBSCRIBE", "PSUBSCRIBE"}; + struct disabled_command *dc; unsigned int i; @@ -45,6 +47,14 @@ cmd_authorized(struct conf *cfg, struct evhttp_request *rq, const char *verb, si u_short client_port; in_addr_t client_addr; + /* some commands are always disabled, regardless of the config file. */ + for(i = 0; i < sizeof(always_off) / sizeof(always_off[0]); ++i) { + if(strncasecmp(always_off[i], verb, verb_len) == 0) { + return 0; + } + } + + /* find client's address */ evhttp_connection_get_peer(rq->evcon, &client_ip, &client_port); client_addr = ntohl(inet_addr(client_ip));