Skip to content

Conversation

@uhm0311
Copy link
Collaborator

@uhm0311 uhm0311 commented Oct 28, 2025

๐Ÿ”— Related Issue

โŒจ๏ธ What I did

  • Binary ํ”„๋กœํ† ์ฝœ์—์„œ๋„ auth ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.
  • Binary์˜ finishedPayload() ๋ฉ”์†Œ๋“œ๋ฅผ Ascii์˜ handleLine()๊ณผ ์ตœ๋Œ€ํ•œ ๋™์ผํ•˜๊ฒŒ ๊ตฌํ˜„ํ•ฉ๋‹ˆ๋‹ค.
    • ๋‹จ, sasl mech ๋ช…๋ น์–ด์˜ handleError() ๋กœ์ง์„ finishedPayload() ๋ฉ”์†Œ๋“œ์— ํฌํ•จํ•ฉ๋‹ˆ๋‹ค.
  • ๋‹ค๋ฅธ Binary ์—ฐ์‚ฐ ํด๋ž˜์Šค์˜ ์˜ค๋ฒ„๋ผ์ด๋“œ๋œ finishedPayload() ๋ฉ”์†Œ๋“œ ๊ตฌํ˜„์„ ์ฐธ๊ณ ํ•˜์—ฌ, resetInput() ๋ฉ”์†Œ๋“œ ํ˜ธ์ถœ์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

@uhm0311 uhm0311 requested a review from jhpark816 October 28, 2025 07:33
Copy link
Collaborator

@jhpark816 jhpark816 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋ฆฌ๋ทฐ ์™„๋ฃŒ

complete(new OperationStatus(false, line, StatusCode.fromAsciiLine(line)));
throw new AuthException(line);
}
resetInput();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resetInput() ํ˜ธ์ถœ์ด ํ•„์š”ํ•œ ์ด์œ ๋ฅผ ๊ฐ„๋‹จํžˆ ์„ค๋ช…ํ•ด ์ฃผ์„ธ์š”.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resetInput()์˜ ์›๋ž˜ ์šฉ๋„๋Š” ํ•œ ๋ฒˆ์— ๋ชจ๋“  ํŒจํ‚ท์„ ์ฝ์ง€ ์•Š๋Š” ์—ฐ์‚ฐ, ์˜ˆ์‹œ๋กœ๋Š” mget ์—ฐ์‚ฐ์˜ ์‘๋‹ต์„ ์ฝ๊ธฐ ์œ„ํ•ด ํ˜ธ์ถœํ•˜๋Š” ์šฉ๋„์ž…๋‹ˆ๋‹ค.
mget๊ณผ ๊ฐ™์€ ์—ฐ์‚ฐ์˜ ์‘๋‹ต์€ <header><body> ํ˜•ํƒœ์˜ ํŒจํ‚ท์ด N๊ฐœ๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.
์ด๋Ÿฌํ•œ ์‘๋‹ต์„ ์ฝ์„ ๋•Œ์—๋Š” 24 ๋ฐ”์ดํŠธ ๊ธธ์ด์˜ header๋ฅผ ๋จผ์ € ์ฝ๊ณ , header์— ๋ช…์‹œ๋œ body ๊ธธ์ด๋งŒํผ ์ฝ์€ ํ›„์—๋Š” ๊ทธ ๋‹ค์Œ 24 ๋ฐ”์ดํŠธ ๊ธธ์ด์˜ header๋ฅผ ์ฝ๋Š” ๊ณผ์ •์œผ๋กœ ๋Œ์•„๊ฐ‘๋‹ˆ๋‹ค.
์ด ๋•Œ resetInput()์„ ํ˜ธ์ถœํ•ด์ฃผ๋ฉด ๊ธฐ์กด์— ํŒจํ‚ท์„ ์ฝ์—ˆ๋˜ ์ •๋ณด๋ฅผ ๋ฒ„๋ฆฌ๋Š” ์—ญํ• ์„ ํ•ฉ๋‹ˆ๋‹ค.
Ascii ์ปค๋งจ๋“œ๋กœ ๋น„์œ ํ•˜๋ฉด, handleLine()๊ณผ handleRead()๋ฅผ ๋ฒˆ๊ฐˆ์•„๊ฐ€๋ฉฐ ํ˜ธ์ถœํ•˜์—ฌ mget ์‘๋‹ต์„ ์ฝ๊ธฐ ์œ„ํ•ด setReadType()์„ ํ˜ธ์ถœํ•˜๋Š” ๊ฒƒ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

