public
Description: IRC "bouncer" proxy in Ruby
Clone URL: git://github.com/myelin/irc-proxy.git
simple buffering is working
myelin (author)
Sun Jul 13 15:38:47 -0700 2008
commit  9b97efed5f51432536b038a40e2f8dbe2d435bb5
tree    f83725e1442dd78cb165138349da6995a9e0486c
parent  7bdd6ddd02961a78400a208bc042fddad0a50130
...
1
 
 
2
3
4
...
7
8
9
 
10
11
12
...
1
2
3
4
5
6
...
9
10
11
12
13
14
15
0
@@ -1,4 +1,6 @@
0
 # copy this to config.yml and customize to fit your needs
0
+global:
0
+ buffers: ./buffers
0
 users:
0
  yourlogin:
0
   passwd: insert password here
0
@@ -7,6 +9,7 @@ servers:
0
   port: 6667
0
   ssl: false
0
   nick: yournick
0
+ awaynick: yournick_away
0
   user: me
0
   name: Your Name Here
0
   channels:
...
34
35
36
 
 
37
38
39
...
58
59
60
61
 
 
 
 
62
63
64
...
34
35
36
37
38
39
40
41
...
60
61
62
 
63
64
65
66
67
68
69
0
@@ -34,6 +34,8 @@ class App
0
 
0
   def read_config
0
     @conf = YAML.load(IO.read("config.yml"))
0
+ @buffer_path = @conf['global']['buffers']
0
+ Dir.mkdir(@buffer_path) unless File.exist?(@buffer_path)
0
   end
0
 
0
   def start_server_connections
0
@@ -58,7 +60,10 @@ class App
0
     if c
0
       c.handle_chanmsg(server, chan, from, msg)
0
     else
0
- puts "TODO: buffer message on channel #{chan}"
0
+ puts "buffering message on server #{server.host} channel #{chan}"
0
+ File.open("#{@buffer_path}/#{server.host}.buffer", "a") do |f|
0
+ f.write "SERVER #{server.host} CHANNEL #{chan} MSG #{msg}\n"
0
+ end
0
     end
0
   end
0
 
...
8
9
10
11
 
 
12
13
14
...
23
24
25
 
 
 
 
26
27
 
28
29
30
...
35
36
37
38
 
39
40
 
41
42
43
...
58
59
60
61
 
62
63
64
...
83
84
85
86
 
87
88
89
...
8
9
10
 
11
12
13
14
15
...
24
25
26
27
28
29
30
31
 
32
33
34
35
...
40
41
42
 
43
44
 
45
46
47
48
...
63
64
65
 
66
67
68
69
...
88
89
90
 
91
92
93
94
0
@@ -8,7 +8,8 @@ class ServerConnection < AsyncSocket
0
     @host = host
0
     @port = conf['port']
0
     @ssl = conf['ssl']
0
- @desired_nick = conf['nick']
0
+ @online_nick = conf['nick']
0
+ @away_nick = conf['awaynick'] || @online_nick
0
     @user = conf['user']
0
     @name = conf['name']
0
     @channels_to_join = conf['channels']
0
@@ -23,8 +24,12 @@ class ServerConnection < AsyncSocket
0
     end
0
   end
0
 
0
+ def desired_nick
0
+ @online_nick
0
+ end
0
+
0
   def run
0
- puts "Server thread for #{@desired_nick}@#{@host}:#{@port} starting"
0
+ puts "Server thread for #{desired_nick}@#{@host}:#{@port} starting"
0
 
0
     while true
0
       if @state == :offline
0
@@ -35,9 +40,9 @@ class ServerConnection < AsyncSocket
0
       poll_socket
0
     end
0
 
0
- puts "Server thread for #{@desired_nick}@#{@host}:#{@port} shut down"
0
+ puts "Server thread for #{desired_nick}@#{@host}:#{@port} shut down"
0
   rescue Exception => e
0
- puts "Exception killed server thread for #{@desired_nick}@#{@host}:#{@port}: #{e}"
0
+ puts "Exception killed server thread for #{desired_nick}@#{@host}:#{@port}: #{e}"
0
     puts e.backtrace.join("\n")
0
   end
0
 
0
@@ -58,7 +63,7 @@ class ServerConnection < AsyncSocket
0
   def handle_connect
0
     puts "connected to server #{@host}!"
0
     @state = :logging_in
0
- write "NICK #{@desired_nick}"
0
+ write "NICK #{desired_nick}"
0
     write "USER #{@user} #{@hostname} #{@host} :#{@name}"
0
   end
0
 
0
@@ -83,7 +88,7 @@ class ServerConnection < AsyncSocket
0
       when "433"
0
         #[":servername", "433", "*", "myelin", "Nickname is already in use."]
0
         @nick_serial += 1
0
- write "NICK #{@desired_nick}#{@nick_serial}"
0
+ write "NICK #{desired_nick}#{@nick_serial}"
0
       when "MODE"
0
         if args[0] == ":#{@nick}"
0
           puts "mode message; i'm connected!"

Comments

    No one has commented yet.