Skip to content

libreirc/protocol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

19 Commits
ย 
ย 

Repository files navigation

OpenIRC protocol v0.0.0

This document is stil work in progress

OpenIRC์—์„œ ์„œ๋ฒ„์™€ ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์–ด๋–ค ๊ฒƒ์„ ์–ผ๋งˆ๋‚˜ ์–ด๋–ป๊ฒŒ ์„œ๋กœ ์ฃผ๊ณ ๋ฐ›์„์ง€๋ฅผ ๊ธฐ์ˆ ํ•ฉ๋‹ˆ๋‹ค.

์ด ๋ฌธ์„œ์—์„œ ๋‹ค๋ค„์ง€๋Š” json ๋ฐ ๋ฉ”์„ธ์ง€ํŒฉ ๋ฐ์ดํ„ฐ์˜ ์Šคํ‚ค๋งˆ๋Š” makise ๋ฌธ๋ฒ•์„ ์‚ฌ์šฉํ•˜์—ฌ ๊ธฐ์ˆ ๋ฉ๋‹ˆ๋‹ค.

Table of contents

  1. ๋ฐฉ๋ฒ•
  2. ์ฑ„ํŒ… ๋ฉ”์„ธ์ง€ ํฌ๋งท
  3. ์š”์ฒญ/์‘๋‹ต ๋ฉ”์„ธ์ง€ ํฌ๋งท
  4. ์„œ๋ฒ„์—์„œ ํด๋ผ์ด์–ธํŠธ๋กœ ๋ณด๋‚ด๋Š” ๋ฉ”์„ธ์ง€ ํฌ๋งท

  1. ๋ฐฉ๋ฒ•

๋กœ๊ทธ์ธ

OpenIRC ์„œ๋ฒ„๋Š” OAuth๋ฅผ ์‚ฌ์šฉํ•œ ์ธ์ฆ๊ณผ ์ด๋ฉ”์ผ ์ธ์ฆ ๋ฐฉ์‹, ๊ทธ๋ฆฌ๊ณ  ๋ฐœ๊ธ‰๋ฐ›์€ ํ† ํฐ์„ ์‚ฌ์šฉํ•˜๋Š” ์ธ์ฆ๋ฐฉ์‹์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

OAuth ์ ˆ์ฐจ

TODO

์ด๋ฉ”์ผ ์ธ์ฆ ์ ˆ์ฐจ

TODO

ํ† ํฐ ์ธ์ฆ ์ ˆ์ฐจ

POST ๋ฉ”์„œ๋“œ๋กœ url์€ http://<OpenIRC ์„œ๋ฒ„ ์ฃผ์†Œ>/login/์œผ๋กœ, ์š”์ฒญ์ธ์ž๋Š” { "method": "token", "token": "<๋ฐœ๊ธ‰๋ฐ›์€ ํ† ํฐ>" }์œผ๋กœ ํ˜ธ์ถœํ•˜๋ฉด ์„œ๋ฒ„๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ํฌ๋งท์˜ json ๊ฐ์ฒด๋ฅผ ์‘๋‹ตํ•ฉ๋‹ˆ๋‹ค:

this is {
    connections: [connection],
    ws: url // ์›น์†Œ์ผ“ ์—ฐ๊ฒฐ ์ฃผ์†Œ
}

url is string

connection is {
    name: string, // ์˜ค์ง•์–ด์„œ๋ฒ„
    url: string, // ocarina.irc.ozinger.org
    port: int32, // 16667
    ssl: boolean, // true
    connid: int32, // ์ปค๋„ฅ์…˜ id
    seq: js_safe_int, // ์‹œํ€€์Šค ๋ฒˆํ˜ธ
    user: me, // ํ˜„์žฌ ์‚ฌ์šฉ์ž
    channels: [channel]
}

channel is {
    name: string, // ์ฑ„๋„ ์ด๋ฆ„
    topic: string, // ์ฑ„๋„ ํ† ํ”ฝ
    users: [user] // ์ฑ„๋„์— ์ ‘์†ํ•œ ์œ ์ € ๋ชฉ๋ก
}