์œ„์™€ ๊ฐ™์€ resetInput()์˜ ๊ตฌํ˜„๊ณผ ์šฉ๋„๋ฅผ ๊ณ ๋ คํ•˜๋ฉด auth ์—ฐ์‚ฐ์—์„œ๋Š” ํ˜ธ์ถœํ•  ํ•„์š”๋Š” ์—†์ง€๋งŒ, ๋‹ค๋ฅธ ์—ฐ์‚ฐ์˜ ์˜ค๋ฒ„๋กœ๋“œ๋œ finishedPayload() ๋ฉ”์†Œ๋“œ์—์„œ ํ˜ธ์ถœ๋˜๋Š” ๊ฒƒ์„ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resetInput() ํ˜ธ์ถœ์€ ์ œ๊ฑฐํ•ฉ์‹œ๋‹ค.
์˜ค๋ฒ„๋กœ๋“œ๋œ decodePayload() ๋ฉ”์†Œ๋“œ๋ฅผ ๊ฐ€์ง„๋‹ค๊ณ  resetInput() ํ˜ธ์ถœํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

์ฐธ๊ณ ๋กœ, ๋‹ค๋ฅธ ์—ฐ์‚ฐ์—์„œ๋Š” ์•„๋ž˜ ๋ฉ”์†Œ๋“œ๋ฅผ overrideํ•˜์—ฌ ์‘๋‹ต ์ฒ˜๋ฆฌ๋ฅผ ๊ตฌํ˜„ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

  • getStatusForErrorCode()
  • decodePayload()

auth ์ฒ˜๋ฆฌ์—์„œ๋„ ๊ธฐ์กด ํ‹€์„ ๋”ฐ๋ผ ์œ„์˜ ๋ฉ”์†Œ๋“œ๋ฅผ overrideํ•˜์—ฌ ๊ตฌํ˜„ํ•˜๋ฉด ์ข‹๊ฒ ์ง€๋งŒ,
๊ทธ๊ฒŒ ์ž˜ ๋งž์ง€ ์•Š์•„์„œ, finishedPayload ๋ฉ”์†Œ๋“œ๋ฅผ overriderํ•œ ๊ฒƒ์œผ๋กœ ์ƒ๊ฐํ–ˆ์Šต๋‹ˆ๋‹ค.

if (isInternal) {
throw new AuthException(line);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ถ”๊ฐ€ ์ฝ”๋ฉ˜ํŠธ์ž…๋‹ˆ๋‹ค.
SASLBaseOperation๊ณผ ์ผ๊ด€๋˜๊ฒŒ ๊ตฌํ˜„ ํ•œ๋‹ค๋ฉด, ์•„๋ž˜์™€ ๊ฐ™์•„์•ผ ํ•˜์ง€ ์•Š๋Š” ์ง€?

    } else if (isInternal && errorCode == UNKNOWN_COMMAND) {
      complete(SASL_NOT_SUPPORTED);
    } else {
      String line = new String(pl);
      complete(new OperationStatus(false, line, StatusCode.fromAsciiLine(line)));
      throw new AuthException(line);
    }

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SASLBaseOperation์˜ ์ฒ˜๋ฆฌ๋Š” ์—„๋ฐ€ํžˆ ๋”ฐ์ง€๋ฉด Ascii ํ”„๋กœํ† ์ฝœ์˜ ๋™์ž‘์„ ๊ทธ๋Œ€๋กœ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์—†์—ˆ๋˜ ๋ถ€๋ถ„์ž…๋‹ˆ๋‹ค.

Ascii ํ”„๋กœํ† ์ฝœ์˜ ๊ฒฝ์šฐ handleLine() ํ˜ธ์ถœ๊ณผ handleError() ํ˜ธ์ถœ์€ CLIENT_ERROR | SERVER_ERROR | ERROR ์ ‘๋‘์‚ฌ๋ฅผ ๊ฐ–๊ณ  ์žˆ๋Š”์ง€ ์—ฌ๋ถ€์— ๋”ฐ๋ผ ๋ถ„๊ธฐ๊ฐ€ ๋ฉ๋‹ˆ๋‹ค.
์ฆ‰, handleLine() ๋‚ด์—์„œ๋Š” ์ ˆ๋Œ€๋กœ CLIENT_ERROR | SERVER_ERROR | ERROR ์ ‘๋‘์‚ฌ๊ฐ€ ๋ถ™์ง€ ์•Š๋Š”๋‹ค๋Š” ์ ์ด ๋ณด์žฅ๋ฉ๋‹ˆ๋‹ค.
๋ฐ˜๋Œ€๋กœ handleError() ๋‚ด์—์„œ๋Š” ํ•ญ์ƒ CLIENT_ERROR | SERVER_ERROR | ERROR ์ ‘๋‘์‚ฌ๊ฐ€ ๋ถ™๋Š”๋‹ค๋Š” ์ ์ด ๋ณด์žฅ๋ฉ๋‹ˆ๋‹ค.

