public
Fork of pjhyett/github-services
Description: Official GitHub Services Integration
Homepage: http://github.com/blog/53-github-services-ipo
Clone URL: git://github.com/github/github-services.git
added ssl support to irc
Sean O'Brien (author)
Tue May 06 15:00:41 -0700 2008
commit  9c910274d07f2812b74214e6be713765f9b94d3d
tree    0df38a55c6806d641461110e3d9c7bf39379ae4a
parent  3d85dfd2c40eb369700e9ac4b7bedfc22259dfe8
...
5
6
7
8
 
9
10
11
...
17
18
19
 
20
21
22
...
5
6
7
 
8
9
10
11
...
17
18
19
20
21
22
23
0
@@ -5,7 +5,7 @@ Install Notes
0
 -------------
0
 
0
   1. server (ie. irc.freenode.net)
0
- 2. port is normally 6667
0
+ 2. port is normally 6667 / 9999 for ssl
0
   3. the room field can support multiple rooms (comma separated)
0
 
0
 
0
@@ -17,6 +17,7 @@ data
0
   - port
0
   - room
0
   - password
0
+ - ssl
0
 
0
 payload
0
   - refer to docs/github_payload
...
1
2
 
3
4
5
...
1
 
2
3
4
5
0
@@ -1,5 +1,5 @@
0
 $:.unshift *Dir["#{File.dirname(__FILE__)}/vendor/**/lib"]
0
-%w( rack sinatra tinder twitter json net/http net/https socket timeout xmlrpc/client ).each { |f| require f }
0
+%w( rack sinatra tinder twitter json net/http net/https socket timeout xmlrpc/client openssl ).each { |f| require f }
0
 
0
 module GitHub
0
   def service(name, &block)
...
3
4
5
6
 
 
 
 
 
 
 
 
 
 
 
7
8
9
...
3
4
5
 
6
7
8
9
10
11
12
13
14
15
16
17
18
19
0
@@ -3,7 +3,17 @@ service :irc do |data, payload|
0
   branch = payload['ref'].split('/').last
0
   rooms = data['room'].gsub(",", " ").split(" ").map{|room| room[0].chr == '#' ? room : "##{room}"}
0
   botname = "GitHub#{rand(200)}"
0
- irc = TCPSocket.open(data['server'], data['port'])
0
+ socket = TCPSocket.open(data['server'], data['port'])
0
+ if data['ssl'].to_i == 1
0
+ ssl_context = OpenSSL::SSL::SSLContext.new()
0
+ ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE # do not verify client certificates
0
+ ssl_socket = OpenSSL::SSL::SSLSocket.new(socket, ssl_context)
0
+ ssl_socket.sync_close = true
0
+ ssl_socket.connect
0
+ irc = ssl_socket
0
+ else
0
+ irc = socket
0
+ end
0
   irc.puts "PASS #{data['password']}" unless data['password'].empty?
0
   irc.puts "USER #{botname} #{botname} #{botname} :GitHub IRCBot"
0
   irc.puts "NICK #{botname}"

Comments

    No one has commented yet.