tanker-core 2.6.2.beta.2 → 2.6.3.beta.1
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/tanker/c_tanker/c_lib.rb +4 -9
- data/lib/tanker/core/stream.rb +27 -18
- data/lib/tanker/core/version.rb +1 -1
- data/vendor/{libctanker/linux64/tanker/lib/libctanker.so → tanker/darwin-x86_64/libctanker.dylib} +0 -0
- data/vendor/tanker/linux-x86_64/libctanker.so +0 -0
- metadata +4 -4
- data/vendor/libctanker/mac64/tanker/lib/libctanker.dylib +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b340cd6c68ae50a570cb9b2fe022cef3e58d977ea496f6a9a9188805dbcefc8f
|
4
|
+
data.tar.gz: '08ed2f6c92839b80f1ad99298affcc5346baa1dd54cec35140a49dcbf1ea53af'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db46bd49eef92e19a889758223a1ca7e187fefd2db5a47fbefd44f990a61a34ca57133bb01683130293c6830805e53b92ca7362538ca00aee4babc08600a7d50
|
7
|
+
data.tar.gz: 841f15d5be8536cca1426ce9e56696c8f053a3684d93ecefdb9f944caf6fc5411aaed74a416c3822495bf26cee104389918df00dda706e955430fe213e6deafd
|
@@ -1,15 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'ffi/platform'
|
4
|
+
|
3
5
|
module Tanker::CTanker
|
4
6
|
def self.get_path(name)
|
5
|
-
|
6
|
-
|
7
|
-
subdir = 'mac64'
|
8
|
-
else
|
9
|
-
ext = '.so'
|
10
|
-
subdir = 'linux64'
|
11
|
-
end
|
12
|
-
|
13
|
-
File.expand_path "../../../vendor/libctanker/#{subdir}/tanker/lib/lib#{name}#{ext}", __dir__
|
7
|
+
File.expand_path "../../../vendor/tanker/#{FFI::Platform::OS}-#{FFI::Platform::ARCH}/"\
|
8
|
+
"#{FFI::Platform::LIBPREFIX}#{name}.#{FFI::Platform::LIBSUFFIX}", __dir__
|
14
9
|
end
|
15
10
|
end
|
data/lib/tanker/core/stream.rb
CHANGED
@@ -3,6 +3,29 @@
|
|
3
3
|
require 'English'
|
4
4
|
require 'tanker/c_tanker'
|
5
5
|
|
6
|
+
# Because Ruby only has synchronous streams, we can't read them on Tanker's
|
7
|
+
# thread (in the read callback). To work around that, we start a new Thread for
|
8
|
+
# each read operation. This is not that bad because Ruby uses a thread pool
|
9
|
+
# behind the scenes and creating a Thread is usually just a work pushed on a
|
10
|
+
# queue.
|
11
|
+
#
|
12
|
+
# Also, there doesn't seem to easily create an IO object. The simplest way is to
|
13
|
+
# create a pipe. A pipe is a stream where you read everything you write into it.
|
14
|
+
# Tanker streams however are pull streams, so there must be something that pulls
|
15
|
+
# from the Tanker stream and pushes onto the IO stream. We start a long-running
|
16
|
+
# thread for that which just loops.
|
17
|
+
#
|
18
|
+
# Because so much is happening in parallel, synchronization is not trivial.
|
19
|
+
# There's one mutex per stream, and we lock that same mutex for every critical
|
20
|
+
# section. Here are some important constraints that must be held:
|
21
|
+
# - Do not copy data to the Tanker buffer if tanker_stream_close has been
|
22
|
+
# called
|
23
|
+
# - Do not call tanker_stream_read_operation_finish if tanker_stream_close has
|
24
|
+
# been called
|
25
|
+
# - On the output stream, do not call tanker_stream_read on a closed/closing
|
26
|
+
# stream. Though it is ok to close the stream after the call, but before the
|
27
|
+
# future is resolved.
|
28
|
+
|
6
29
|
module Tanker
|
7
30
|
class Core
|
8
31
|
def encrypt_stream(stream, encryption_options = nil)
|
@@ -95,21 +118,6 @@ module Tanker
|
|
95
118
|
end
|
96
119
|
end
|
97
120
|
|
98
|
-
# IMPORTANT: about synchronization
|
99
|
-
# Because of a design flaw in the Tanker C streaming API, it is difficult to
|
100
|
-
# handle cancelation. When canceling a read (closing the stream), Tanker
|
101
|
-
# doesn't forward the cancelation request to the input stream (there's no
|
102
|
-
# callback for that), which means that the callback maybe writing to a buffer
|
103
|
-
# that's being freed. We worked around that by adding a mutex and locking it
|
104
|
-
# in both the output stream and the input stream.
|
105
|
-
# Things to be careful about:
|
106
|
-
# - Do not copy data to the Tanker buffer if tanker_stream_close has been
|
107
|
-
# called
|
108
|
-
# - Do not call tanker_stream_read_operation_finish if tanker_stream_close has
|
109
|
-
# been called
|
110
|
-
# - On the output stream, do not call tanker_stream_read on a closed/closing
|
111
|
-
# stream. Though it is ok to close the stream after the call, but before the
|
112
|
-
# future is resolved.
|
113
121
|
class IoToTankerStreamWrapper
|
114
122
|
attr_reader :error
|
115
123
|
attr_reader :read_method
|
@@ -174,14 +182,15 @@ module Tanker
|
|
174
182
|
def initialize(tanker_stream, substream)
|
175
183
|
@tanker_stream = tanker_stream
|
176
184
|
@substream = substream
|
185
|
+
end
|
186
|
+
|
187
|
+
def init_io
|
188
|
+
read, @write = IO.pipe
|
177
189
|
|
178
190
|
# The user will only read on the pipe, so we need something that reads
|
179
191
|
# from Tanker and writes to the pipe, it's this thread.
|
180
192
|
Thread.new { read_thread }
|
181
|
-
end
|
182
193
|
|
183
|
-
def init_io
|
184
|
-
read, @write = IO.pipe
|
185
194
|
read
|
186
195
|
end
|
187
196
|
|
data/lib/tanker/core/version.rb
CHANGED
data/vendor/{libctanker/linux64/tanker/lib/libctanker.so → tanker/darwin-x86_64/libctanker.dylib}
RENAMED
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tanker-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.3.beta.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tanker team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -165,8 +165,8 @@ files:
|
|
165
165
|
- lib/tanker/encryption_options.rb
|
166
166
|
- lib/tanker/error.rb
|
167
167
|
- lib/tanker/sharing_options.rb
|
168
|
-
- vendor/
|
169
|
-
- vendor/
|
168
|
+
- vendor/tanker/darwin-x86_64/libctanker.dylib
|
169
|
+
- vendor/tanker/linux-x86_64/libctanker.so
|
170
170
|
homepage: https://tanker.io
|
171
171
|
licenses:
|
172
172
|
- Apache-2.0
|
Binary file
|