ultrahook 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +1 -1
- data/lib/ultrahook.rb +0 -0
- data/lib/ultrahook/client.rb +26 -9
- data/lib/ultrahook/version.rb +1 -1
- metadata +16 -22
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f121751871d589fe219517b892a2a68259f72f2d6290ea180fc803ca8d13809b
|
4
|
+
data.tar.gz: 40d1424d65a17167fbdd2c687b53f830a0ce0228e014935baccc6c51a82bbc45
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c14c4260e09e8d70f3ee75836584004cb82c1172b9aaf9a556e85a056db173cd774bc4da284b8f005ae2463c66c6bdb829f48d63a4e9ccdccba27e22b38f5cc4
|
7
|
+
data.tar.gz: 58595e2dde96869f35cf76be69716150a8d2050af60b953d7c362107e4d6cf404ff785e83d25368914cd7c4e473e1008f0a838b83a94db6c4cfb65246cb78047
|
data/LICENSE
CHANGED
data/lib/ultrahook.rb
CHANGED
File without changes
|
data/lib/ultrahook/client.rb
CHANGED
@@ -3,6 +3,9 @@ require 'net/http'
|
|
3
3
|
require 'json'
|
4
4
|
require 'base64'
|
5
5
|
require 'optparse'
|
6
|
+
require 'openssl'
|
7
|
+
|
8
|
+
$stdout.sync = true
|
6
9
|
|
7
10
|
module UltraHook
|
8
11
|
class Client
|
@@ -34,7 +37,7 @@ module UltraHook
|
|
34
37
|
end
|
35
38
|
|
36
39
|
if @options["key"].nil? || @options["key"] == ""
|
37
|
-
path = "
|
40
|
+
path = File.expand_path("~/.ultrahook")
|
38
41
|
if File.readable?(path)
|
39
42
|
if matchdata = /api_key:\s*([^\s]+)/.match(IO.read(path))
|
40
43
|
@options["key"] = matchdata.captures[0]
|
@@ -69,7 +72,7 @@ module UltraHook
|
|
69
72
|
"http://#{dest}"
|
70
73
|
elsif dest =~ /^[[:alnum:]\.\-]+$/
|
71
74
|
"http://#{dest}"
|
72
|
-
elsif dest =~ /^
|
75
|
+
elsif dest =~ /^https?:\/\//
|
73
76
|
dest
|
74
77
|
else
|
75
78
|
error "Cannot parse destination url"
|
@@ -78,7 +81,7 @@ module UltraHook
|
|
78
81
|
|
79
82
|
def process(msg)
|
80
83
|
begin
|
81
|
-
payload = JSON.parse(Base64.decode64(msg))
|
84
|
+
payload = JSON.parse(Base64.decode64(msg).force_encoding("utf-8"))
|
82
85
|
rescue
|
83
86
|
error "Cannot communicate with server."
|
84
87
|
end
|
@@ -89,7 +92,7 @@ module UltraHook
|
|
89
92
|
|
90
93
|
def process_init(payload)
|
91
94
|
puts "Forwarding activated..."
|
92
|
-
puts "
|
95
|
+
puts "https://#{@ultrahook_host} -> #{@options["destination"]}"
|
93
96
|
end
|
94
97
|
|
95
98
|
def process_error(payload)
|
@@ -100,6 +103,14 @@ module UltraHook
|
|
100
103
|
puts "Warning: "+payload["message"]
|
101
104
|
end
|
102
105
|
|
106
|
+
def process_message(payload)
|
107
|
+
puts payload["message"]
|
108
|
+
end
|
109
|
+
|
110
|
+
def process_ping(payload)
|
111
|
+
# silent ack!
|
112
|
+
end
|
113
|
+
|
103
114
|
def full_path(uri)
|
104
115
|
return "/" if uri.path == "" && uri.query == ""
|
105
116
|
return "/?#{uri.query}" if uri.path == "" && uri.query != ""
|
@@ -112,15 +123,20 @@ module UltraHook
|
|
112
123
|
uri = URI("#{@options["destination"]}#{payload["path"]}?#{payload["query"]}")
|
113
124
|
response = http_post(uri, payload["body"], payload["headers"])
|
114
125
|
|
115
|
-
puts "[#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}] POST
|
126
|
+
puts "[#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}] POST #{uri.scheme}://#{uri.host}:#{uri.port}#{full_path(uri)} - #{response.code}"
|
116
127
|
end
|
117
128
|
|
118
|
-
def http_post(uri, data, headers=
|
119
|
-
Net::HTTP.new(uri.host, uri.port)
|
129
|
+
def http_post(uri, data="", headers={})
|
130
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
131
|
+
if uri.scheme == "https"
|
132
|
+
http.use_ssl = true
|
133
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
134
|
+
end
|
135
|
+
http.post(full_path(uri), data, headers)
|
120
136
|
end
|
121
137
|
|
122
138
|
def retrieve_config
|
123
|
-
response = http_post(URI("
|
139
|
+
response = http_post(URI("https://www.ultrahook.com/init"), "key=#{@options["key"]}&host=#{@options["host"]}&version=#{UltraHook::VERSION}")
|
124
140
|
|
125
141
|
error "Could not retrieve config from server: #{response.code}" if response.code.to_i != 200
|
126
142
|
|
@@ -128,6 +144,7 @@ module UltraHook
|
|
128
144
|
if payload["success"] == true
|
129
145
|
@stream_url = payload["url"]
|
130
146
|
@namespace = payload["namespace"]
|
147
|
+
@ultrahook_host = payload["host"]
|
131
148
|
|
132
149
|
puts "Authenticated as #{@namespace}"
|
133
150
|
else
|
@@ -137,7 +154,7 @@ module UltraHook
|
|
137
154
|
|
138
155
|
def init_stream
|
139
156
|
uri = URI(@stream_url)
|
140
|
-
Net::HTTP.start(uri.host, uri.port) do |http|
|
157
|
+
Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
141
158
|
begin
|
142
159
|
request = Net::HTTP::Get.new "#{uri.path}?#{uri.query}"
|
143
160
|
|
data/lib/ultrahook/version.rb
CHANGED
metadata
CHANGED
@@ -1,70 +1,64 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ultrahook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Vinay Sahni
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2020-11-18 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: json
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 1.8.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 1.8.0
|
30
|
-
description: UltraHook
|
31
|
-
(provided by the ultrahook.com service) to
|
32
|
-
|
27
|
+
description: UltraHook lets you receive webhooks on localhost. It relays HTTP POST
|
28
|
+
requests sent from a public endpoints (provided by the ultrahook.com service) to
|
29
|
+
private endpoints accessible from your computer.
|
33
30
|
email: vinay@sahni.org
|
34
31
|
executables:
|
35
32
|
- ultrahook
|
36
33
|
extensions: []
|
37
34
|
extra_rdoc_files: []
|
38
35
|
files:
|
39
|
-
- lib/ultrahook/client.rb
|
40
|
-
- lib/ultrahook/version.rb
|
41
|
-
- lib/ultrahook.rb
|
42
36
|
- LICENSE
|
43
37
|
- bin/ultrahook
|
38
|
+
- lib/ultrahook.rb
|
39
|
+
- lib/ultrahook/client.rb
|
40
|
+
- lib/ultrahook/version.rb
|
44
41
|
homepage: http://www.ultrahook.com
|
45
42
|
licenses:
|
46
43
|
- Commercial
|
44
|
+
metadata: {}
|
47
45
|
post_install_message:
|
48
46
|
rdoc_options: []
|
49
47
|
require_paths:
|
50
48
|
- lib
|
51
49
|
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
-
none: false
|
53
50
|
requirements:
|
54
|
-
- -
|
51
|
+
- - ">="
|
55
52
|
- !ruby/object:Gem::Version
|
56
53
|
version: '0'
|
57
54
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
55
|
requirements:
|
60
|
-
- -
|
56
|
+
- - ">="
|
61
57
|
- !ruby/object:Gem::Version
|
62
58
|
version: '0'
|
63
59
|
requirements: []
|
64
|
-
|
65
|
-
rubygems_version: 1.8.25
|
60
|
+
rubygems_version: 3.0.6
|
66
61
|
signing_key:
|
67
|
-
specification_version:
|
68
|
-
summary:
|
69
|
-
firewalls
|
62
|
+
specification_version: 4
|
63
|
+
summary: Receive webhooks on localhost
|
70
64
|
test_files: []
|