packet-capture-sdk 1.0.0
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 +7 -0
- data/LICENSE +21 -0
- data/README.md +12 -0
- data/docs/API.md +23 -0
- data/docs/LICENSE.nlohmann-json +21 -0
- data/lib/packet_capture_sdk.rb +46 -0
- data/native/PacketCaptureSDKJsonSDK.dll +0 -0
- metadata +68 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 918a30c029072ad74463af9150cf13a6c039ed04a8361babac76b0fe09264071
|
|
4
|
+
data.tar.gz: 2da7769cd7439a1cc634854816f621d73c8ddbe3052f985233986c75c644ee40
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 8663e988c524ee54b61cf037dcb08a9da1d38af07a28b2f447090686961909057d2973c2cb78c266bb6f4956fe44d763af0f835a62e30b06a46f8f4ae5d43ae1
|
|
7
|
+
data.tar.gz: c266eb7afec0eb59095e1770781e2d79bba5f0223491ad565b5e65585848dfa8dc5eec4333f750ffaad26f8a7444b6585d639c98533b191c27985db01b373e34
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Titanfyre
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Packet-Capture-SDK Ruby SDK
|
|
2
|
+
|
|
3
|
+
`gem install packet-capture-sdk`
|
|
4
|
+
|
|
5
|
+
Windows x64 Ruby3.1+.
|
|
6
|
+
|
|
7
|
+
```ruby
|
|
8
|
+
require "packet_capture_sdk"
|
|
9
|
+
PacketCaptureSDKSDK::Client.open { |client| p client.call("status") }
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
[API and operation schema](docs/API.md). Matching driver installed separately.
|
data/docs/API.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Packet-Capture-SDK operation schema
|
|
2
|
+
|
|
3
|
+
The unchanged product C++ SDK is called directly. Operations: `check`, `parse_frame`, `authorize`, `adapters`, `start`, `stop`, `status`, `receive`, `send`, `close`. The dispatch source in `Bridge.cpp` lists exact argument keys and maps every operation to the original public SDK. Protocol structs retain their public-header field names, including case. UInt64 and Int64 fields are decimal strings; fixed arrays accept at most their capacity and omitted fields initialize to zero. Unknown fields and out-of-range values are rejected. SDK validators apply original protocol constraints.
|
|
4
|
+
|
|
5
|
+
Wire types and fields:
|
|
6
|
+
|
|
7
|
+
- `PC_ADAPTER`: id, luid, ifindex, running, mac, reserved, name
|
|
8
|
+
- `PC_ADAPTERS`: version, count, adapters
|
|
9
|
+
- `PC_SELECTION`: adapter, directions, reserved
|
|
10
|
+
- `PC_STATE`: version, size, active, authorized, selected, captured, overwritten, sent, send_failed, frequency, queued, pending_sends
|
|
11
|
+
- `PC_EVENT`: sequence, qpc, adapter, direction, length, original_length, reserved, data, padding
|
|
12
|
+
- `PC_BATCH`: version, count, state, events
|
|
13
|
+
- `PC_FRAME`: length, reserved, data, padding
|
|
14
|
+
- `TITAN_AUTHORIZATION_CHALLENGE`: magic, version, product, duration_seconds, nonce
|
|
15
|
+
- `TITAN_AUTHORIZATION_TOKEN`: permission, signature
|
|
16
|
+
|
|
17
|
+
Only explicit start/connect/policy calls start the corresponding operation. The C ABI session constructor is inert; one active session per product DLL. Always close. Capture receives are bounded when the native API accepts a timeout. SDK original licensing/trial checks remain unchanged. No driver is installed by packages.
|
|
18
|
+
|
|
19
|
+
Tests exercise synthetic wire inputs using the real production SDK validation/formatting helpers, rejected arguments, exact unsigned values and inert session lifecycle. No live capture, policy application, storage fault, traffic modification or driver activation is performed by these tests. Operational driver paths require a separate integration environment.
|
|
20
|
+
|
|
21
|
+
## Language client
|
|
22
|
+
|
|
23
|
+
The client calls the native SDK directly. Use the call method with an operation name and argument object. Calls are synchronous; only operations exposing a receive timeout are capped at100ms; use an application worker for responsive UI/event loops. Explicitly close the client after use. 64-bit identifiers and counters are decimal strings. Native errors expose their Windows code. Matching driver and licensing are separate requirements.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2013-2025 Niels Lohmann
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
require 'fiddle'
|
|
3
|
+
require 'thread'
|
|
4
|
+
module PacketCaptureSDKSDK
|
|
5
|
+
class NativeError < StandardError
|
|
6
|
+
attr_reader :code
|
|
7
|
+
def initialize(code,message);@code=code;super(message);end
|
|
8
|
+
end
|
|
9
|
+
class Client
|
|
10
|
+
def self.open(library_path: nil)
|
|
11
|
+
client=new(library_path: library_path)
|
|
12
|
+
return client unless block_given?
|
|
13
|
+
begin;yield client;ensure;client.close;end
|
|
14
|
+
end
|
|
15
|
+
def initialize(library_path: nil)
|
|
16
|
+
raise 'Windows x64 required' unless Fiddle::SIZEOF_VOIDP==8 && RUBY_PLATFORM.match?(/mingw|mswin/)
|
|
17
|
+
@library=Fiddle::Handle.new(library_path || ENV['PACKET_CAPTURE_SDK_SDK_NATIVE_PATH'] || File.expand_path('../native/PacketCaptureSDKJsonSDK.dll',__dir__))
|
|
18
|
+
@mutex=Mutex.new
|
|
19
|
+
@open=Fiddle::Function.new(@library['packet_capture_sdk_json_open'],[Fiddle::TYPE_VOIDP],Fiddle::TYPE_INT)
|
|
20
|
+
@close=Fiddle::Function.new(@library['packet_capture_sdk_json_close'],[Fiddle::TYPE_LONG_LONG],Fiddle::TYPE_INT)
|
|
21
|
+
@call=Fiddle::Function.new(@library['packet_capture_sdk_json_call'],[Fiddle::TYPE_LONG_LONG,Fiddle::TYPE_VOIDP,Fiddle::TYPE_INT],Fiddle::TYPE_VOIDP)
|
|
22
|
+
@free=Fiddle::Function.new(@library['packet_capture_sdk_json_free'],[Fiddle::TYPE_VOIDP],Fiddle::TYPE_VOID)
|
|
23
|
+
out=Fiddle::Pointer.malloc(8,Fiddle::RUBY_FREE);out[0,8]=[0].pack('Q<');code=@open.call(out);raise NativeError.new(code,'Cannot open SDK') if code!=0
|
|
24
|
+
@session=out[0,8].unpack1('Q<')
|
|
25
|
+
end
|
|
26
|
+
def call(operation,arguments={})
|
|
27
|
+
payload=JSON.generate({operation:operation,arguments:arguments}).encode('UTF-8')
|
|
28
|
+
raise ArgumentError,'Request exceeds 32 MiB' if payload.bytesize>32*1024*1024
|
|
29
|
+
@mutex.synchronize do
|
|
30
|
+
raise 'SDK is closed' if @session==0
|
|
31
|
+
pointer=@call.call(@session,payload,payload.bytesize);raise NoMemoryError,'Native response allocation failed' if pointer.null?
|
|
32
|
+
begin;response=JSON.parse(pointer.to_s);ensure;@free.call(pointer);end
|
|
33
|
+
raise NativeError.new(response['code'],response['message']) unless response['ok']
|
|
34
|
+
response['result']
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
def close
|
|
38
|
+
@mutex.synchronize do
|
|
39
|
+
if @session!=0
|
|
40
|
+
code=@close.call(@session);raise NativeError.new(code,'Native close failed') if code!=0
|
|
41
|
+
@session=0
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
Binary file
|
metadata
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: packet-capture-sdk
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- TitanCSA
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: fiddle
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '1.1'
|
|
19
|
+
- - "<"
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '2'
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
requirements:
|
|
26
|
+
- - ">="
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
version: '1.1'
|
|
29
|
+
- - "<"
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: '2'
|
|
32
|
+
description: Product native SDK operations through a UTF-8 JSON C ABI; driver installed
|
|
33
|
+
separately.
|
|
34
|
+
executables: []
|
|
35
|
+
extensions: []
|
|
36
|
+
extra_rdoc_files: []
|
|
37
|
+
files:
|
|
38
|
+
- LICENSE
|
|
39
|
+
- README.md
|
|
40
|
+
- docs/API.md
|
|
41
|
+
- docs/LICENSE.nlohmann-json
|
|
42
|
+
- lib/packet_capture_sdk.rb
|
|
43
|
+
- native/PacketCaptureSDKJsonSDK.dll
|
|
44
|
+
homepage: https://github.com/titanfyre/Packet-Capture-SDK
|
|
45
|
+
licenses:
|
|
46
|
+
- MIT
|
|
47
|
+
metadata:
|
|
48
|
+
source_code_uri: https://github.com/titanfyre/Packet-Capture-SDK
|
|
49
|
+
documentation_uri: https://github.com/titanfyre/Packet-Capture-SDK/tree/main/Packet-Capture-SDK-Ruby-rubygems/docs
|
|
50
|
+
allowed_push_host: https://rubygems.org
|
|
51
|
+
rdoc_options: []
|
|
52
|
+
require_paths:
|
|
53
|
+
- lib
|
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
55
|
+
requirements:
|
|
56
|
+
- - ">="
|
|
57
|
+
- !ruby/object:Gem::Version
|
|
58
|
+
version: '3.1'
|
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
|
+
requirements:
|
|
61
|
+
- - ">="
|
|
62
|
+
- !ruby/object:Gem::Version
|
|
63
|
+
version: '0'
|
|
64
|
+
requirements: []
|
|
65
|
+
rubygems_version: 4.0.20
|
|
66
|
+
specification_version: 4
|
|
67
|
+
summary: Windows x64 Packet-Capture-SDK direct SDK
|
|
68
|
+
test_files: []
|