user is {
    nickname: string // ์‚ฌ์šฉ์ž ๋Œ€ํ™”๋ช…
}

me is user and {
    realname: string, // ์‚ฌ์šฉ์ž๋ช…
    username: string, // ์‚ฌ์šฉ์ž ๊ณ„์ •๋ช…
    password: string // ์‚ฌ์šฉ์ž ๋น„๋ฐ€๋ฒˆํ˜ธ
}

์ปค๋„ฅ์…˜๋งˆ๋‹ค seq๋ผ๋Š” ์‹œํ€€์Šค ๋ฒˆํ˜ธ๊ฐ€ ๋“ค์–ด์žˆ๋Š”๋ฐ, ์ด ์‹œํ€€์Šค ๋ฒˆํ˜ธ๋ณด๋‹ค ์ž‘์€ ์ฑ„ํŒ… ์ด๋ฒคํŠธ ๋กœ๊ทธ๋Š” ์ปค๋„ฅ์…˜์˜ ์ƒํƒœ๋ฅผ ์กฐ์ž‘ํ•˜์ง€ ๋ง๋ผ๋Š” ์˜๋ฏธ์ž…๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ ์ปค๋„ฅ์…˜์˜ ์ƒํƒœ๋ž€ ์ฑ„๋„ ๋ชฉ๋ก๊ณผ ์ฑ„๋„๋ณ„ ํ† ํ”ฝ ๋ฐ ์œ ์ €๋ชฉ๋ก ๋“ฑ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.

์ฑ„ํŒ… ๋ฉ”์„ธ์ง€

์›น์†Œ์ผ“์„ ํ†ตํ•ด์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์ฃผ๊ณ ๋ฐ›์Šต๋‹ˆ๋‹ค.

๋กœ๊ทธ์ธ ์ ˆ์ฐจ๋ฅผ ๊ฑฐ์น˜๋ฉด ์‚ฌ์šฉ์ž ๊ธฐ๋ณธ ์ •๋ณด์™€ ์›น์†Œ์ผ“ ์—ฐ๊ฒฐ ์ฃผ์†Œ(res.ws)๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž ์ธ์ฆ๋œ ์›น์†Œ์ผ“ ์—ฐ๊ฒฐ ์ฃผ์†Œ์ด๊ธฐ ๋•Œ๋ฌธ์— ์ฑ„ํŒ… ๋ฉ”์„ธ์ง€์—๋Š” ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ๋”ฐ๋กœ ๋‹ด์„ ํ•„์š”๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.

๊ทธ ์™ธ ์‚ฌ์šฉ์ž ์ •๋ณด๋Š” RESTful api๋ฅผ ํ†ตํ•ด์„œ ์–ป์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

  1. ์ฑ„ํŒ… ๋ฉ”์„ธ์ง€ ํฌ๋งท

๋ฉ”์„ธ์ง€ํŒฉ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

์ฃผ๊ณ ๋ฐ›๋Š” ๋ฉ”์„ธ์ง€ ๋ฐ์ดํ„ฐ๋Š” ๋ฌด์กฐ๊ฑด object ํ˜•ํƒœ์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.

์„œ๋ฒ„๋Š” ํด๋ผ์ด์–ธํŠธ์˜ ๋ชจ๋“  ์š”์ฒญ์— ๋Œ€ํ•ด์„œ ์‘๋‹ต์„ ํ•ด์ค„ ์˜๋ฌด๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

ํด๋ผ์ด์–ธํŠธ์—์„œ ์„œ๋ฒ„๋กœ ๋ณด๋‚ด๋Š” ๋ชจ๋“  ์ฑ„ํŒ… ๋ฉ”์„ธ์ง€๋Š” ์š”์ฒญ id(์ดํ•˜ rid)๋ฅผ ๊ฐ–์Šต๋‹ˆ๋‹ค. ์„œ๋ฒ„์˜ ๋ชจ๋“  ์‘๋‹ต ๋ฉ”์„ธ์ง€๋„ rid๋ฅผ ๊ฐ–์Šต๋‹ˆ๋‹ค. ํด๋ผ์ด์–ธํŠธ๋Š” ์ด rid๋ฅผ ์ด์šฉํ•ด์„œ ์š”์ฒญ์— ์ƒ์‘ํ•˜๋Š” ์‘๋‹ต์„ ์•Œ์•„๋‚ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

