websocket-server 1.1.3-java → 1.1.5-java
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/lib/logging.rb +1 -1
- data/lib/websocket/config.rb +3 -1
- data/lib/websocket/instance_methods.rb +3 -54
- data/lib/websocket/server.rb +5 -0
- data/lib/websocket/ssl_context_initialization.rb +9 -0
- data/lib/websocket/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 58298e46b315a6b0a3b263a24b5ce82644a75e26b828d5bbee46b9206c4bb944
|
|
4
|
+
data.tar.gz: 8ab9652cb207c8c3f180ffb85792782b4665a9842d71299e5bf368fedef5737d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 94ad7799ec5713d5e4f0671158d488856f91e99cbd7e8d8dd9d9a06e622c273d28e95bfe3d377efe571ba779149bd62ec1dd8402ace97f66c11921b894b11312
|
|
7
|
+
data.tar.gz: ebefc7c8ec573d5266d72c76e54e7bcd240efe8289f3aefc74c679a29f83e61b27edc7a8a59ecaf96491948b84c2686ae4e9db0496fb30aad30c64226e101a18
|
data/lib/logging.rb
CHANGED
|
@@ -156,7 +156,7 @@ module Logging
|
|
|
156
156
|
java_import Java::org.apache.logging.log4j.LogManager
|
|
157
157
|
end
|
|
158
158
|
|
|
159
|
-
FORWARD_SLASH_PATTERN = %r{/}
|
|
159
|
+
FORWARD_SLASH_PATTERN = %r{/} unless defined? FORWARD_SLASH_PATTERN
|
|
160
160
|
|
|
161
161
|
def init_logger(level = :info, logger_name = nil)
|
|
162
162
|
return init_java_logger(level, logger_name, caller[2]) if defined?(Java)
|
data/lib/websocket/config.rb
CHANGED
|
@@ -41,6 +41,8 @@ module WebSocket
|
|
|
41
41
|
inspect_ssl: false,
|
|
42
42
|
idle_reading: 5 * 60, # seconds
|
|
43
43
|
idle_writing: 30, # seconds
|
|
44
|
+
keep_alive: true,
|
|
45
|
+
max_queued_incoming_connections: 100,
|
|
44
46
|
index_page: 'index.html',
|
|
45
47
|
web_root: File.join(project_dir_path, 'web'),
|
|
46
48
|
web_socket_path: '/websocket',
|
|
@@ -51,7 +53,7 @@ module WebSocket
|
|
|
51
53
|
insecure_uri_pattern: /.*[<>&"].*/,
|
|
52
54
|
allowed_file_name: /[A-Za-z0-9][-_A-Za-z0-9\\.]*/,
|
|
53
55
|
log_requests: false
|
|
54
|
-
}
|
|
56
|
+
}.freeze
|
|
55
57
|
end
|
|
56
58
|
end
|
|
57
59
|
module_function :server_config
|
|
@@ -19,23 +19,15 @@ require_relative 'shutdown_hook'
|
|
|
19
19
|
# The WebSocket module
|
|
20
20
|
module WebSocket
|
|
21
21
|
java_import Java::io.netty.bootstrap.ServerBootstrap
|
|
22
|
-
java_import Java::io.netty.channel.
|
|
23
|
-
java_import Java::io.netty.channel.nio.NioEventLoopGroup
|
|
24
|
-
java_import Java::io.netty.handler.logging.LoggingHandler
|
|
25
|
-
java_import Java::io.netty.handler.logging.LogLevel
|
|
26
|
-
java_import Java::io.netty.util.concurrent.GlobalEventExecutor
|
|
22
|
+
java_import Java::io.netty.channel.ChannelOption
|
|
27
23
|
|
|
28
24
|
# The InstanceMethods module
|
|
29
25
|
module InstanceMethods
|
|
30
|
-
def configure_handlers(&block)
|
|
31
|
-
add_listener(self)
|
|
32
|
-
channel_initializer << block if block_given?
|
|
33
|
-
end
|
|
34
|
-
|
|
35
26
|
def bootstrap
|
|
36
27
|
@bootstrap = ServerBootstrap.new
|
|
37
28
|
@bootstrap.group(boss_group, worker_group)
|
|
38
|
-
@bootstrap.channel(
|
|
29
|
+
@bootstrap.channel(channel_type)
|
|
30
|
+
@bootstrap.option(ChannelOption::SO_BACKLOG, max_queued_incoming_connections)
|
|
39
31
|
@bootstrap.handler(logging_handler) if @options[:log_requests]
|
|
40
32
|
@bootstrap.childHandler(channel_initializer)
|
|
41
33
|
end
|
|
@@ -44,22 +36,6 @@ module WebSocket
|
|
|
44
36
|
@channel_initializer ||= ::WebSocket::ChannelInitializer.new(channel_group, @options)
|
|
45
37
|
end
|
|
46
38
|
|
|
47
|
-
def boss_group
|
|
48
|
-
@boss_group ||= NioEventLoopGroup.new(2)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def worker_group
|
|
52
|
-
@worker_group ||= NioEventLoopGroup.new
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def channel_group
|
|
56
|
-
@channel_group ||= DefaultChannelGroup.new('server_channels', GlobalEventExecutor::INSTANCE)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def logging_handler
|
|
60
|
-
LoggingHandler.new(LogLevel::INFO)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
39
|
# rubocop: disable Metrics/AbcSize
|
|
64
40
|
# rubocop: disable Metrics/MethodLength
|
|
65
41
|
def run(params = {})
|
|
@@ -82,33 +58,6 @@ module WebSocket
|
|
|
82
58
|
def port
|
|
83
59
|
@port ||= (@options[:ssl] ? @options[:ssl_port] : @options[:port]).to_i
|
|
84
60
|
end
|
|
85
|
-
|
|
86
|
-
def shutdown
|
|
87
|
-
channel_group.disconnect().awaitUninterruptibly()
|
|
88
|
-
channel_group.close().awaitUninterruptibly()
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def stop
|
|
92
|
-
boss_group&.shutdownGracefully()
|
|
93
|
-
worker_group&.shutdownGracefully()
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
def <<(handler)
|
|
97
|
-
channel_initializer.handlers << handler
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def add_listener(*listener)
|
|
101
|
-
channel_initializer.add_listener(*listener)
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
# def all_exist?(*files)
|
|
105
|
-
# files.all? { |f| File.exist?(f) }
|
|
106
|
-
# end
|
|
107
|
-
|
|
108
|
-
# def init_ssl_context(certificate, private_key)
|
|
109
|
-
# return certificate_key_pair(certificate, private_key) if all_exist?(certificate, private_key)
|
|
110
|
-
# options[:use_jdk_ssl_provider] ? jdk_ssl_provider : self_signed_certificate
|
|
111
|
-
# end
|
|
112
61
|
end
|
|
113
62
|
# module ServerInstanceMethods
|
|
114
63
|
end
|
data/lib/websocket/server.rb
CHANGED
|
@@ -19,6 +19,11 @@ module WebSocket
|
|
|
19
19
|
# The Server class sets up the netty server
|
|
20
20
|
class Server < ::Server::Server
|
|
21
21
|
include ::WebSocket::InstanceMethods
|
|
22
|
+
|
|
23
|
+
def initialize(options = {}, *handlers, &block)
|
|
24
|
+
raise ArgumentError, 'Parameter may not be nil: options' if options.nil?
|
|
25
|
+
super(::WebSocket.server_config.merge(options), *handlers, &block)
|
|
26
|
+
end
|
|
22
27
|
end
|
|
23
28
|
end
|
|
24
29
|
# module WebSocket
|
|
@@ -36,6 +36,15 @@ module WebSocket
|
|
|
36
36
|
channel_initializer.ssl_context = context unless context.nil?
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
+
def all_exist?(*files)
|
|
40
|
+
files.all? { |f| File.exist?(f) }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def init_ssl_context(certificate, private_key)
|
|
44
|
+
return certificate_key_pair(certificate, private_key) if all_exist?(certificate, private_key)
|
|
45
|
+
options[:use_jdk_ssl_provider] ? jdk_ssl_provider : self_signed_certificate
|
|
46
|
+
end
|
|
47
|
+
|
|
39
48
|
def ssl_context
|
|
40
49
|
@ssl_context ||= init_ssl_context(options[:ssl_certificate_file_path], options[:ssl_private_key_file_path])
|
|
41
50
|
end
|
data/lib/websocket/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: websocket-server
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.5
|
|
5
5
|
platform: java
|
|
6
6
|
authors:
|
|
7
7
|
- Nels Nelson
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-04-
|
|
11
|
+
date: 2024-04-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
|
15
15
|
requirements:
|
|
16
16
|
- - "~>"
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 1.1.
|
|
18
|
+
version: 1.1.4
|
|
19
19
|
name: tcp-server
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
@@ -23,7 +23,7 @@ dependencies:
|
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 1.1.
|
|
26
|
+
version: 1.1.4
|
|
27
27
|
force_ruby_platform: false
|
|
28
28
|
description: Websocket Server for JRuby is a websocket server with a file server to
|
|
29
29
|
support a demo javascript client application which interfaces with a demo echo server
|