protocol-quic 0.0.3 → 0.0.4
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
- checksums.yaml.gz.sig +0 -0
- data/ext/source/Ruby/Protocol/QUIC/Address.cpp +122 -0
- data/ext/source/{Protocol → Ruby/Protocol}/QUIC/Address.hpp +5 -5
- data/ext/source/Ruby/Protocol/QUIC/Client.cpp +161 -0
- data/ext/source/{Protocol → Ruby/Protocol}/QUIC/Client.hpp +3 -3
- data/ext/source/Ruby/Protocol/QUIC/Configuration.cpp +74 -0
- data/ext/source/{Protocol → Ruby/Protocol}/QUIC/Configuration.hpp +3 -3
- data/ext/source/Ruby/Protocol/QUIC/Connection.cpp +50 -0
- data/ext/source/{Protocol → Ruby/Protocol}/QUIC/Connection.hpp +4 -4
- data/ext/source/Ruby/Protocol/QUIC/Dispatcher.cpp +194 -0
- data/ext/source/{Protocol → Ruby/Protocol}/QUIC/Dispatcher.hpp +3 -3
- data/ext/source/Ruby/Protocol/QUIC/PacketHeader.cpp +59 -0
- data/ext/source/{Protocol → Ruby/Protocol}/QUIC/PacketHeader.hpp +4 -4
- data/ext/source/Ruby/Protocol/QUIC/Reference.hpp +35 -0
- data/ext/source/Ruby/Protocol/QUIC/Server.cpp +169 -0
- data/ext/source/{Protocol → Ruby/Protocol}/QUIC/Server.hpp +3 -3
- data/ext/source/Ruby/Protocol/QUIC/Socket.cpp +103 -0
- data/ext/source/{Protocol → Ruby/Protocol}/QUIC/Socket.hpp +4 -4
- data/ext/source/Ruby/Protocol/QUIC/Stream.cpp +100 -0
- data/ext/source/{Protocol → Ruby/Protocol}/QUIC/Stream.hpp +4 -4
- data/ext/source/Ruby/Protocol/QUIC/TLS/ClientContext.cpp +61 -0
- data/ext/source/{Protocol → Ruby/Protocol}/QUIC/TLS/ClientContext.hpp +3 -3
- data/ext/source/Ruby/Protocol/QUIC/TLS/Context.cpp +116 -0
- data/ext/source/{Protocol → Ruby/Protocol}/QUIC/TLS/Context.hpp +3 -3
- data/ext/source/Ruby/Protocol/QUIC/TLS/ServerContext.cpp +61 -0
- data/ext/source/{Protocol → Ruby/Protocol}/QUIC/TLS/ServerContext.hpp +3 -3
- data/ext/source/Ruby/Protocol/QUIC.cpp +36 -0
- data/ext/source/{Protocol → Ruby/Protocol}/QUIC.hpp +1 -1
- data/ext/teapot.rb +1 -1
- data/lib/protocol/quic/version.rb +1 -1
- data/lib/protocol/quic.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +28 -28
- metadata.gz.sig +0 -0
- data/ext/source/Protocol/QUIC/Address.cpp +0 -122
- data/ext/source/Protocol/QUIC/Client.cpp +0 -157
- data/ext/source/Protocol/QUIC/Configuration.cpp +0 -74
- data/ext/source/Protocol/QUIC/Connection.cpp +0 -50
- data/ext/source/Protocol/QUIC/Dispatcher.cpp +0 -190
- data/ext/source/Protocol/QUIC/PacketHeader.cpp +0 -59
- data/ext/source/Protocol/QUIC/Reference.hpp +0 -31
- data/ext/source/Protocol/QUIC/Server.cpp +0 -165
- data/ext/source/Protocol/QUIC/Socket.cpp +0 -103
- data/ext/source/Protocol/QUIC/Stream.cpp +0 -96
- data/ext/source/Protocol/QUIC/TLS/ClientContext.cpp +0 -61
- data/ext/source/Protocol/QUIC/TLS/Context.cpp +0 -116
- data/ext/source/Protocol/QUIC/TLS/ServerContext.cpp +0 -61
- data/ext/source/Protocol/QUIC.cpp +0 -36
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Context.cpp
|
|
3
|
+
// This file is part of the "Protocol::QUIC" project and released under the MIT License.
|
|
4
|
+
//
|
|
5
|
+
// Created by Samuel Williams on 27/4/2023.
|
|
6
|
+
// Copyright, 2023, by Samuel Williams. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#include "Context.hpp"
|
|
10
|
+
|
|
11
|
+
#include "ClientContext.hpp"
|
|
12
|
+
#include "ServerContext.hpp"
|
|
13
|
+
|
|
14
|
+
VALUE Ruby_Protocol_QUIC_TLS_Context = Qnil;
|
|
15
|
+
|
|
16
|
+
static void Ruby_Protocol_QUIC_TLS_Context_free(void *data) {
|
|
17
|
+
if (data) {
|
|
18
|
+
delete reinterpret_cast<::Protocol::QUIC::TLS::Context *>(data);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static size_t Ruby_Protocol_QUIC_TLS_Context_size(const void *data) {
|
|
23
|
+
return sizeof(::Protocol::QUIC::TLS::Context);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const rb_data_type_t Ruby_Protocol_QUIC_TLS_Context_type = {
|
|
27
|
+
.wrap_struct_name = "Protocol::QUIC::TLS::Context",
|
|
28
|
+
.function = {
|
|
29
|
+
.dmark = NULL,
|
|
30
|
+
.dfree = Ruby_Protocol_QUIC_TLS_Context_free,
|
|
31
|
+
.dsize = Ruby_Protocol_QUIC_TLS_Context_size,
|
|
32
|
+
},
|
|
33
|
+
.data = NULL,
|
|
34
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
::Protocol::QUIC::TLS::Context * Ruby_Protocol_QUIC_TLS_Context_get(VALUE self)
|
|
38
|
+
{
|
|
39
|
+
::Protocol::QUIC::TLS::Context *tls_context;
|
|
40
|
+
|
|
41
|
+
TypedData_Get_Struct(self, ::Protocol::QUIC::TLS::Context, &Ruby_Protocol_QUIC_TLS_Context_type, tls_context);
|
|
42
|
+
|
|
43
|
+
return tls_context;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static VALUE Ruby_Protocol_QUIC_TLS_Context_allocate(VALUE klass) {
|
|
47
|
+
return TypedData_Wrap_Struct(klass, &Ruby_Protocol_QUIC_TLS_Context_type, NULL);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static VALUE Ruby_Protocol_QUIC_TLS_Context_initialize(VALUE self) {
|
|
51
|
+
DATA_PTR(self) = new ::Protocol::QUIC::TLS::Context();
|
|
52
|
+
|
|
53
|
+
return self;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static VALUE Ruby_Protocol_QUIC_TLS_Context_add_protocol(VALUE self, VALUE name) {
|
|
57
|
+
StringValue(name);
|
|
58
|
+
|
|
59
|
+
::Protocol::QUIC::TLS::Context *tls_context;
|
|
60
|
+
TypedData_Get_Struct(self, ::Protocol::QUIC::TLS::Context, &Ruby_Protocol_QUIC_TLS_Context_type, tls_context);
|
|
61
|
+
|
|
62
|
+
tls_context->add_protocol(
|
|
63
|
+
std::string(RSTRING_PTR(name), RSTRING_LEN(name))
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
return self;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static VALUE Ruby_Protocol_QUIC_TLS_Context_load_certificate_file(VALUE self, VALUE path) {
|
|
70
|
+
StringValue(path);
|
|
71
|
+
|
|
72
|
+
auto tls_context = Ruby_Protocol_QUIC_TLS_Context_get(self);
|
|
73
|
+
tls_context->load_certificate_file(RSTRING_PTR(path));
|
|
74
|
+
|
|
75
|
+
return self;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
static VALUE Ruby_Protocol_QUIC_TLS_Context_load_private_key_file(VALUE self, VALUE path) {
|
|
79
|
+
StringValue(path);
|
|
80
|
+
|
|
81
|
+
auto tls_context = Ruby_Protocol_QUIC_TLS_Context_get(self);
|
|
82
|
+
tls_context->load_private_key_file(RSTRING_PTR(path));
|
|
83
|
+
|
|
84
|
+
return self;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static VALUE Ruby_Protocol_QUIC_TLS_Context_protocols(VALUE self) {
|
|
88
|
+
::Protocol::QUIC::TLS::Context *tls_context;
|
|
89
|
+
TypedData_Get_Struct(self, ::Protocol::QUIC::TLS::Context, &Ruby_Protocol_QUIC_TLS_Context_type, tls_context);
|
|
90
|
+
|
|
91
|
+
VALUE protocols = rb_ary_new();
|
|
92
|
+
|
|
93
|
+
for (auto & protocol : tls_context->protocols()) {
|
|
94
|
+
rb_ary_push(protocols, rb_str_new(protocol.data(), protocol.size()));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return protocols;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
void Init_Ruby_Protocol_QUIC_TLS_Context(VALUE Protocol_QUIC) {
|
|
101
|
+
VALUE Protocol_QUIC_TLS = rb_define_module_under(Protocol_QUIC, "TLS");
|
|
102
|
+
|
|
103
|
+
Ruby_Protocol_QUIC_TLS_Context =
|
|
104
|
+
rb_define_class_under(Protocol_QUIC_TLS, "Context", rb_cObject);
|
|
105
|
+
|
|
106
|
+
rb_define_alloc_func(Ruby_Protocol_QUIC_TLS_Context, Ruby_Protocol_QUIC_TLS_Context_allocate);
|
|
107
|
+
rb_define_method(Ruby_Protocol_QUIC_TLS_Context, "initialize", Ruby_Protocol_QUIC_TLS_Context_initialize, 0);
|
|
108
|
+
|
|
109
|
+
rb_define_method(Ruby_Protocol_QUIC_TLS_Context, "add_protocol", Ruby_Protocol_QUIC_TLS_Context_add_protocol, 1);
|
|
110
|
+
rb_define_method(Ruby_Protocol_QUIC_TLS_Context, "load_certificate_file", Ruby_Protocol_QUIC_TLS_Context_load_certificate_file, 1);
|
|
111
|
+
rb_define_method(Ruby_Protocol_QUIC_TLS_Context, "load_private_key_file", Ruby_Protocol_QUIC_TLS_Context_load_private_key_file, 1);
|
|
112
|
+
rb_define_method(Ruby_Protocol_QUIC_TLS_Context, "protocols", Ruby_Protocol_QUIC_TLS_Context_protocols, 0);
|
|
113
|
+
|
|
114
|
+
Init_Ruby_Protocol_QUIC_TLS_ClientContext(Protocol_QUIC_TLS);
|
|
115
|
+
Init_Ruby_Protocol_QUIC_TLS_ServerContext(Protocol_QUIC_TLS);
|
|
116
|
+
}
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
extern "C" {
|
|
17
17
|
#endif
|
|
18
18
|
|
|
19
|
-
extern VALUE
|
|
19
|
+
extern VALUE Ruby_Protocol_QUIC_TLS_Context;
|
|
20
20
|
|
|
21
|
-
extern const rb_data_type_t
|
|
21
|
+
extern const rb_data_type_t Ruby_Protocol_QUIC_TLS_Context_type;
|
|
22
22
|
|
|
23
|
-
void
|
|
23
|
+
void Init_Ruby_Protocol_QUIC_TLS_Context(VALUE Protocol_QUIC);
|
|
24
24
|
|
|
25
25
|
#ifdef __cplusplus
|
|
26
26
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
//
|
|
2
|
+
// ServerContext.cpp
|
|
3
|
+
// This file is part of the "Protocol::QUIC" project and released under the MIT License.
|
|
4
|
+
//
|
|
5
|
+
// Created by Samuel Williams on 27/4/2023.
|
|
6
|
+
// Copyright, 2023, by Samuel Williams. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#include "ServerContext.hpp"
|
|
10
|
+
#include "Context.hpp"
|
|
11
|
+
|
|
12
|
+
VALUE Ruby_Protocol_QUIC_TLS_ServerContext = Qnil;
|
|
13
|
+
|
|
14
|
+
static void Ruby_Protocol_QUIC_TLS_ServerContext_free(void *data) {
|
|
15
|
+
if (data) {
|
|
16
|
+
delete reinterpret_cast<::Protocol::QUIC::TLS::ServerContext *>(data);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static size_t Ruby_Protocol_QUIC_TLS_ServerContext_size(const void *data) {
|
|
21
|
+
return sizeof(::Protocol::QUIC::TLS::ServerContext);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static const rb_data_type_t Ruby_Protocol_QUIC_TLS_ServerContext_type = {
|
|
25
|
+
.wrap_struct_name = "Protocol::QUIC::TLS::ServerContext",
|
|
26
|
+
.function = {
|
|
27
|
+
.dmark = NULL,
|
|
28
|
+
.dfree = Ruby_Protocol_QUIC_TLS_ServerContext_free,
|
|
29
|
+
.dsize = Ruby_Protocol_QUIC_TLS_ServerContext_size,
|
|
30
|
+
},
|
|
31
|
+
.parent = &Ruby_Protocol_QUIC_TLS_Context_type,
|
|
32
|
+
.data = NULL,
|
|
33
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
::Protocol::QUIC::TLS::ServerContext * Ruby_Protocol_QUIC_TLS_ServerContext_get(VALUE self)
|
|
37
|
+
{
|
|
38
|
+
::Protocol::QUIC::TLS::ServerContext *data;
|
|
39
|
+
|
|
40
|
+
TypedData_Get_Struct(self, ::Protocol::QUIC::TLS::ServerContext, &Ruby_Protocol_QUIC_TLS_ServerContext_type, data);
|
|
41
|
+
|
|
42
|
+
return data;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static VALUE Ruby_Protocol_QUIC_TLS_ServerContext_allocate(VALUE klass) {
|
|
46
|
+
return TypedData_Wrap_Struct(klass, &Ruby_Protocol_QUIC_TLS_ServerContext_type, NULL);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static VALUE Ruby_Protocol_QUIC_TLS_ServerContext_initialize(VALUE self) {
|
|
50
|
+
DATA_PTR(self) = new ::Protocol::QUIC::TLS::ServerContext();
|
|
51
|
+
|
|
52
|
+
return self;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
void Init_Ruby_Protocol_QUIC_TLS_ServerContext(VALUE Protocol_QUIC_TLS) {
|
|
56
|
+
Ruby_Protocol_QUIC_TLS_ServerContext =
|
|
57
|
+
rb_define_class_under(Protocol_QUIC_TLS, "ServerContext", Ruby_Protocol_QUIC_TLS_Context);
|
|
58
|
+
|
|
59
|
+
rb_define_alloc_func(Ruby_Protocol_QUIC_TLS_ServerContext, Ruby_Protocol_QUIC_TLS_ServerContext_allocate);
|
|
60
|
+
rb_define_method(Ruby_Protocol_QUIC_TLS_ServerContext, "initialize", Ruby_Protocol_QUIC_TLS_ServerContext_initialize, 0);
|
|
61
|
+
}
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
extern "C" {
|
|
17
17
|
#endif
|
|
18
18
|
|
|
19
|
-
extern VALUE
|
|
19
|
+
extern VALUE Ruby_Protocol_QUIC_TLS_ServerContext;
|
|
20
20
|
|
|
21
|
-
void
|
|
21
|
+
void Init_Ruby_Protocol_QUIC_TLS_ServerContext(VALUE Protocol_QUIC_TLS);
|
|
22
22
|
|
|
23
|
-
Protocol::QUIC::TLS::ServerContext *
|
|
23
|
+
::Protocol::QUIC::TLS::ServerContext * Ruby_Protocol_QUIC_TLS_ServerContext_get(VALUE self);
|
|
24
24
|
|
|
25
25
|
#ifdef __cplusplus
|
|
26
26
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#include "QUIC.hpp"
|
|
2
|
+
|
|
3
|
+
#include "QUIC/Connection.hpp"
|
|
4
|
+
#include "QUIC/TLS/Context.hpp"
|
|
5
|
+
|
|
6
|
+
#include "QUIC/Address.hpp"
|
|
7
|
+
#include "QUIC/Dispatcher.hpp"
|
|
8
|
+
#include "QUIC/Configuration.hpp"
|
|
9
|
+
#include "QUIC/PacketHeader.hpp"
|
|
10
|
+
#include "QUIC/Socket.hpp"
|
|
11
|
+
|
|
12
|
+
#include "QUIC/Server.hpp"
|
|
13
|
+
#include "QUIC/Client.hpp"
|
|
14
|
+
#include "QUIC/Stream.hpp"
|
|
15
|
+
|
|
16
|
+
VALUE Protocol_QUIC = Qnil;
|
|
17
|
+
|
|
18
|
+
void Init_Ruby_Protocol_QUIC(void)
|
|
19
|
+
{
|
|
20
|
+
VALUE Protocol = rb_define_module("Protocol");
|
|
21
|
+
Protocol_QUIC = rb_define_module_under(Protocol, "QUIC");
|
|
22
|
+
|
|
23
|
+
Init_Ruby_Protocol_QUIC_TLS_Context(Protocol_QUIC);
|
|
24
|
+
|
|
25
|
+
Init_Ruby_Protocol_QUIC_Address(Protocol_QUIC);
|
|
26
|
+
Init_Ruby_Protocol_QUIC_Dispatcher(Protocol_QUIC);
|
|
27
|
+
Init_Ruby_Protocol_QUIC_Configuration(Protocol_QUIC);
|
|
28
|
+
Init_Ruby_Protocol_QUIC_PacketHeader(Protocol_QUIC);
|
|
29
|
+
Init_Ruby_Protocol_QUIC_Socket(Protocol_QUIC);
|
|
30
|
+
|
|
31
|
+
Init_Ruby_Protocol_QUIC_Connection(Protocol_QUIC);
|
|
32
|
+
Init_Ruby_Protocol_QUIC_Server(Protocol_QUIC);
|
|
33
|
+
Init_Ruby_Protocol_QUIC_Client(Protocol_QUIC);
|
|
34
|
+
|
|
35
|
+
Init_Ruby_Protocol_QUIC_Stream(Protocol_QUIC);
|
|
36
|
+
}
|
data/ext/teapot.rb
CHANGED
|
@@ -22,7 +22,7 @@ define_target "ruby-protocol-quic" do |target|
|
|
|
22
22
|
target.provides "Ruby/Protocol/QUIC" do
|
|
23
23
|
source_root = target.package.path + "source"
|
|
24
24
|
|
|
25
|
-
library_path = build dynamic_library: "
|
|
25
|
+
library_path = build dynamic_library: "Ruby_Protocol_QUIC", source_files: source_root.glob("**/*.{c,cpp}")
|
|
26
26
|
|
|
27
27
|
copy source: [library_path], prefix: environment[:ruby_install_path]
|
|
28
28
|
|
data/lib/protocol/quic.rb
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: protocol-quic
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
@@ -73,33 +73,33 @@ extra_rdoc_files: []
|
|
|
73
73
|
files:
|
|
74
74
|
- ext/rakefile.rb
|
|
75
75
|
- ext/ruby-protocol-quic-lock.yml
|
|
76
|
-
- ext/source/Protocol/QUIC.cpp
|
|
77
|
-
- ext/source/Protocol/QUIC.hpp
|
|
78
|
-
- ext/source/Protocol/QUIC/Address.cpp
|
|
79
|
-
- ext/source/Protocol/QUIC/Address.hpp
|
|
80
|
-
- ext/source/Protocol/QUIC/Client.cpp
|
|
81
|
-
- ext/source/Protocol/QUIC/Client.hpp
|
|
82
|
-
- ext/source/Protocol/QUIC/Configuration.cpp
|
|
83
|
-
- ext/source/Protocol/QUIC/Configuration.hpp
|
|
84
|
-
- ext/source/Protocol/QUIC/Connection.cpp
|
|
85
|
-
- ext/source/Protocol/QUIC/Connection.hpp
|
|
86
|
-
- ext/source/Protocol/QUIC/Dispatcher.cpp
|
|
87
|
-
- ext/source/Protocol/QUIC/Dispatcher.hpp
|
|
88
|
-
- ext/source/Protocol/QUIC/PacketHeader.cpp
|
|
89
|
-
- ext/source/Protocol/QUIC/PacketHeader.hpp
|
|
90
|
-
- ext/source/Protocol/QUIC/Reference.hpp
|
|
91
|
-
- ext/source/Protocol/QUIC/Server.cpp
|
|
92
|
-
- ext/source/Protocol/QUIC/Server.hpp
|
|
93
|
-
- ext/source/Protocol/QUIC/Socket.cpp
|
|
94
|
-
- ext/source/Protocol/QUIC/Socket.hpp
|
|
95
|
-
- ext/source/Protocol/QUIC/Stream.cpp
|
|
96
|
-
- ext/source/Protocol/QUIC/Stream.hpp
|
|
97
|
-
- ext/source/Protocol/QUIC/TLS/ClientContext.cpp
|
|
98
|
-
- ext/source/Protocol/QUIC/TLS/ClientContext.hpp
|
|
99
|
-
- ext/source/Protocol/QUIC/TLS/Context.cpp
|
|
100
|
-
- ext/source/Protocol/QUIC/TLS/Context.hpp
|
|
101
|
-
- ext/source/Protocol/QUIC/TLS/ServerContext.cpp
|
|
102
|
-
- ext/source/Protocol/QUIC/TLS/ServerContext.hpp
|
|
76
|
+
- ext/source/Ruby/Protocol/QUIC.cpp
|
|
77
|
+
- ext/source/Ruby/Protocol/QUIC.hpp
|
|
78
|
+
- ext/source/Ruby/Protocol/QUIC/Address.cpp
|
|
79
|
+
- ext/source/Ruby/Protocol/QUIC/Address.hpp
|
|
80
|
+
- ext/source/Ruby/Protocol/QUIC/Client.cpp
|
|
81
|
+
- ext/source/Ruby/Protocol/QUIC/Client.hpp
|
|
82
|
+
- ext/source/Ruby/Protocol/QUIC/Configuration.cpp
|
|
83
|
+
- ext/source/Ruby/Protocol/QUIC/Configuration.hpp
|
|
84
|
+
- ext/source/Ruby/Protocol/QUIC/Connection.cpp
|
|
85
|
+
- ext/source/Ruby/Protocol/QUIC/Connection.hpp
|
|
86
|
+
- ext/source/Ruby/Protocol/QUIC/Dispatcher.cpp
|
|
87
|
+
- ext/source/Ruby/Protocol/QUIC/Dispatcher.hpp
|
|
88
|
+
- ext/source/Ruby/Protocol/QUIC/PacketHeader.cpp
|
|
89
|
+
- ext/source/Ruby/Protocol/QUIC/PacketHeader.hpp
|
|
90
|
+
- ext/source/Ruby/Protocol/QUIC/Reference.hpp
|
|
91
|
+
- ext/source/Ruby/Protocol/QUIC/Server.cpp
|
|
92
|
+
- ext/source/Ruby/Protocol/QUIC/Server.hpp
|
|
93
|
+
- ext/source/Ruby/Protocol/QUIC/Socket.cpp
|
|
94
|
+
- ext/source/Ruby/Protocol/QUIC/Socket.hpp
|
|
95
|
+
- ext/source/Ruby/Protocol/QUIC/Stream.cpp
|
|
96
|
+
- ext/source/Ruby/Protocol/QUIC/Stream.hpp
|
|
97
|
+
- ext/source/Ruby/Protocol/QUIC/TLS/ClientContext.cpp
|
|
98
|
+
- ext/source/Ruby/Protocol/QUIC/TLS/ClientContext.hpp
|
|
99
|
+
- ext/source/Ruby/Protocol/QUIC/TLS/Context.cpp
|
|
100
|
+
- ext/source/Ruby/Protocol/QUIC/TLS/Context.hpp
|
|
101
|
+
- ext/source/Ruby/Protocol/QUIC/TLS/ServerContext.cpp
|
|
102
|
+
- ext/source/Ruby/Protocol/QUIC/TLS/ServerContext.hpp
|
|
103
103
|
- ext/teapot.rb
|
|
104
104
|
- lib/protocol/quic.rb
|
|
105
105
|
- lib/protocol/quic/version.rb
|
metadata.gz.sig
CHANGED
|
Binary file
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Address.cpp
|
|
3
|
-
// This file is part of the "Protocol::QUIC" project and released under the MIT License.
|
|
4
|
-
//
|
|
5
|
-
// Created by Samuel Williams on 27/4/2023.
|
|
6
|
-
// Copyright, 2023, by Samuel Williams. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#include "Address.hpp"
|
|
10
|
-
#include "ruby/backward/cxxanyargs.hpp"
|
|
11
|
-
#include "ruby/internal/intern/object.h"
|
|
12
|
-
|
|
13
|
-
VALUE Protocol_QUIC_Address = Qnil;
|
|
14
|
-
|
|
15
|
-
static void Protocol_QUIC_Address_free(void *data) {
|
|
16
|
-
if (data) {
|
|
17
|
-
delete reinterpret_cast<Protocol::QUIC::Address *>(data);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
static size_t Protocol_QUIC_Address_size(const void *data) {
|
|
22
|
-
return sizeof(Protocol::QUIC::Address);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const rb_data_type_t Protocol_QUIC_Address_type = {
|
|
26
|
-
.wrap_struct_name = "Protocol::QUIC::Address",
|
|
27
|
-
.function = {
|
|
28
|
-
.dmark = NULL,
|
|
29
|
-
.dfree = Protocol_QUIC_Address_free,
|
|
30
|
-
.dsize = Protocol_QUIC_Address_size,
|
|
31
|
-
},
|
|
32
|
-
.data = NULL,
|
|
33
|
-
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
Protocol::QUIC::Address * Protocol_QUIC_Address_get(VALUE self)
|
|
37
|
-
{
|
|
38
|
-
Protocol::QUIC::Address *address;
|
|
39
|
-
|
|
40
|
-
TypedData_Get_Struct(self, Protocol::QUIC::Address, &Protocol_QUIC_Address_type, address);
|
|
41
|
-
|
|
42
|
-
return address;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
VALUE Protocol_QUIC_Address_allocate(VALUE klass) {
|
|
46
|
-
return TypedData_Wrap_Struct(klass, &Protocol_QUIC_Address_type, NULL);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
static VALUE Protocol_QUIC_Address_initialize(VALUE self) {
|
|
50
|
-
DATA_PTR(self) = new Protocol::QUIC::Address();
|
|
51
|
-
|
|
52
|
-
return self;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
static VALUE Protocol_QUIC_Address_inspect(VALUE self) {
|
|
56
|
-
auto address = Protocol_QUIC_Address_get(self);
|
|
57
|
-
auto string = address->to_string();
|
|
58
|
-
|
|
59
|
-
VALUE class_name = rb_inspect(rb_class_of(self));
|
|
60
|
-
|
|
61
|
-
return rb_sprintf("<%" PRIsVALUE ":%p '%s'>", class_name, (void*)self, string.c_str());
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
static VALUE Protocol_QUIC_Address_family(VALUE self) {
|
|
65
|
-
Protocol::QUIC::Address *address = Protocol_QUIC_Address_get(self);
|
|
66
|
-
|
|
67
|
-
return RB_INT2NUM(address->family());
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
static VALUE Protocol_QUIC_Address_data(VALUE self) {
|
|
71
|
-
Protocol::QUIC::Address *address = Protocol_QUIC_Address_get(self);
|
|
72
|
-
|
|
73
|
-
return rb_str_new((const char *)&address->data.sa, address->length);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
VALUE Protocol_QUIC_Address_wrap(VALUE klass, const Protocol::QUIC::Address & address)
|
|
77
|
-
{
|
|
78
|
-
VALUE self = Protocol_QUIC_Address_allocate(klass);
|
|
79
|
-
Protocol_QUIC_Address_initialize(self);
|
|
80
|
-
|
|
81
|
-
Protocol::QUIC::Address *data = Protocol_QUIC_Address_get(self);
|
|
82
|
-
|
|
83
|
-
*data = address;
|
|
84
|
-
|
|
85
|
-
return self;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
VALUE Protocol_QUIC_Address_s_resolve(VALUE klass, VALUE host, VALUE service, VALUE family, VALUE type, VALUE flags)
|
|
89
|
-
{
|
|
90
|
-
StringValue(host);
|
|
91
|
-
StringValue(service);
|
|
92
|
-
|
|
93
|
-
auto addresses = Protocol::QUIC::Address::resolve(
|
|
94
|
-
std::string_view(RSTRING_PTR(host), RSTRING_LEN(host)),
|
|
95
|
-
std::string_view(RSTRING_PTR(service), RSTRING_LEN(service)),
|
|
96
|
-
RB_NUM2INT(family),
|
|
97
|
-
RB_NUM2INT(type),
|
|
98
|
-
RB_NUM2INT(flags)
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
VALUE result = rb_ary_new_capa(addresses.size());
|
|
102
|
-
|
|
103
|
-
for (auto & address : addresses) {
|
|
104
|
-
rb_ary_push(result, Protocol_QUIC_Address_wrap(klass, address));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return result;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
void Init_Protocol_QUIC_Address(VALUE Protocol_QUIC) {
|
|
111
|
-
Protocol_QUIC_Address =
|
|
112
|
-
rb_define_class_under(Protocol_QUIC, "Address", rb_cObject);
|
|
113
|
-
|
|
114
|
-
rb_define_singleton_method(Protocol_QUIC_Address, "resolve", Protocol_QUIC_Address_s_resolve, 5);
|
|
115
|
-
|
|
116
|
-
rb_define_alloc_func(Protocol_QUIC_Address, Protocol_QUIC_Address_allocate);
|
|
117
|
-
rb_define_method(Protocol_QUIC_Address, "initialize", Protocol_QUIC_Address_initialize, 0);
|
|
118
|
-
rb_define_method(Protocol_QUIC_Address, "inspect", Protocol_QUIC_Address_inspect, 0);
|
|
119
|
-
|
|
120
|
-
rb_define_method(Protocol_QUIC_Address, "family", Protocol_QUIC_Address_family, 0);
|
|
121
|
-
rb_define_method(Protocol_QUIC_Address, "data", Protocol_QUIC_Address_data, 0);
|
|
122
|
-
}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
#include "Client.hpp"
|
|
3
|
-
|
|
4
|
-
#include "Configuration.hpp"
|
|
5
|
-
#include "TLS/ClientContext.hpp"
|
|
6
|
-
#include "Socket.hpp"
|
|
7
|
-
#include "Address.hpp"
|
|
8
|
-
#include "Stream.hpp"
|
|
9
|
-
|
|
10
|
-
#include <unordered_map>
|
|
11
|
-
|
|
12
|
-
VALUE Protocol_QUIC_Client = Qnil;
|
|
13
|
-
|
|
14
|
-
class RubyClient : public Protocol::QUIC::Client {
|
|
15
|
-
public:
|
|
16
|
-
VALUE self;
|
|
17
|
-
|
|
18
|
-
private:
|
|
19
|
-
VALUE _configuration;
|
|
20
|
-
VALUE _tls_context;
|
|
21
|
-
VALUE _socket;
|
|
22
|
-
VALUE _remote_address;
|
|
23
|
-
std::unordered_map<Protocol::QUIC::StreamID, VALUE> _ruby_streams;
|
|
24
|
-
|
|
25
|
-
public:
|
|
26
|
-
RubyClient(VALUE self, VALUE configuration, VALUE tls_context, VALUE socket, VALUE remote_address, VALUE chosen_version) : Protocol::QUIC::Client(*Protocol_QUIC_Configuration_get(configuration), *Protocol_QUIC_TLS_ClientContext_get(tls_context), *Protocol_QUIC_Socket_get(socket), *Protocol_QUIC_Address_get(remote_address), RB_NUM2UINT(chosen_version)), self(self), _configuration(configuration), _tls_context(tls_context), _socket(socket), _remote_address(remote_address) {}
|
|
27
|
-
virtual ~RubyClient() {}
|
|
28
|
-
|
|
29
|
-
void handshake_completed() override
|
|
30
|
-
{
|
|
31
|
-
rb_funcall(self, rb_intern("handshake_completed"), 0);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
Protocol::QUIC::Stream * create_stream(Protocol::QUIC::StreamID stream_id) override
|
|
35
|
-
{
|
|
36
|
-
VALUE stream = rb_funcall(self, rb_intern("create_stream"), 1, RB_LL2NUM(stream_id));
|
|
37
|
-
_ruby_streams[stream_id] = stream;
|
|
38
|
-
|
|
39
|
-
return Protocol_QUIC_Stream_get(stream);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
void disconnect() override
|
|
43
|
-
{
|
|
44
|
-
Protocol::QUIC::Client::disconnect();
|
|
45
|
-
_ruby_streams.clear();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
void stream_close(Protocol::QUIC::Stream * stream, std::int32_t flags, std::uint64_t error_code) override
|
|
49
|
-
{
|
|
50
|
-
auto stream_id = stream->stream_id();
|
|
51
|
-
Protocol::QUIC::Client::stream_close(stream, flags, error_code);
|
|
52
|
-
_ruby_streams.erase(stream_id);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
void stream_reset(Protocol::QUIC::Stream * stream, std::size_t final_size, std::uint64_t error_code) override
|
|
56
|
-
{
|
|
57
|
-
auto stream_id = stream->stream_id();
|
|
58
|
-
Protocol::QUIC::Client::stream_reset(stream, final_size, error_code);
|
|
59
|
-
_ruby_streams.erase(stream_id);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
void mark() {
|
|
63
|
-
rb_gc_mark_movable(self);
|
|
64
|
-
rb_gc_mark_movable(_configuration);
|
|
65
|
-
rb_gc_mark_movable(_tls_context);
|
|
66
|
-
rb_gc_mark_movable(_socket);
|
|
67
|
-
rb_gc_mark_movable(_remote_address);
|
|
68
|
-
|
|
69
|
-
for (auto & [stream_id, ruby_stream] : _ruby_streams) {
|
|
70
|
-
rb_gc_mark_movable(ruby_stream);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
void compact() {
|
|
75
|
-
self = rb_gc_location(self);
|
|
76
|
-
_configuration = rb_gc_location(_configuration);
|
|
77
|
-
_tls_context = rb_gc_location(_tls_context);
|
|
78
|
-
_socket = rb_gc_location(_socket);
|
|
79
|
-
_remote_address = rb_gc_location(_remote_address);
|
|
80
|
-
|
|
81
|
-
for (auto & [stream_id, ruby_stream] : _ruby_streams) {
|
|
82
|
-
ruby_stream = rb_gc_location(ruby_stream);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
static void Protocol_QUIC_Client_mark(void *data)
|
|
88
|
-
{
|
|
89
|
-
if (data) {
|
|
90
|
-
reinterpret_cast<RubyClient *>(data)->mark();
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
static void Protocol_QUIC_Client_compact(void *data)
|
|
95
|
-
{
|
|
96
|
-
if (data) {
|
|
97
|
-
reinterpret_cast<RubyClient *>(data)->compact();
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
static void Protocol_QUIC_Client_free(void *data)
|
|
102
|
-
{
|
|
103
|
-
if (data) {
|
|
104
|
-
delete reinterpret_cast<Protocol::QUIC::Client *>(data);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
static size_t Protocol_QUIC_Client_size(const void *data) {
|
|
109
|
-
return sizeof(RubyClient);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
static const rb_data_type_t Protocol_QUIC_Client_type = {
|
|
113
|
-
.wrap_struct_name = "Protocol::QUIC::Client",
|
|
114
|
-
.function = {
|
|
115
|
-
.dmark = Protocol_QUIC_Client_mark,
|
|
116
|
-
.dfree = Protocol_QUIC_Client_free,
|
|
117
|
-
.dsize = Protocol_QUIC_Client_size,
|
|
118
|
-
.dcompact = Protocol_QUIC_Client_compact,
|
|
119
|
-
},
|
|
120
|
-
.data = NULL,
|
|
121
|
-
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
Protocol::QUIC::Client * Protocol_QUIC_Client_get(VALUE self)
|
|
125
|
-
{
|
|
126
|
-
Protocol::QUIC::Client *configuration;
|
|
127
|
-
TypedData_Get_Struct(self, Protocol::QUIC::Client, &Protocol_QUIC_Client_type, configuration);
|
|
128
|
-
return configuration;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
static VALUE Protocol_QUIC_Client_allocate(VALUE klass) {
|
|
132
|
-
return TypedData_Wrap_Struct(klass, &Protocol_QUIC_Client_type, NULL);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
static VALUE Protocol_QUIC_Client_initialize(VALUE self, VALUE configuration, VALUE tls_context, VALUE socket, VALUE remote_address, VALUE chosen_version) {
|
|
136
|
-
Protocol::QUIC::Client *client = new RubyClient(self, configuration, tls_context, socket, remote_address, chosen_version);
|
|
137
|
-
DATA_PTR(self) = client;
|
|
138
|
-
return self;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
static VALUE Protocol_QUIC_Client_connect(VALUE self) {
|
|
142
|
-
Protocol::QUIC::Client *client = Protocol_QUIC_Client_get(self);
|
|
143
|
-
|
|
144
|
-
client->connect();
|
|
145
|
-
|
|
146
|
-
return Qnil;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
void Init_Protocol_QUIC_Client(VALUE Protocol_QUIC) {
|
|
150
|
-
Protocol_QUIC_Client =
|
|
151
|
-
rb_define_class_under(Protocol_QUIC, "Client", rb_cObject);
|
|
152
|
-
|
|
153
|
-
rb_define_alloc_func(Protocol_QUIC_Client, Protocol_QUIC_Client_allocate);
|
|
154
|
-
rb_define_method(Protocol_QUIC_Client, "initialize", Protocol_QUIC_Client_initialize, 5);
|
|
155
|
-
|
|
156
|
-
rb_define_method(Protocol_QUIC_Client, "connect", Protocol_QUIC_Client_connect, 0);
|
|
157
|
-
}
|