rid๋Š” int32 ํƒ€์ž…์„ ๊ฐ€์ง€๋ฉฐ, ํด๋ผ์ด์–ธํŠธ์—์„œ ์ง์ ‘ ๊ด€๋ฆฌ(2147483647์„ ๋„˜์–ด๊ฐ€๋ฉด 0๋ถ€ํ„ฐ ๋‹ค์‹œ ์‹œ์ž‘ํ•˜๋Š” ๋“ฑ์˜ ์ฒ˜๋ฆฌ)ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

rid๊ฐ€ int32 ํƒ€์ž…์ด ์•„๋‹ˆ๊ฑฐ๋‚˜(์˜ˆ: 12.34) ์Œ์ˆ˜๊ฐ’์„ ๊ฐ€์งˆ ๊ฒฝ์šฐ, ์„œ๋ฒ„๋Š” rid๊ฐ€ -1์ธ ์‘๋‹ต์„ ๋Œ๋ ค์ฃผ์–ด์•ผํ•ฉ๋‹ˆ๋‹ค:

{
    "rid": -1,
    "given_rid": 12.34,
    "kind": "error",
    "list": [
        {
            "kind": "invalid_type",
            "context": "rid",
            "given_type": "number",
            "required_type": "int32"
        }
    ]
}

(ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์„œ๋ฒ„๋กœ ๋ณด๋‚ด๋Š”) ์š”์ฒญ ๋ฉ”์„ธ์ง€์˜ ๊ธฐ๋ณธ ํฌ๋งท์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค:

request is {
    rid: int32,
    kind: request_kind
}

request_kind is (
    'join', 'leave', 'message'
)

(์„œ๋ฒ„๊ฐ€ ํด๋ผ์ด์–ธํŠธ๋กœ ๋ณด๋‚ด๋Š”) ์‘๋‹ต ๋ฉ”์„ธ์ง€์˜ ๊ธฐ๋ณธ ํฌ๋งท์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค:

response is {
    rid: int32,
    kind: response_kind
}

response_kind is (
    'ok',
    'error'
)

response[rid = -1] is {
    given_rid: *
}

response[kind = 'error'] is {
    list: [error]
}

error is {
    kind: ('invalid_type')
}

error[kind = 'invalid_type'] is {
    context: string, // 'key.array["0"].key2'...
    given_type: string,
    required_type: string
}

์‘๋‹ต์ด ์•„๋‹Œ ๊ฒฝ์šฐ์—, ์„œ๋ฒ„๊ฐ€ ํด๋ผ์ด์–ธํŠธ๋กœ ๋ณด๋‚ด๋Š” ๋ฉ”์„ธ์ง€๋Š” ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์‘๋‹ตํ•  ์˜๋ฌด๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.

์„œ๋ฒ„๊ฐ€ ํด๋ผ์ด์–ธํŠธ๋กœ ๋ณด๋‚ด๋Š” ๋ฉ”์„ธ์ง€์˜ ๊ธฐ๋ณธ ํฌ๋งท์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค:

message is {
    kind: message_kind
}

message_kind is () // TODO
  1. ์š”์ฒญ/์‘๋‹ต ๋ฉ”์„ธ์ง€ ํฌ๋งท

target is {
    connid: int32,
    kind: ('channel', 'user'),
    name: string
}

// ์ฑ„๋„ ์ ‘์†
request[kind = 'join'] is {
    target: target
}

// ์ฑ„๋„ ํ‡ด์žฅ
request[kind = 'leave'] is {
    target: target
}

// ๋Œ€ํ™”
request[kind = 'message'] is {
    target: target,
    content: string
}
  1. ์„œ๋ฒ„์—์„œ ํด๋ผ์ด์–ธํŠธ๋กœ ๋ณด๋‚ด๋Š” ๋ฉ”์„ธ์ง€ ํฌ๋งท

TODO

About

[OBSOLETED] We're using GraphQL instead

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published