flyerhzm-rfetion 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +1 -0
- data/VERSION +1 -1
- data/lib/rfetion/fetion.rb +15 -12
- data/rfetion.gemspec +41 -0
- metadata +2 -1
data/README.textile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/rfetion/fetion.rb
CHANGED
@@ -10,6 +10,7 @@ class Fetion
|
|
10
10
|
FETION_CONFIG_URL = 'http://nav.fetion.com.cn/nav/getsystemconfig.aspx'
|
11
11
|
FETION_SIPP = 'SIPP'
|
12
12
|
GUID = UUID.new.generate
|
13
|
+
@@nonce = nil
|
13
14
|
|
14
15
|
def initialize
|
15
16
|
@next_call = 0
|
@@ -96,19 +97,21 @@ class Fetion
|
|
96
97
|
curl_exec(next_url('i'), @ssic, msg)
|
97
98
|
|
98
99
|
response = curl_exec(next_url, @ssic, FETION_SIPP)
|
99
|
-
|
100
|
+
unless @@nonce
|
101
|
+
raise FetionException.new("Fetion Error: no nonce found") unless response.body =~ /nonce="(\w+)"/
|
102
|
+
end
|
100
103
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
104
|
+
@@nonce = $1
|
105
|
+
@@salt = "777A6D03"
|
106
|
+
@@cnonce = calc_cnonce
|
107
|
+
@@response = calc_response
|
105
108
|
|
106
|
-
@logger.debug "nonce: #{
|
107
|
-
@logger.debug "salt: #{
|
108
|
-
@logger.debug "cnonce: #{
|
109
|
-
@logger.debug "response: #{
|
109
|
+
@logger.debug "nonce: #{@@nonce}"
|
110
|
+
@logger.debug "salt: #{@@salt}"
|
111
|
+
@logger.debug "cnonce: #{@@cnonce}"
|
112
|
+
@logger.debug "response: #{@@response}"
|
110
113
|
|
111
|
-
msg = sip_create('R fetion.com.cn SIP-C/2.0', {'F' => @sid, 'I' => call, 'Q' => '2 R', 'A' => "Digest algorithm=\"SHA1-sess\",response=\"#{
|
114
|
+
msg = sip_create('R fetion.com.cn SIP-C/2.0', {'F' => @sid, 'I' => call, 'Q' => '2 R', 'A' => "Digest algorithm=\"SHA1-sess\",response=\"#{@@response}\",cnonce=\"#{@@cnonce}\",salt=\"#{@@salt}\""}, arg) + FETION_SIPP
|
112
115
|
curl_exec(next_url, @ssic, msg)
|
113
116
|
response = curl_exec(next_url, @ssic, FETION_SIPP)
|
114
117
|
|
@@ -187,10 +190,10 @@ class Fetion
|
|
187
190
|
str = [hash_password[8..-1]].pack("H*")
|
188
191
|
key = Digest::SHA1.digest("#{@sid}:#{@domain}:#{str}")
|
189
192
|
|
190
|
-
h1 = Digest::MD5.hexdigest("#{key}:#{
|
193
|
+
h1 = Digest::MD5.hexdigest("#{key}:#{@@nonce}:#{@@cnonce}").upcase
|
191
194
|
h2 = Digest::MD5.hexdigest("REGISTER:#{@sid}").upcase
|
192
195
|
|
193
|
-
Digest::MD5.hexdigest("#{h1}:#{
|
196
|
+
Digest::MD5.hexdigest("#{h1}:#{@@nonce}:#{h2}").upcase
|
194
197
|
end
|
195
198
|
|
196
199
|
def calc_cnonce
|
data/rfetion.gemspec
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{rfetion}
|
8
|
+
s.version = "0.1.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Richard Huang"]
|
12
|
+
s.date = %q{2009-09-17}
|
13
|
+
s.description = %q{rfetion is a ruby gem for China Mobile fetion service that you can send SMS free.}
|
14
|
+
s.email = %q{flyerhzm@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.textile"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"README.textile",
|
20
|
+
"Rakefile",
|
21
|
+
"VERSION",
|
22
|
+
"lib/rfetion.rb",
|
23
|
+
"lib/rfetion/fetion.rb",
|
24
|
+
"rfetion.gemspec"
|
25
|
+
]
|
26
|
+
s.homepage = %q{}
|
27
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
28
|
+
s.require_paths = ["lib"]
|
29
|
+
s.rubygems_version = %q{1.3.5}
|
30
|
+
s.summary = %q{rfetion is a ruby gem for China Mobile fetion service that you can send SMS free.}
|
31
|
+
|
32
|
+
if s.respond_to? :specification_version then
|
33
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
34
|
+
s.specification_version = 3
|
35
|
+
|
36
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
37
|
+
else
|
38
|
+
end
|
39
|
+
else
|
40
|
+
end
|
41
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flyerhzm-rfetion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
@@ -27,6 +27,7 @@ files:
|
|
27
27
|
- VERSION
|
28
28
|
- lib/rfetion.rb
|
29
29
|
- lib/rfetion/fetion.rb
|
30
|
+
- rfetion.gemspec
|
30
31
|
has_rdoc: false
|
31
32
|
homepage: ""
|
32
33
|
licenses:
|