hyper-operation 1.0.alpha1.8 → 1.0.0.lap28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -7
- data/.travis.yml +9 -21
- data/CODE_OF_CONDUCT.md +49 -0
- data/DOCS-POLICIES.md +582 -0
- data/DOCS.md +869 -0
- data/Gemfile +1 -5
- data/LICENSE.txt +21 -0
- data/README.md +77 -0
- data/Rakefile +2 -1
- data/dciy.toml +3 -0
- data/hyper-operation.gemspec +15 -19
- data/lib/hyper-operation.rb +6 -10
- data/lib/hyper-operation/api.rb +4 -8
- data/lib/hyper-operation/boot.rb +2 -3
- data/lib/hyper-operation/delay_and_interval.rb +9 -0
- data/lib/hyper-operation/engine.rb +2 -2
- data/lib/hyper-operation/exception.rb +4 -30
- data/lib/hyper-operation/filters/acting_user.rb +1 -1
- data/lib/hyper-operation/http.rb +2 -2
- data/lib/hyper-operation/promise.rb +2 -32
- data/lib/hyper-operation/railway.rb +1 -1
- data/lib/hyper-operation/railway/dispatcher.rb +5 -8
- data/lib/hyper-operation/railway/params_wrapper.rb +2 -2
- data/lib/hyper-operation/railway/run.rb +49 -58
- data/lib/hyper-operation/railway/validations.rb +3 -10
- data/lib/hyper-operation/server_op.rb +20 -46
- data/lib/hyper-operation/transport/action_cable.rb +8 -8
- data/lib/hyper-operation/transport/client_drivers.rb +55 -96
- data/lib/hyper-operation/transport/connection.rb +136 -58
- data/lib/hyper-operation/transport/{hyperstack.rb → hyperloop.rb} +15 -28
- data/lib/hyper-operation/transport/{hyperstack_controller.rb → hyperloop_controller.rb} +53 -59
- data/lib/hyper-operation/transport/policy.rb +49 -50
- data/lib/hyper-operation/version.rb +2 -2
- data/lib/sources/{hyperstack → hyperloop}/pusher.js +0 -0
- metadata +73 -94
- data/lib/hyper-operation/async_sleep.rb +0 -23
- data/lib/hyper-operation/transport/connection_adapter/active_record.rb +0 -113
- data/lib/hyper-operation/transport/connection_adapter/active_record/auto_create.rb +0 -26
- data/lib/hyper-operation/transport/connection_adapter/active_record/connection.rb +0 -47
- data/lib/hyper-operation/transport/connection_adapter/active_record/queued_message.rb +0 -42
- data/lib/hyper-operation/transport/connection_adapter/redis.rb +0 -94
- data/lib/hyper-operation/transport/connection_adapter/redis/connection.rb +0 -85
- data/lib/hyper-operation/transport/connection_adapter/redis/queued_message.rb +0 -34
- data/lib/hyper-operation/transport/connection_adapter/redis/redis_record.rb +0 -158
- data/lib/hyper-operation/transport/policy_diagnostics.rb +0 -106
@@ -1,95 +1,173 @@
|
|
1
|
-
|
1
|
+
module Hyperloop
|
2
|
+
module AutoCreate
|
3
|
+
def table_exists?
|
4
|
+
# works with both rails 4 and 5 without deprecation warnings
|
5
|
+
if connection.respond_to?(:data_sources)
|
6
|
+
connection.data_sources.include?(table_name)
|
7
|
+
else
|
8
|
+
connection.tables.include?(table_name)
|
9
|
+
end
|
10
|
+
end
|
2
11
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
else
|
21
|
-
raise e.class, "Error loading the '#{adapter_name}' adapter. Missing a gem it depends on? #{e.message}", e.backtrace
|
22
|
-
end
|
23
|
-
end
|
12
|
+
def needs_init?
|
13
|
+
Hyperloop.transport != :none && Hyperloop.on_server? && !table_exists?
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_table(*args, &block)
|
17
|
+
connection.create_table(table_name, *args, &block) if needs_init?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class Connection < ActiveRecord::Base
|
22
|
+
class QueuedMessage < ActiveRecord::Base
|
23
|
+
|
24
|
+
extend AutoCreate
|
25
|
+
|
26
|
+
self.table_name = 'hyperloop_queued_messages'
|
27
|
+
|
28
|
+
do_not_synchronize
|
24
29
|
|
25
|
-
|
26
|
-
|
30
|
+
serialize :data
|
31
|
+
|
32
|
+
belongs_to :hyperloop_connection,
|
33
|
+
class_name: 'Hyperloop::Connection',
|
34
|
+
foreign_key: 'connection_id'
|
35
|
+
|
36
|
+
scope :for_session,
|
37
|
+
->(session) { joins(:hyperloop_connection).where('session = ?', session) }
|
38
|
+
|
39
|
+
# For simplicity we use QueuedMessage with connection_id 0
|
40
|
+
# to store the current path which is used by consoles to
|
41
|
+
# communicate back to the server
|
42
|
+
|
43
|
+
default_scope { where('connection_id IS NULL OR connection_id != 0') }
|
44
|
+
|
45
|
+
def self.root_path=(path)
|
46
|
+
unscoped.find_or_create_by(connection_id: 0).update(data: path)
|
27
47
|
end
|
28
48
|
|
29
|
-
def
|
30
|
-
|
49
|
+
def self.root_path
|
50
|
+
unscoped.find_or_create_by(connection_id: 0).data
|
31
51
|
end
|
52
|
+
end
|
32
53
|
|
33
|
-
|
34
|
-
|
54
|
+
extend AutoCreate
|
55
|
+
|
56
|
+
def self.build_tables
|
57
|
+
create_table(force: :cascade) do |t|
|
58
|
+
t.string :channel
|
59
|
+
t.string :session
|
60
|
+
t.datetime :created_at
|
61
|
+
t.datetime :expires_at
|
62
|
+
t.datetime :refresh_at
|
63
|
+
end
|
64
|
+
QueuedMessage.create_table(force: :cascade) do |t|
|
65
|
+
t.text :data
|
66
|
+
t.integer :connection_id
|
35
67
|
end
|
68
|
+
end
|
36
69
|
|
37
|
-
|
38
|
-
|
70
|
+
do_not_synchronize
|
71
|
+
|
72
|
+
self.table_name = 'hyperloop_connections'
|
73
|
+
|
74
|
+
has_many :messages,
|
75
|
+
foreign_key: 'connection_id',
|
76
|
+
class_name: 'Hyperloop::Connection::QueuedMessage',
|
77
|
+
dependent: :destroy
|
78
|
+
scope :expired,
|
79
|
+
-> { where('expires_at IS NOT NULL AND expires_at < ?', Time.zone.now) }
|
80
|
+
scope :pending_for,
|
81
|
+
->(channel) { where(channel: channel).where('session IS NOT NULL') }
|
82
|
+
scope :inactive,
|
83
|
+
-> { where('session IS NULL AND refresh_at < ?', Time.zone.now) }
|
84
|
+
|
85
|
+
def self.needs_refresh?
|
86
|
+
exists?(['refresh_at IS NOT NULL AND refresh_at < ?', Time.zone.now])
|
87
|
+
end
|
88
|
+
|
89
|
+
def transport
|
90
|
+
self.class.transport
|
91
|
+
end
|
92
|
+
|
93
|
+
before_create do
|
94
|
+
if session
|
95
|
+
self.expires_at = Time.now + transport.expire_new_connection_in
|
96
|
+
elsif transport.refresh_channels_every != :never
|
97
|
+
self.refresh_at = Time.now + transport.refresh_channels_every
|
39
98
|
end
|
99
|
+
end
|
40
100
|
|
41
|
-
|
42
|
-
|
101
|
+
class << self
|
102
|
+
attr_accessor :transport
|
43
103
|
|
44
|
-
|
45
|
-
|
104
|
+
def active
|
105
|
+
# if table doesn't exist then we are either calling from within
|
106
|
+
# a migration or from a console before the server has ever started
|
107
|
+
# in these cases there are no channels so we return nothing
|
108
|
+
return [] unless table_exists?
|
109
|
+
if Hyperloop.on_server?
|
110
|
+
expired.delete_all
|
111
|
+
refresh_connections if needs_refresh?
|
46
112
|
end
|
113
|
+
all.pluck(:channel).uniq
|
47
114
|
end
|
48
115
|
|
49
|
-
def
|
50
|
-
|
116
|
+
def open(channel, session = nil, root_path = nil)
|
117
|
+
self.root_path = root_path
|
118
|
+
find_or_create_by(channel: channel, session: session)
|
119
|
+
end
|
51
120
|
|
52
|
-
|
121
|
+
def send_to_channel(channel, data)
|
122
|
+
pending_for(channel).each do |connection|
|
123
|
+
QueuedMessage.create(data: data, hyperloop_connection: connection)
|
124
|
+
end
|
125
|
+
transport.send_data(channel, data) if exists?(channel: channel, session: nil)
|
53
126
|
end
|
54
127
|
|
55
128
|
def read(session, root_path)
|
56
|
-
|
57
|
-
|
58
|
-
|
129
|
+
self.root_path = root_path
|
130
|
+
where(session: session)
|
131
|
+
.update_all(expires_at: Time.now + transport.expire_polled_connection_in)
|
132
|
+
QueuedMessage.for_session(session).destroy_all.pluck(:data)
|
59
133
|
end
|
60
134
|
|
61
135
|
def connect_to_transport(channel, session, root_path)
|
62
|
-
|
63
|
-
|
64
|
-
|
136
|
+
self.root_path = root_path
|
137
|
+
if (connection = find_by(channel: channel, session: session))
|
138
|
+
messages = connection.messages.pluck(:data)
|
139
|
+
connection.destroy
|
140
|
+
else
|
141
|
+
messages = []
|
142
|
+
end
|
143
|
+
open(channel)
|
144
|
+
messages
|
65
145
|
end
|
66
146
|
|
67
147
|
def disconnect(channel)
|
68
|
-
|
148
|
+
find_by(channel: channel, session: nil).destroy
|
69
149
|
end
|
70
150
|
|
71
151
|
def root_path=(path)
|
72
|
-
|
152
|
+
QueuedMessage.root_path = path if path
|
73
153
|
end
|
74
154
|
|
75
155
|
def root_path
|
76
|
-
|
156
|
+
# if the QueuedMessage table doesn't exist then we are either calling from within
|
157
|
+
# a migration or from a console before the server has ever started
|
158
|
+
# in these cases there is no root path to the server
|
159
|
+
QueuedMessage.root_path if QueuedMessage.table_exists?
|
77
160
|
end
|
78
161
|
|
79
162
|
def refresh_connections
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
else
|
87
|
-
super
|
163
|
+
refresh_started_at = Time.zone.now
|
164
|
+
channels = transport.refresh_channels
|
165
|
+
next_refresh = refresh_started_at + transport.refresh_channels_every
|
166
|
+
channels.each do |channel|
|
167
|
+
connection = find_by(channel: channel, session: nil)
|
168
|
+
connection.update(refresh_at: next_refresh) if connection
|
88
169
|
end
|
89
|
-
|
90
|
-
|
91
|
-
def respond_to_missing?(method_name, include_private = false)
|
92
|
-
adapter::Connection.respond_to?(method_name)
|
170
|
+
inactive.delete_all
|
93
171
|
end
|
94
172
|
end
|
95
173
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# Provides the configuration and the two basic routines for the server
|
2
2
|
# to indicate that records have changed: after_change and after_destroy
|
3
|
-
module
|
3
|
+
module Hyperloop
|
4
4
|
|
5
5
|
def self.initialize_policies
|
6
6
|
reset_operations unless @config_reset_called
|
@@ -13,10 +13,10 @@ module Hyperstack
|
|
13
13
|
def self.reset_operations
|
14
14
|
@config_reset_called = true
|
15
15
|
Rails.configuration.tap do |config|
|
16
|
-
# config.eager_load_paths += %W(#{config.root}/app/
|
17
|
-
# config.autoload_paths += %W(#{config.root}/app/
|
18
|
-
# config.assets.paths << ::Rails.root.join('app', '
|
19
|
-
config.after_initialize { Connection.build_tables
|
16
|
+
# config.eager_load_paths += %W(#{config.root}/app/hyperloop/models)
|
17
|
+
# config.autoload_paths += %W(#{config.root}/app/hyperloop/models)
|
18
|
+
# config.assets.paths << ::Rails.root.join('app', 'hyperloop').to_s
|
19
|
+
config.after_initialize { Connection.build_tables }
|
20
20
|
end
|
21
21
|
Object.send(:remove_const, :Application) if @fake_application_defined
|
22
22
|
@fake_application_defined = false
|
@@ -37,10 +37,10 @@ module Hyperstack
|
|
37
37
|
@fake_application_defined = true
|
38
38
|
end
|
39
39
|
begin
|
40
|
-
Object.const_get '
|
40
|
+
Object.const_get 'Hyperloop::ApplicationPolicy'
|
41
41
|
rescue LoadError
|
42
42
|
rescue NameError => e
|
43
|
-
raise e unless e.message =~ /uninitialized constant
|
43
|
+
raise e unless e.message =~ /uninitialized constant Hyperloop::ApplicationPolicy/
|
44
44
|
end
|
45
45
|
@pusher = nil
|
46
46
|
end
|
@@ -49,31 +49,21 @@ module Hyperstack
|
|
49
49
|
if transport == :action_cable
|
50
50
|
require 'hyper-operation/transport/action_cable'
|
51
51
|
opts[:refresh_channels_every] = :never
|
52
|
-
import 'action_cable', client_only: true if Rails.configuration.
|
52
|
+
import 'action_cable', client_only: true if Rails.configuration.hyperloop.auto_config
|
53
53
|
elsif transport == :pusher
|
54
54
|
require 'pusher'
|
55
|
-
import '
|
55
|
+
import 'hyperloop/pusher', client_only: true if Rails.configuration.hyperloop.auto_config
|
56
56
|
opts[:refresh_channels_every] = nil if opts[:refresh_channels_every] == :never
|
57
57
|
else
|
58
58
|
opts[:refresh_channels_every] = nil if opts[:refresh_channels_every] == :never
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
define_setting(:send_to_server_timeout, 10)
|
63
|
-
|
64
62
|
define_setting :opts, {}
|
65
63
|
define_setting :channel_prefix, 'synchromesh'
|
66
64
|
define_setting :client_logging, true
|
67
65
|
define_setting :connect_session, true
|
68
66
|
|
69
|
-
define_setting(:connection, { adapter: :active_record }) do |connection|
|
70
|
-
if connection[:adapter] == :redis
|
71
|
-
require 'redis'
|
72
|
-
|
73
|
-
connection[:redis_url] ||= 'redis://127.0.0.1:6379/hyperstack'
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
67
|
def self.app_id
|
78
68
|
opts[:app_id] || Pusher.app_id if transport == :pusher
|
79
69
|
end
|
@@ -117,7 +107,7 @@ module Hyperstack
|
|
117
107
|
|
118
108
|
def self.refresh_channels
|
119
109
|
new_channels = pusher.channels[:channels].collect do |channel, _etc|
|
120
|
-
channel.gsub(/^#{Regexp.quote(
|
110
|
+
channel.gsub(/^#{Regexp.quote(Hyperloop.channel)}\-/, '').gsub('==', '::')
|
121
111
|
end
|
122
112
|
end
|
123
113
|
|
@@ -125,9 +115,9 @@ module Hyperstack
|
|
125
115
|
if !on_server?
|
126
116
|
send_to_server(channel, data)
|
127
117
|
elsif transport == :pusher
|
128
|
-
pusher.trigger("#{
|
118
|
+
pusher.trigger("#{Hyperloop.channel}-#{data[1][:channel].gsub('::', '==')}", *data)
|
129
119
|
elsif transport == :action_cable
|
130
|
-
ActionCable.server.broadcast("
|
120
|
+
ActionCable.server.broadcast("hyperloop-#{channel}", message: data[0], data: data[1])
|
131
121
|
end
|
132
122
|
end
|
133
123
|
|
@@ -173,15 +163,12 @@ module Hyperstack
|
|
173
163
|
request.body = {
|
174
164
|
channel: channel, data: data, salt: salt, authorization: authorization
|
175
165
|
}.to_json
|
176
|
-
|
177
|
-
rescue Timeout::Error
|
178
|
-
puts "\n********* FAILED TO RECEIVE RESPONSE FROM SERVER WITHIN #{Hyperstack.send_to_server_timeout} SECONDS. CHANGES WILL NOT BE SYNCED ************\n"
|
179
|
-
raise 'no server running'
|
166
|
+
http.request(request)
|
180
167
|
end
|
181
168
|
|
182
169
|
def self.dispatch(data)
|
183
|
-
if !
|
184
|
-
|
170
|
+
if !Hyperloop.on_server? && Connection.root_path
|
171
|
+
Hyperloop.send_to_server(data[:channel], [:dispatch, data])
|
185
172
|
else
|
186
173
|
Connection.send_to_channel(data[:channel], [:dispatch, data])
|
187
174
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
module
|
2
|
-
::
|
3
|
-
|
1
|
+
module Hyperloop
|
2
|
+
::Hyperloop::Engine.routes.append do
|
3
|
+
Hyperloop.initialize_policies
|
4
4
|
|
5
5
|
module ::WebConsole
|
6
6
|
class Middleware
|
@@ -11,22 +11,18 @@ module Hyperstack
|
|
11
11
|
end
|
12
12
|
end if defined? ::WebConsole::Middleware
|
13
13
|
|
14
|
-
|
15
|
-
# The purpose of this is to prevent massive amounts of logging
|
16
|
-
# if using simple polling. If polling is on then only actual messages
|
17
|
-
# with content will be shown, other wise the log message is dropped.
|
18
14
|
module ::Rails
|
19
15
|
module Rack
|
20
16
|
class Logger < ActiveSupport::LogSubscriber
|
21
|
-
unless method_defined? :
|
22
|
-
alias
|
17
|
+
unless method_defined? :pre_hyperloop_call
|
18
|
+
alias pre_hyperloop_call call
|
23
19
|
def call(env)
|
24
|
-
if
|
20
|
+
if Hyperloop.transport == :simple_poller && env['PATH_INFO'] && env['PATH_INFO'].include?('/hyperloop-read/')
|
25
21
|
Rails.logger.silence do
|
26
|
-
|
22
|
+
pre_hyperloop_call(env)
|
27
23
|
end
|
28
24
|
else
|
29
|
-
|
25
|
+
pre_hyperloop_call(env)
|
30
26
|
end
|
31
27
|
end
|
32
28
|
end
|
@@ -34,7 +30,7 @@ module Hyperstack
|
|
34
30
|
end
|
35
31
|
end if defined?(::Rails::Rack::Logger)
|
36
32
|
|
37
|
-
class
|
33
|
+
class HyperloopController < ::ApplicationController
|
38
34
|
|
39
35
|
protect_from_forgery except: [:console_update, :execute_remote_api]
|
40
36
|
|
@@ -43,28 +39,28 @@ module Hyperstack
|
|
43
39
|
end
|
44
40
|
|
45
41
|
before_action do
|
46
|
-
session.delete '
|
42
|
+
session.delete 'hyperloop-dummy-init' unless session.id
|
47
43
|
end
|
48
44
|
|
49
45
|
def session_channel
|
50
|
-
"
|
46
|
+
"Hyperloop::Session-#{session.id}"
|
51
47
|
end
|
52
48
|
|
53
49
|
def regulate(channel)
|
54
|
-
unless channel == session_channel # "
|
55
|
-
|
50
|
+
unless channel == session_channel # "Hyperloop::Session-#{client_id.split('-').last}"
|
51
|
+
Hyperloop::InternalPolicy.regulate_connection(try(:acting_user), channel)
|
56
52
|
end
|
57
53
|
channel
|
58
54
|
end
|
59
55
|
|
60
56
|
def channels(user = acting_user, session_id = session.id)
|
61
|
-
|
57
|
+
Hyperloop::AutoConnect.channels(session_id, user)
|
62
58
|
end
|
63
59
|
|
64
60
|
def can_connect?(channel, user = acting_user)
|
65
|
-
|
61
|
+
Hyperloop::InternalPolicy.regulate_connection(
|
66
62
|
user,
|
67
|
-
|
63
|
+
Hyperloop::InternalPolicy.channel_to_string(channel)
|
68
64
|
)
|
69
65
|
true
|
70
66
|
rescue
|
@@ -105,47 +101,45 @@ module Hyperstack
|
|
105
101
|
|
106
102
|
def subscribe
|
107
103
|
channel = regulate params[:channel].gsub('==', '::')
|
108
|
-
root_path = request.original_url.gsub(/
|
109
|
-
|
104
|
+
root_path = request.original_url.gsub(/hyperloop-subscribe.*$/, '')
|
105
|
+
Hyperloop::Connection.open(channel, client_id, root_path)
|
110
106
|
head :ok
|
111
107
|
rescue Exception
|
112
108
|
head :unauthorized
|
113
109
|
end
|
114
110
|
|
115
111
|
def read
|
116
|
-
root_path = request.original_url.gsub(/
|
117
|
-
data =
|
112
|
+
root_path = request.original_url.gsub(/hyperloop-read.*$/, '')
|
113
|
+
data = Hyperloop::Connection.read(client_id, root_path)
|
118
114
|
render json: data
|
119
115
|
end
|
120
116
|
|
121
117
|
def pusher_auth
|
122
|
-
raise unless
|
123
|
-
channel = regulate params[:channel_name].gsub(/^#{Regexp.quote(
|
124
|
-
response =
|
118
|
+
raise unless Hyperloop.transport == :pusher
|
119
|
+
channel = regulate params[:channel_name].gsub(/^#{Regexp.quote(Hyperloop.channel)}\-/,'').gsub('==', '::')
|
120
|
+
response = Hyperloop.pusher.authenticate(params[:channel_name], params[:socket_id])
|
125
121
|
render json: response
|
126
122
|
rescue Exception => e
|
127
123
|
head :unauthorized
|
128
124
|
end
|
129
125
|
|
130
126
|
def action_cable_auth
|
131
|
-
raise unless
|
132
|
-
channel = regulate params[:channel_name].gsub(/^#{Regexp.quote(
|
127
|
+
raise unless Hyperloop.transport == :action_cable
|
128
|
+
channel = regulate params[:channel_name].gsub(/^#{Regexp.quote(Hyperloop.channel)}\-/,'')
|
133
129
|
salt = SecureRandom.hex
|
134
|
-
authorization =
|
130
|
+
authorization = Hyperloop.authorization(salt, channel, client_id)
|
135
131
|
render json: {authorization: authorization, salt: salt}
|
136
132
|
rescue Exception
|
137
133
|
head :unauthorized
|
138
134
|
end
|
139
135
|
|
140
136
|
def connect_to_transport
|
141
|
-
root_path = request.original_url.gsub(/
|
142
|
-
render json:
|
143
|
-
rescue Exception => e
|
144
|
-
render status: :service_unavailable, json: {error: e}
|
137
|
+
root_path = request.original_url.gsub(/hyperloop-connect-to-transport.*$/, '')
|
138
|
+
render json: Hyperloop::Connection.connect_to_transport(params[:channel], client_id, root_path)
|
145
139
|
end
|
146
140
|
|
147
141
|
def execute_remote
|
148
|
-
parsed_params = JSON.parse(params[:
|
142
|
+
parsed_params = JSON.parse(params[:json]).symbolize_keys
|
149
143
|
render ServerOp.run_from_client(
|
150
144
|
:acting_user,
|
151
145
|
self,
|
@@ -157,15 +151,15 @@ module Hyperstack
|
|
157
151
|
def execute_remote_api
|
158
152
|
params.require(:params).permit!
|
159
153
|
parsed_params = params[:params].to_h.symbolize_keys
|
160
|
-
raise AccessViolation
|
154
|
+
raise AccessViolation unless parsed_params[:authorization]
|
161
155
|
render ServerOp.run_from_client(:authorization, self, params[:operation], parsed_params)
|
162
156
|
end
|
163
157
|
|
164
158
|
def console_update # TODO this should just become an execute-remote-api call
|
165
159
|
raise unless Rails.env.development?
|
166
|
-
authorization =
|
160
|
+
authorization = Hyperloop.authorization(params[:salt], params[:channel], params[:data][1][:broadcast_id]) #params[:data].to_json)
|
167
161
|
return head :unauthorized if authorization != params[:authorization]
|
168
|
-
|
162
|
+
Hyperloop::Connection.send_to_channel(params[:channel], params[:data])
|
169
163
|
head :no_content
|
170
164
|
rescue
|
171
165
|
head :unauthorized
|
@@ -175,32 +169,32 @@ module Hyperstack
|
|
175
169
|
head :no_content
|
176
170
|
end
|
177
171
|
|
178
|
-
end unless defined?
|
172
|
+
end unless defined? Hyperloop::HyperloopController
|
179
173
|
|
180
174
|
match 'execute_remote',
|
181
|
-
to: '
|
175
|
+
to: 'hyperloop#execute_remote', via: :post
|
182
176
|
match 'execute_remote_api',
|
183
|
-
to: '
|
184
|
-
|
185
|
-
# match '
|
186
|
-
# to: '
|
187
|
-
# match '
|
188
|
-
# to: '
|
189
|
-
match '
|
190
|
-
to: '
|
191
|
-
match '
|
192
|
-
to: '
|
193
|
-
match '
|
194
|
-
to: '
|
195
|
-
match '
|
196
|
-
to: '
|
197
|
-
match '
|
198
|
-
to: '
|
177
|
+
to: 'hyperloop#execute_remote_api', via: :post
|
178
|
+
|
179
|
+
# match 'hyperloop-subscribe',
|
180
|
+
# to: 'hyperloop#subscribe', via: :get
|
181
|
+
# match 'hyperloop-read/:subscriber',
|
182
|
+
# to: 'hyperloop#read', via: :get
|
183
|
+
match 'hyperloop-subscribe/:client_id/:channel',
|
184
|
+
to: 'hyperloop#subscribe', via: :get
|
185
|
+
match 'hyperloop-read/:client_id',
|
186
|
+
to: 'hyperloop#read', via: :get
|
187
|
+
match 'hyperloop-pusher-auth',
|
188
|
+
to: 'hyperloop#pusher_auth', via: :post
|
189
|
+
match 'hyperloop-action-cable-auth/:client_id/:channel_name',
|
190
|
+
to: 'hyperloop#action_cable_auth', via: :post
|
191
|
+
match 'hyperloop-connect-to-transport/:client_id/:channel',
|
192
|
+
to: 'hyperloop#connect_to_transport', via: :get
|
199
193
|
match 'console',
|
200
|
-
to: '
|
194
|
+
to: 'hyperloop#debug_console', via: :get
|
201
195
|
match 'console_update',
|
202
|
-
to: '
|
196
|
+
to: 'hyperloop#console_update', via: :post
|
203
197
|
match 'server_up',
|
204
|
-
to: '
|
198
|
+
to: 'hyperloop#server_up', via: :get
|
205
199
|
end
|
206
200
|
end
|