-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
INTERNAL: Make the -S option available with ascii protocol #819
base: develop
Are you sure you want to change the base?
Conversation
memcached.c
Outdated
(strcmp(tokens[COMMAND_TOKEN].value, "shutdown") == 0) || | ||
(strcmp(tokens[COMMAND_TOKEN].value, "stats") == 0) || | ||
(strcmp(tokens[COMMAND_TOKEN].value, "version") == 0) || | ||
(strcmp(tokens[COMMAND_TOKEN].value, "zkensemble") == 0)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flush ๋ช ๋ น์ ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ผ๋ฐ์ ์ผ๋ก ์ ๊ทผ ์ ํ์ด๋ผ๋ ํํ์ read/write๋ฅผ ์์ฐ๋ฅด๋ ์๋ฏธ๋ก ์ฌ์ฉํ๋ ๊ฒฝ์ฐ๊ฐ ๋ง๊ณ
flush๋ ์บ์ ์์ดํ
์ ๋ํ write ์ฑ๊ฒฉ์ ๋ช
๋ น์ด๋ผ๊ณ ์๊ฐํด์ ํ์ฉ ๋ช
๋ น์์ ์ ์ธํ์ต๋๋ค.
๊ทธ๋ฐ๋ฐ ์๊ฐํด ๋ณด๋ ์์ฉ์์ ํน์ key๋ prefix๋ฅผ ์ ๊ฑฐํด ๋ฌ๋ผ๋ ์์ฒญ์ด ์์ ์ ์๊ณ
flush
, delete
๋ช
๋ น์ ํ์ฉํ๋ค๊ณ ํด์ ์ ์ฅ๋ ์ ๋ณด๋ฅผ ์ ์ ์๊ฒ ๋๋ ๊ฒ์ด ์๋๋ฏ๋ก
์ด๋ฌํ ๋ช
๋ น์ ํ์ฉํ๋ ๊ฒ์ด ์ ์ฉํ๊ฐ ํ๋ ์๊ฐ๋ ๋ค๊ธฐ๋ ํฉ๋๋ค.
์ ์๊ฐ์ flush๋ฅผ ์ด์ ๊ณ์ด์ ๋ช
๋ น์ผ๋ก ๋ถ๋ฅํ์ ๋ ๋ฌธ์ ๊ฐ ๋๋ ๋ถ๋ถ์,
์ธ์ฆํ์ง ์์ ์ฌ์ฉ์ or ๋ชจ๋ํฐ๋ง ํ๋ก์ธ์ค๊ฐ ์บ์ ๋ฐ์ดํฐ๋ฅผ ์ ๋ถ ์ ๊ฑฐํ ์ ์๋ค๊ณ ํด์ํ ์ฌ์ง๊ฐ ์๋ค๋ ์ ์
๋๋ค.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๋ฆฌ๋ทฐ ์๋ฃ
} | ||
|
||
return rv; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์๋ ํํ๋ก ๋ณ๊ฒฝํ์์ฃ . ์๋ ์ฝ๋๊ฐ ์ง๊ด์ ์ผ๋ก ์ฝ๊ธฐ๊ฐ ์ฝ์ต๋๋ค.
static bool authenticated_ascii(conn *c, token_t *tokens, const size_t ntokens)
{
if (c->authenticated) {
return true;
}
if ((ntokens >= 2) &&
(strcmp(tokens[COMMAND_TOKEN].value, "dump") == 0 ||
strcmp(tokens[COMMAND_TOKEN].value, "cmdlog") == 0 ||
. . .
strcmp(tokens[COMMAND_TOKEN].value, "version") == 0 ||
strcmp(tokens[COMMAND_TOKEN].value, "zkensemble") == 0)) {
return true;
}
if ((ntokens >= 3) &&
(strcmp(tokens[COMMAND_TOKEN].value, "set") == 0 ||
strcmp(tokens[COMMAND_TOKEN].value, "get") == 0)) {
return (strncmp(tokens[KEY_TOKEN].value, "arcus:", 6) == 0);
}
if ((ntokens >= 5) &&
(strcmp(tokens[COMMAND_TOKEN].value, "lop") == 0 ||
...
strcmp(tokens[COMMAND_TOKEN].value, "bop") == 0)) {
return (strncmp(tokens[COMMAND_TOKEN+2].value, "arcus:", 6) == 0);
}
return false;
}
adf98c2
to
d2f6f61
Compare
|
d2f6f61
to
bb9358e
Compare
strcmp(tokens[COMMAND_TOKEN].value, "bop") == 0)) { | ||
return (strncmp(tokens[COMMAND_TOKEN+2].value, "arcus:", 6) == 0); | ||
} | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@namsic
์๋์ ๊ฐ์ด ์กฐ๊ธ์ด๋ผ๋ ์ต์ ํํ๋ ๋ฐฉ์์ ๊ฒํ ํด ์ฃผ์ธ์.
if ((ntokens >= 5) &&
(strcmp(tokens[COMMAND_TOKEN].value+1, "op ") == 0)) { // lop, sop, mop, bop
return (strncmp(tokens[COMMAND_TOKEN+2].value, "arcus:", 6) == 0);
}
if ((ntokens >= 3) &&
(strcmp(tokens[COMMAND_TOKEN].value+1, "et ") == 0)) { // get, set
return (strncmp(tokens[KEY_TOKEN].value, "arcus:", 6) == 0);
}
if ((ntokens >= 2) &&
(strcmp(tokens[COMMAND_TOKEN].value, "dump") == 0 ||
strcmp(tokens[COMMAND_TOKEN].value, "cmdlog") == 0 ||
strcmp(tokens[COMMAND_TOKEN].value, "config") == 0 ||
strcmp(tokens[COMMAND_TOKEN].value, "flush_all") == 0 ||
strcmp(tokens[COMMAND_TOKEN].value, "flush_prefix") == 0 ||
strcmp(tokens[COMMAND_TOKEN].value, "getattr") == 0 ||
strcmp(tokens[COMMAND_TOKEN].value, "help") == 0 ||
strcmp(tokens[COMMAND_TOKEN].value, "lqdetect") == 0 ||
strcmp(tokens[COMMAND_TOKEN].value, "scan") == 0 ||
strcmp(tokens[COMMAND_TOKEN].value, "setattr") == 0 ||
strcmp(tokens[COMMAND_TOKEN].value, "stats") == 0 ||
strcmp(tokens[COMMAND_TOKEN].value, "zkensemble") == 0)) {
return true;
}
if ((ntokens == 2) &&
(strcmp(tokens[COMMAND_TOKEN].value, "quit") == 0 ||
strcmp(tokens[COMMAND_TOKEN].value, "ready") == 0 ||
strcmp(tokens[COMMAND_TOKEN].value, "version") == 0 ||
strcmp(tokens[COMMAND_TOKEN].value, "shutdown") == 0)) {
return true;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ฒซ ๊ธ์ ํ์ธํ์ฌ switchํ ๋ค ๋ฌธ์์ด ๋น๊ตํ๋ ๊ตฌํ๋ ๊ฒํ ํ ๋งํ ๊ฒ ๊ฐ์ต๋๋ค.
switch(buffer[0])
{
case 'V':
if (memcmp(buffer, "VALUE", 5) == 0)
{
/* We add back in one because we will need to search for END */
memcached_server_response_increment(ptr);
return textual_value_fetch(ptr, buffer, buffer_length, result);
}
else if (memcmp(buffer, "VERSION", 7) == 0)
{
/* Find the space, and then move one past it to copy version */
char *version_ptr= index(buffer, ' ');
version_ptr++;
return textual_version_fetch(ptr, version_ptr);
}
break;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@namsic
c client ๋ฐฉ์์ผ๋ก ๊ตฌํํฉ์๋ค.
๐ Related Issue
โจ๏ธ What I did
-S
option์ ascii protocol๊ณผ ํจ๊ป ์ฌ์ฉํ ์ ์๋๋ก ํ์ฅํฉ๋๋ค.ascii protocol์์ SASL ์ธ์ฆ ์ํํ ๋ฐฉ๋ฒ์ด ์๋ ์ํ์ด๋ฏ๋ก,
-S
์ต์ ์ฌ์ฉ ์ ascii conn์์๋ ํ์ฉ๋ ๋ช ๋ น๋ง ์ฌ์ฉํ ์ ์์ต๋๋ค.๊ธฐ์กด์๋
-S
option์ ์ค์ ํ๋ฉด binary protocol์ผ๋ก ๊ณ ์ ๋๊ณ ,-B
option์์auto
๋ascii
๋ฅผ ๋ช ์ํ ์ํ์์-S
ํจ๊ป ์ง์ ํ๋ฉด ๊ตฌ๋ ์คํจํฉ๋๋ค.๋ณ๊ฒฝ ํ์๋
-S
option์ ์ค์ ํ๋๋ผ๋ ascii protocol์ ์ฌ์ฉํ ์ ์์ต๋๋ค.-S
option์ ์ค์ ํ์ฌ ๊ตฌ๋ํ ๊ฒฝ์ฐ์ ascii protocol ์ฌ์ฉํ๋ ์ฐ๊ฒฐ์ํ์ฉ๋์ง ์์ ๋ช ๋ น์ ๋ํด
CLIENT_ERROR unauthenticated
์๋ตํฉ๋๋ค.