Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 7
- Log:
Initial import of RForum 0.2 sources from a downloaded Tarball.
RForum is a Ruby On Rails based forum and mail gateway service.
- Author:
- adh
- Date:
- Sat Jul 22 18:43:13 +0100 2006
- Size:
- 2530 Bytes
1 | class NNTPError < Exception |
2 | attr :message |
3 | |
4 | def initialize(message) |
5 | @message = message |
6 | end |
7 | end |
8 | |
9 | class NNTPSession |
10 | attr_reader :group, :article, :user, :auth_user_name |
11 | |
12 | def initialize(socket, logger) |
13 | @socket = socket |
14 | @logger = logger |
15 | end |
16 | |
17 | def write(s) |
18 | @socket.write s |
19 | end |
20 | |
21 | def putline(line) |
22 | @socket.write(line.chomp + "\r\n") |
23 | @logger.debug { "Thread #{Thread.current.id}: > #{line.chomp}" } |
24 | end |
25 | |
26 | # Read a single line from the client and return it. |
27 | def getline |
28 | line = @socket.gets("\n").chomp |
29 | @logger.debug { "Thread #{Thread.current.id}: < #{line}" } |
30 | return line |
31 | end |
32 | |
33 | # Read a multi-line message from a client. |
34 | def getarticle |
35 | # TODO |
36 | end |
37 | |
38 | def close |
39 | @socket.close |
40 | end |
41 | |
42 | def serve |
43 | putline "200 server ready" |
44 | while request = getline.strip |
45 | cmd, *args = request.split(/\s+/) |
46 | |
47 | begin |
48 | case request |
49 | |
50 | when /^LIST$/i |
51 | write Forum.nntp_grouplist.join("\r\n") + "\r\n" |
52 | putline '.' |
53 | |
54 | when /^LIST OVERVIEW\.FMT$/i |
55 | write "Subject:\r\nFrom:\r\nDate:\r\nMessage-Id:\r\nReferences:\r\nBytes:\r\nLines:\r\n" |
56 | putline '.' |
57 | |
58 | when /^GROUP (.+)$/i |
59 | putline select_group($1) |
60 | |
61 | when /^AUTHINFO USER (.+)$/i |
62 | @auth_user_name = $1 |
63 | @user = nil |
64 | putline '381 More authentication information required' |
65 | |
66 | when /^AUTHINFO PASS (.+)$/i |
67 | if @auth_user_name |
68 | # try login |
69 | @user = User.find_by_login(@auth_user_name, $1) |
70 | if @user |
71 | putline '281 Authentication accepted' |
72 | else |
73 | putline '502 No permission' |
74 | end |
75 | else |
76 | # password without username |
77 | putline '482 Authentication rejected' |
78 | end |
79 | |
80 | when /^NEWNEWS/i |
81 | putline '502 permission denied (command disabled)' |
82 | |
83 | when /^SLAVE$/i |
84 | putline '202 ignored' |
85 | |
86 | when /^MODE READER$/i |
87 | putline '200 ignored' |
88 | |
89 | when /^IHAVE/i |
90 | putline '435 article not wanted - do not send it' |
91 | |
92 | when /^QUIT$/i |
93 | putline '205 closing connection' |
94 | close |
95 | return |
96 | |
97 | else |
98 | raise NNTPError, '500 unknown command' |
99 | end |
100 | rescue NNTPError => err |
101 | putline err.message |
102 | end |
103 | |
104 | end |
105 | end |
106 | |
107 | def select_group(name) |
108 | @group = Forum.find_by_groupname(name) |
109 | '211 foo' |
110 | rescue |
111 | '411 group not found' |
112 | end |
113 | |
114 | end |
115 |