websocket secure params in app_config
This commit is contained in:
parent
de1fed70f0
commit
c5ae73f96d
3 changed files with 22 additions and 6 deletions
|
|
@ -8,9 +8,9 @@
|
|||
$(document).ready(function(){
|
||||
function debug(str){ $("#debug").append("<p>" + str); };
|
||||
|
||||
ws = new WebSocket("ws://#{request.host}:#{APP_CONFIG[:socket_port]}/");
|
||||
ws = new WebSocket("#{(APP_CONFIG[:socket_secure])?'wss':'ws'}://#{request.host}:#{APP_CONFIG[:socket_port]}/");
|
||||
|
||||
//Attach onmessage to websocket
|
||||
//Attach onmessage to websocket
|
||||
ws.onmessage = function(evt) {
|
||||
var obj = jQuery.parseJSON(evt.data);
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,12 @@ default:
|
|||
socket_port: 8080
|
||||
socket_collection_name: 'websocket'
|
||||
|
||||
# Secure websocket confguration (wss://)
|
||||
# requires SSL cert and key
|
||||
socket_secure: false
|
||||
socket_private_key_location: '/full/path/to/file.key'
|
||||
socket_cert_chain_location: '/full/path/to/cert_chain.crt'
|
||||
|
||||
# Diaspora is only tested against this default pubsub server.
|
||||
pubsub_server: 'https://pubsubhubbub.appspot.com/'
|
||||
|
||||
|
|
|
|||
|
|
@ -45,10 +45,20 @@ begin
|
|||
EM.run {
|
||||
Diaspora::WebSocket.initialize_channels
|
||||
|
||||
EventMachine::WebSocket.start(
|
||||
:host => APP_CONFIG[:socket_host],
|
||||
:port => APP_CONFIG[:socket_port],
|
||||
:debug =>APP_CONFIG[:socket_debug]) do |ws|
|
||||
socket_params = { :host => APP_CONFIG[:socket_host],
|
||||
:port => APP_CONFIG[:socket_port],
|
||||
:debug =>APP_CONFIG[:socket_debug] }
|
||||
|
||||
if APP_CONFIG[:socket_secure] && APP_CONFIG[:socket_private_key_location] && APP_CONFIG[:socket_cert_chain_location]
|
||||
socket_params[:secure] = true;
|
||||
socket_params[:tls_options] = {
|
||||
:private_key_file => APP_CONFIG[:socket_private_key_location],
|
||||
:cert_chain_file => APP_CONFIG[:socket_cert_chain_location]
|
||||
}
|
||||
end
|
||||
|
||||
EventMachine::WebSocket.start( socket_params ) do |ws|
|
||||
|
||||
ws.onopen {
|
||||
begin
|
||||
debug_pp ws.request
|
||||
|
|
|
|||
Loading…
Reference in a new issue