Binary ํ”„๋กœํ† ์ฝœ์—์„œ๋Š” ์œ„์™€ ๊ฐ™์ด ์—๋Ÿฌ์ธ์ง€ ์•„๋‹Œ์ง€ ๊ตฌ๋ถ„์€ ์—†๊ณ , finishedPayload() ๋ฉ”์†Œ๋“œ๊ฐ€ ํ˜ธ์ถœ๋ฉ๋‹ˆ๋‹ค.
๋”ฐ๋ผ์„œ finishedPayload() ๋ฉ”์†Œ๋“œ๋ฅผ ์˜ค๋ฒ„๋ผ์ด๋“œํ•˜๊ฒŒ ๋œ๋‹ค๋ฉด, finishedPayload() ๋ฉ”์†Œ๋“œ์—์„œ Ascii์˜ handleLine()์— ํ•ด๋‹นํ•˜๋Š” ๋กœ์ง๊ณผ handleError()์— ํ•ด๋‹นํ•˜๋Š” ๋กœ์ง์„ ๋ชจ๋‘ ๋„ฃ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

SASLBaseOperation์˜ ๊ฒฝ์šฐ handleError() ์ฒ˜๋ฆฌ๋ฅผ ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” CLIENT_ERROR | SERVER_ERROR | ERROR๋กœ ๋ถ„๋ฅ˜๋˜๋Š” ๋ชจ๋“  ์—๋Ÿฌ ์ฝ”๋“œ์— ํ•ด๋‹นํ•˜๋Š” ๊ฒฝ์šฐ์— ๋Œ€ํ•œ ๋ถ„๊ธฐ ์ฒ˜๋ฆฌ๋ฅผ ์ถ”๊ฐ€ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.
SASLMechsOperation์˜ ๊ฒฝ์šฐ unknown command ์—๋Ÿฌ์— ํ•œํ•˜์—ฌ Ascii ํ”„๋กœํ† ์ฝœ๊ณผ ๋™์ผํ•œ ๋™์ž‘์„ ํ•˜๋„๋ก ํ•˜์˜€์œผ๋ฉฐ, ๊ทธ ์™ธ์— CLIENT_ERROR | SERVER_ERROR | ERROR๋กœ ๋ถ„๋ฅ˜๋˜๋Š” ๋ชจ๋“  ์—๋Ÿฌ ์ฝ”๋“œ๋Š” AuthException์„ ์ „ํŒŒ์‹œํ‚ค๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ง€๋‚œ ๋ฒˆ์— ์–˜๊ธฐํ•œ ๋Œ€๋กœ,
Ascii Protocol์—์„œ CLIENT_ERROR | SERVER_ERROR | ERROR ์˜ค๋ฅ˜์ผ ๊ฒฝ์šฐ
ํ˜„์žฌ ์—ฐ๊ฒฐ์— ๋‚จ์€ garbage data๋ฅผ ์ œ๊ฑฐํ•˜๊ธฐ ์œ„ํ•ด immediate reconnect ํ•ฉ๋‹ˆ๋‹ค.

Binary Protocol์€ ๋‹ค๋ฆ…๋‹ˆ๋‹ค.
Binary์—์„œ๋Š” ์˜ˆ์ƒํ•˜์ง€ ์•Š์€ ์‘๋‹ต์ด ์˜ฌ ๊ฒฝ์šฐ SERVER_ERROR ์˜ค๋ฅ˜๋กœ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐ์š”.
๊ทธ ์ด์œ ๋ฅผ ์ฝ”๋“œ๋ฅผ ํ†ตํ•ด ํ™•์ธํ•ด ๋ณด๋ฉด ์ข‹๊ฒ ์ง€๋งŒ,
ํ™•์ธํ•ด ๋ณด์ง€ ์•Š์€ ์ƒํƒœ๋ผ๋ฉด ๊ธฐ์กด ์ฝ”๋“œ๋ฅผ ๊ทธ๋Œ€๋กœ ์œ ์ง€ํ•˜์ž๊ณ  ํ–ˆ์Šต๋‹ˆ๋‹ค.

sasl mech ์—ฐ์‚ฐ์ด ์™ธ๋ถ€์—์„œ ์š”์ฒญ๋  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ,
internal ๊ฒฝ์šฐ๊ฐ€ ์•„๋‹ˆ๋ฉด, ์•„๋ž˜์™€ ๊ฐ™์ด ๊ธฐ์กด ์ฝ”๋“œ๋ฅผ ์œ ์ง€ํ•˜๋Š” ๊ฒƒ์ด ๋‚˜์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

    } else if (isInternal) {
      if (errorCode == UNKNOWN_COMMAND) {
        complete(SASL_NOT_SUPPORTED);
      } else {
        String line = new String(pl);
        complete(new OperationStatus(false, line, StatusCode.fromAsciiLine(line)));
        throw new AuthException(line);
      }
    } else {
      super.finishedPayload(pl);
    }

@jhpark816 jhpark816 merged commit 55e5339 into naver:develop Oct 28, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants