skates 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -2
- data/lib/skates/client_connection.rb +32 -7
- metadata +5 -5
data/Rakefile
CHANGED
@@ -13,9 +13,9 @@ begin
|
|
13
13
|
gem.add_dependency('eventmachine', ">= 0.12.10")
|
14
14
|
gem.add_dependency('log4r')
|
15
15
|
gem.add_dependency('superfeedr-nokogiri', ">= 1.4.0")
|
16
|
-
gem.add_dependency('
|
16
|
+
gem.add_dependency('superfeedr-sax-machine', ">= 0.0.22")
|
17
17
|
gem.add_dependency('templater')
|
18
|
-
gem.requirements = ["eventmachine", "yaml", "fileutils", "log4r", "superfeedr-nokogiri", "
|
18
|
+
gem.requirements = ["eventmachine", "yaml", "fileutils", "log4r", "superfeedr-nokogiri", "superfeedr-sax-machine", "templater", "optparse", "digest/sha1", "base64", "resolv", "activesupport"]
|
19
19
|
gem.executables = "skates"
|
20
20
|
gem.files = [ "bin/skates",
|
21
21
|
"lib/skates.rb",
|
@@ -20,7 +20,7 @@ module Skates
|
|
20
20
|
# It will not resolve if params["host"] is an IP.
|
21
21
|
# And it will always use
|
22
22
|
def self.connect(params, handler = nil)
|
23
|
-
params["host"] ||= params["jid"].split("/").first.split("@").last
|
23
|
+
params["host"] ||= "_xmpp-client._tcp." + params["jid"].split("/").first.split("@").last
|
24
24
|
super(params, handler)
|
25
25
|
end
|
26
26
|
|
@@ -30,20 +30,45 @@ module Skates
|
|
30
30
|
Resolv::DNS.open { |dns|
|
31
31
|
# If ruby version is too old and SRV is unknown, this will raise a NameError
|
32
32
|
# which is caught below
|
33
|
-
Skates.logger.debug {
|
34
|
-
"RESOLVING: #{srv_for_host(host)} (SRV)"
|
35
|
-
}
|
36
33
|
begin
|
37
|
-
|
34
|
+
found = false
|
35
|
+
|
36
|
+
Skates.logger.debug {
|
37
|
+
"RESOLVING: #{host} (SRV)"
|
38
|
+
}
|
39
|
+
srv = dns.getresources(host, Resolv::DNS::Resource::IN::SRV)
|
38
40
|
# Sort SRV records: lowest priority first, highest weight first
|
39
41
|
srv.sort! { |a,b| (a.priority != b.priority) ? (a.priority <=> b.priority) : (b.weight <=> a.weight) }
|
42
|
+
Skates.logger.debug {
|
43
|
+
"Found #{srv.count} SRV records for : #{host} : #{srv.inspect}"
|
44
|
+
}
|
40
45
|
# And now, for each record, let's try to connect.
|
41
46
|
srv.each { |record|
|
47
|
+
Skates.logger.debug {
|
48
|
+
"Trying connection with : #{record.target.to_s}:#{record.port}"
|
49
|
+
}
|
42
50
|
ip = record.target.to_s
|
43
51
|
port = Integer(record.port)
|
44
|
-
|
52
|
+
if block.call({"host" => ip, "port" => port})
|
53
|
+
found = true
|
54
|
+
break
|
55
|
+
end
|
45
56
|
}
|
46
|
-
|
57
|
+
if !found
|
58
|
+
# We failover to solving A record with default port.
|
59
|
+
Skates.logger.debug {
|
60
|
+
"RESOLVING: #{host} (A record)"
|
61
|
+
}
|
62
|
+
records = dns.getresources(host, Resolv::DNS::Resource::IN::A)
|
63
|
+
records.each do |record|
|
64
|
+
ip = record.address.to_s
|
65
|
+
if block.call({"host" => ip, "port" => Integer(Skates.config["port"]) || 5222})
|
66
|
+
found = true
|
67
|
+
break
|
68
|
+
end
|
69
|
+
end
|
70
|
+
block.call(false) unless found# bleh, we couldn't resolve to host that accept connections. Too bad.
|
71
|
+
end
|
47
72
|
rescue NameError
|
48
73
|
Skates.logger.debug {
|
49
74
|
"Resolv::DNS does not support SRV records. Please upgrade to ruby-1.8.3 or later! \n#{$!} : #{$!.backtrace.join("\n")}"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skates
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- julien Genestoux
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-21 00:00:00 -08:00
|
13
13
|
default_executable: skates
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -43,14 +43,14 @@ dependencies:
|
|
43
43
|
version: 1.4.0
|
44
44
|
version:
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
|
-
name:
|
46
|
+
name: superfeedr-sax-machine
|
47
47
|
type: :runtime
|
48
48
|
version_requirement:
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0.0.
|
53
|
+
version: 0.0.22
|
54
54
|
version:
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: templater
|
@@ -128,7 +128,7 @@ requirements:
|
|
128
128
|
- fileutils
|
129
129
|
- log4r
|
130
130
|
- superfeedr-nokogiri
|
131
|
-
-
|
131
|
+
- superfeedr-sax-machine
|
132
132
|
- templater
|
133
133
|
- optparse
|
134
134
|
- digest/sha1
|