protocol-quic 0.0.3 → 0.0.5
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 +4 -2
- data/ext/ruby-protocol-quic-lock.yml +2 -2
- 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 +118 -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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cebc4e910242d2f8a4b5eda4d7b44fcbbe3c6ae3220003d8d5886d3fce785a5c
|
|
4
|
+
data.tar.gz: a3ae388d1abd5bf2736fe9bd0ace296ce30ca984b2097c535d78bc2fb8417b86
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 15f4ba97d0b2df5a56502f20300f6149f879be26b743eba97b7b3d8fd709cacba7d30b1a032bd312722c64614db156853bedd7e0dc13e9113c870ed8d719275c
|
|
7
|
+
data.tar.gz: 4c64b7549057a6bd15eb383c1ba2efbf391701aa22f35ed62c412ad630b9642b570b4b31e552daa7606b9bd5e592f090e8e17fc2d538630214e3ca67c74c0a40
|
checksums.yaml.gz.sig
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
vP��
|
|
2
|
+
��/���f��(��r�J��|�cL��u'W
|
|
3
|
+
W������U�z������(���B��H=b�ѕ� E�� L�������X��kx�ǂmE��
|
|
4
|
+
d��Z�>u����N��B�g�S�\m��;�=�E��w�>�������j��Ǥ����Ε${Fh�p?KSE�0pQ;��g���$������;� ��J.Ime; Q v�C��*���R���_��EI��-V:�7<mU�Hp9}L��
|
|
@@ -9,10 +9,10 @@ build-cmake:
|
|
|
9
9
|
:commit: 6558fdad5bbb475f0fa5584ff773de8f12ff232e
|
|
10
10
|
:branch: master
|
|
11
11
|
scheduler-ruby:
|
|
12
|
-
:commit:
|
|
12
|
+
:commit: 94e524e64912081aaa5a8cb54bad7ad73f01a51a
|
|
13
13
|
:branch: main
|
|
14
14
|
protocol-quic:
|
|
15
|
-
:commit:
|
|
15
|
+
:commit: 1328f66a91ba7b3e544304dde8ba7bc93d3462ec
|
|
16
16
|
:branch: main
|
|
17
17
|
ruby:
|
|
18
18
|
:commit: 685cdd5a421dae7749f368d08add9aa9709ad043
|
|
@@ -0,0 +1,122 @@
|
|
|
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 Ruby_Protocol_QUIC_Address = Qnil;
|
|
14
|
+
|
|
15
|
+
static void Ruby_Protocol_QUIC_Address_free(void *data) {
|
|
16
|
+
if (data) {
|
|
17
|
+
delete reinterpret_cast<::Protocol::QUIC::Address *>(data);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static size_t Ruby_Protocol_QUIC_Address_size(const void *data) {
|
|
22
|
+
return sizeof(::Protocol::QUIC::Address);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const rb_data_type_t Ruby_Protocol_QUIC_Address_type = {
|
|
26
|
+
.wrap_struct_name = "Protocol::QUIC::Address",
|
|
27
|
+
.function = {
|
|
28
|
+
.dmark = NULL,
|
|
29
|
+
.dfree = Ruby_Protocol_QUIC_Address_free,
|
|
30
|
+
.dsize = Ruby_Protocol_QUIC_Address_size,
|
|
31
|
+
},
|
|
32
|
+
.data = NULL,
|
|
33
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
::Protocol::QUIC::Address * Ruby_Protocol_QUIC_Address_get(VALUE self)
|
|
37
|
+
{
|
|
38
|
+
::Protocol::QUIC::Address *address;
|
|
39
|
+
|
|
40
|
+
TypedData_Get_Struct(self, ::Protocol::QUIC::Address, &Ruby_Protocol_QUIC_Address_type, address);
|
|
41
|
+
|
|
42
|
+
return address;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
VALUE Ruby_Protocol_QUIC_Address_allocate(VALUE klass) {
|
|
46
|
+
return TypedData_Wrap_Struct(klass, &Ruby_Protocol_QUIC_Address_type, NULL);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static VALUE Ruby_Protocol_QUIC_Address_initialize(VALUE self) {
|
|
50
|
+
DATA_PTR(self) = new ::Protocol::QUIC::Address();
|
|
51
|
+
|
|
52
|
+
return self;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static VALUE Ruby_Protocol_QUIC_Address_inspect(VALUE self) {
|
|
56
|
+
auto address = Ruby_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 Ruby_Protocol_QUIC_Address_family(VALUE self) {
|
|
65
|
+
::Protocol::QUIC::Address *address = Ruby_Protocol_QUIC_Address_get(self);
|
|
66
|
+
|
|
67
|
+
return RB_INT2NUM(address->family());
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static VALUE Ruby_Protocol_QUIC_Address_data(VALUE self) {
|
|
71
|
+
::Protocol::QUIC::Address *address = Ruby_Protocol_QUIC_Address_get(self);
|
|
72
|
+
|
|
73
|
+
return rb_str_new((const char *)&address->data.sa, address->length);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
VALUE Ruby_Protocol_QUIC_Address_wrap(VALUE klass, const ::Protocol::QUIC::Address & address)
|
|
77
|
+
{
|
|
78
|
+
VALUE self = Ruby_Protocol_QUIC_Address_allocate(klass);
|
|
79
|
+
Ruby_Protocol_QUIC_Address_initialize(self);
|
|
80
|
+
|
|
81
|
+
::Protocol::QUIC::Address *data = Ruby_Protocol_QUIC_Address_get(self);
|
|
82
|
+
|
|
83
|
+
*data = address;
|
|
84
|
+
|
|
85
|
+
return self;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
VALUE Ruby_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, Ruby_Protocol_QUIC_Address_wrap(klass, address));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
void Init_Ruby_Protocol_QUIC_Address(VALUE Protocol_QUIC) {
|
|
111
|
+
Ruby_Protocol_QUIC_Address =
|
|
112
|
+
rb_define_class_under(Protocol_QUIC, "Address", rb_cObject);
|
|
113
|
+
|
|
114
|
+
rb_define_singleton_method(Ruby_Protocol_QUIC_Address, "resolve", Ruby_Protocol_QUIC_Address_s_resolve, 5);
|
|
115
|
+
|
|
116
|
+
rb_define_alloc_func(Ruby_Protocol_QUIC_Address, Ruby_Protocol_QUIC_Address_allocate);
|
|
117
|
+
rb_define_method(Ruby_Protocol_QUIC_Address, "initialize", Ruby_Protocol_QUIC_Address_initialize, 0);
|
|
118
|
+
rb_define_method(Ruby_Protocol_QUIC_Address, "inspect", Ruby_Protocol_QUIC_Address_inspect, 0);
|
|
119
|
+
|
|
120
|
+
rb_define_method(Ruby_Protocol_QUIC_Address, "family", Ruby_Protocol_QUIC_Address_family, 0);
|
|
121
|
+
rb_define_method(Ruby_Protocol_QUIC_Address, "data", Ruby_Protocol_QUIC_Address_data, 0);
|
|
122
|
+
}
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
extern "C" {
|
|
17
17
|
#endif
|
|
18
18
|
|
|
19
|
-
extern VALUE
|
|
19
|
+
extern VALUE Ruby_Protocol_QUIC_Address;
|
|
20
20
|
|
|
21
|
-
void
|
|
21
|
+
void Init_Ruby_Protocol_QUIC_Address(VALUE Protocol_QUIC);
|
|
22
22
|
|
|
23
|
-
Protocol::QUIC::Address *
|
|
23
|
+
::Protocol::QUIC::Address * Ruby_Protocol_QUIC_Address_get(VALUE self);
|
|
24
24
|
|
|
25
|
-
VALUE
|
|
26
|
-
VALUE
|
|
25
|
+
VALUE Ruby_Protocol_QUIC_Address_allocate(VALUE klass);
|
|
26
|
+
VALUE Ruby_Protocol_QUIC_Address_wrap(VALUE klass, const ::Protocol::QUIC::Address & address);
|
|
27
27
|
|
|
28
28
|
#ifdef __cplusplus
|
|
29
29
|
}
|
|
@@ -0,0 +1,161 @@
|
|
|
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 Ruby_Protocol_QUIC_Client = Qnil;
|
|
13
|
+
|
|
14
|
+
namespace Ruby::Protocol::QUIC {
|
|
15
|
+
|
|
16
|
+
class Client : public ::Protocol::QUIC::Client {
|
|
17
|
+
public:
|
|
18
|
+
VALUE self;
|
|
19
|
+
|
|
20
|
+
private:
|
|
21
|
+
VALUE _configuration;
|
|
22
|
+
VALUE _tls_context;
|
|
23
|
+
VALUE _socket;
|
|
24
|
+
VALUE _remote_address;
|
|
25
|
+
std::unordered_map<::Protocol::QUIC::StreamID, VALUE> _ruby_streams;
|
|
26
|
+
|
|
27
|
+
public:
|
|
28
|
+
Client(VALUE self, VALUE configuration, VALUE tls_context, VALUE socket, VALUE remote_address, VALUE chosen_version) : ::Protocol::QUIC::Client(*Ruby_Protocol_QUIC_Configuration_get(configuration), *Ruby_Protocol_QUIC_TLS_ClientContext_get(tls_context), *Ruby_Protocol_QUIC_Socket_get(socket), *Ruby_Protocol_QUIC_Address_get(remote_address), RB_NUM2UINT(chosen_version)), self(self), _configuration(configuration), _tls_context(tls_context), _socket(socket), _remote_address(remote_address) {}
|
|
29
|
+
virtual ~Client() {}
|
|
30
|
+
|
|
31
|
+
void handshake_completed() override
|
|
32
|
+
{
|
|
33
|
+
rb_funcall(self, rb_intern("handshake_completed"), 0);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
::Protocol::QUIC::Stream * create_stream(::Protocol::QUIC::StreamID stream_id) override
|
|
37
|
+
{
|
|
38
|
+
VALUE stream = rb_funcall(self, rb_intern("create_stream"), 1, RB_LL2NUM(stream_id));
|
|
39
|
+
_ruby_streams[stream_id] = stream;
|
|
40
|
+
|
|
41
|
+
return Ruby_Protocol_QUIC_Stream_get(stream);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
void disconnect() override
|
|
45
|
+
{
|
|
46
|
+
::Protocol::QUIC::Client::disconnect();
|
|
47
|
+
_ruby_streams.clear();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
void stream_close(::Protocol::QUIC::Stream * stream, std::int32_t flags, std::uint64_t error_code) override
|
|
51
|
+
{
|
|
52
|
+
auto stream_id = stream->stream_id();
|
|
53
|
+
::Protocol::QUIC::Client::stream_close(stream, flags, error_code);
|
|
54
|
+
_ruby_streams.erase(stream_id);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
void stream_reset(::Protocol::QUIC::Stream * stream, std::size_t final_size, std::uint64_t error_code) override
|
|
58
|
+
{
|
|
59
|
+
auto stream_id = stream->stream_id();
|
|
60
|
+
::Protocol::QUIC::Client::stream_reset(stream, final_size, error_code);
|
|
61
|
+
_ruby_streams.erase(stream_id);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
void mark() {
|
|
65
|
+
rb_gc_mark_movable(self);
|
|
66
|
+
rb_gc_mark_movable(_configuration);
|
|
67
|
+
rb_gc_mark_movable(_tls_context);
|
|
68
|
+
rb_gc_mark_movable(_socket);
|
|
69
|
+
rb_gc_mark_movable(_remote_address);
|
|
70
|
+
|
|
71
|
+
for (auto & [stream_id, ruby_stream] : _ruby_streams) {
|
|
72
|
+
rb_gc_mark_movable(ruby_stream);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
void compact() {
|
|
77
|
+
self = rb_gc_location(self);
|
|
78
|
+
_configuration = rb_gc_location(_configuration);
|
|
79
|
+
_tls_context = rb_gc_location(_tls_context);
|
|
80
|
+
_socket = rb_gc_location(_socket);
|
|
81
|
+
_remote_address = rb_gc_location(_remote_address);
|
|
82
|
+
|
|
83
|
+
for (auto & [stream_id, ruby_stream] : _ruby_streams) {
|
|
84
|
+
ruby_stream = rb_gc_location(ruby_stream);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
static void Ruby_Protocol_QUIC_Client_mark(void *data)
|
|
92
|
+
{
|
|
93
|
+
if (data) {
|
|
94
|
+
reinterpret_cast<Ruby::Protocol::QUIC::Client *>(data)->mark();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
static void Ruby_Protocol_QUIC_Client_compact(void *data)
|
|
99
|
+
{
|
|
100
|
+
if (data) {
|
|
101
|
+
reinterpret_cast<Ruby::Protocol::QUIC::Client *>(data)->compact();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
static void Ruby_Protocol_QUIC_Client_free(void *data)
|
|
106
|
+
{
|
|
107
|
+
if (data) {
|
|
108
|
+
delete reinterpret_cast<::Protocol::QUIC::Client *>(data);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
static size_t Ruby_Protocol_QUIC_Client_size(const void *data) {
|
|
113
|
+
return sizeof(Ruby::Protocol::QUIC::Client);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
static const rb_data_type_t Ruby_Protocol_QUIC_Client_type = {
|
|
117
|
+
.wrap_struct_name = "Protocol::QUIC::Client",
|
|
118
|
+
.function = {
|
|
119
|
+
.dmark = Ruby_Protocol_QUIC_Client_mark,
|
|
120
|
+
.dfree = Ruby_Protocol_QUIC_Client_free,
|
|
121
|
+
.dsize = Ruby_Protocol_QUIC_Client_size,
|
|
122
|
+
.dcompact = Ruby_Protocol_QUIC_Client_compact,
|
|
123
|
+
},
|
|
124
|
+
.data = NULL,
|
|
125
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
::Protocol::QUIC::Client * Ruby_Protocol_QUIC_Client_get(VALUE self)
|
|
129
|
+
{
|
|
130
|
+
::Protocol::QUIC::Client *configuration;
|
|
131
|
+
TypedData_Get_Struct(self, ::Protocol::QUIC::Client, &Ruby_Protocol_QUIC_Client_type, configuration);
|
|
132
|
+
return configuration;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
static VALUE Ruby_Protocol_QUIC_Client_allocate(VALUE klass) {
|
|
136
|
+
return TypedData_Wrap_Struct(klass, &Ruby_Protocol_QUIC_Client_type, NULL);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
static VALUE Ruby_Protocol_QUIC_Client_initialize(VALUE self, VALUE configuration, VALUE tls_context, VALUE socket, VALUE remote_address, VALUE chosen_version) {
|
|
140
|
+
::Protocol::QUIC::Client *client = new Ruby::Protocol::QUIC::Client(self, configuration, tls_context, socket, remote_address, chosen_version);
|
|
141
|
+
DATA_PTR(self) = client;
|
|
142
|
+
return self;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
static VALUE Ruby_Protocol_QUIC_Client_connect(VALUE self) {
|
|
146
|
+
::Protocol::QUIC::Client *client = Ruby_Protocol_QUIC_Client_get(self);
|
|
147
|
+
|
|
148
|
+
client->connect();
|
|
149
|
+
|
|
150
|
+
return Qnil;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
void Init_Ruby_Protocol_QUIC_Client(VALUE Protocol_QUIC) {
|
|
154
|
+
Ruby_Protocol_QUIC_Client =
|
|
155
|
+
rb_define_class_under(Protocol_QUIC, "Client", rb_cObject);
|
|
156
|
+
|
|
157
|
+
rb_define_alloc_func(Ruby_Protocol_QUIC_Client, Ruby_Protocol_QUIC_Client_allocate);
|
|
158
|
+
rb_define_method(Ruby_Protocol_QUIC_Client, "initialize", Ruby_Protocol_QUIC_Client_initialize, 5);
|
|
159
|
+
|
|
160
|
+
rb_define_method(Ruby_Protocol_QUIC_Client, "connect", Ruby_Protocol_QUIC_Client_connect, 0);
|
|
161
|
+
}
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
extern "C" {
|
|
17
17
|
#endif
|
|
18
18
|
|
|
19
|
-
extern VALUE
|
|
19
|
+
extern VALUE Ruby_Protocol_QUIC_Client;
|
|
20
20
|
|
|
21
|
-
void
|
|
21
|
+
void Init_Ruby_Protocol_QUIC_Client(VALUE Protocol_QUIC);
|
|
22
22
|
|
|
23
|
-
Protocol::QUIC::Client *
|
|
23
|
+
::Protocol::QUIC::Client * Ruby_Protocol_QUIC_Client_get(VALUE self);
|
|
24
24
|
|
|
25
25
|
#ifdef __cplusplus
|
|
26
26
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
|
|
2
|
+
#include <ruby.h>
|
|
3
|
+
|
|
4
|
+
#include "Configuration.hpp"
|
|
5
|
+
|
|
6
|
+
#include <stdarg.h>
|
|
7
|
+
#include <stdio.h>
|
|
8
|
+
|
|
9
|
+
#include <ngtcp2/ngtcp2.h>
|
|
10
|
+
|
|
11
|
+
VALUE Ruby_Protocol_QUIC_Configuration = Qnil;
|
|
12
|
+
|
|
13
|
+
static void Ruby_Protocol_QUIC_Configuration_free(void *data)
|
|
14
|
+
{
|
|
15
|
+
if (data) {
|
|
16
|
+
delete reinterpret_cast<::Protocol::QUIC::Configuration *>(data);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static size_t Ruby_Protocol_QUIC_Configuration_size(const void *data) {
|
|
21
|
+
return sizeof(::Protocol::QUIC::Configuration);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static const rb_data_type_t Ruby_Protocol_QUIC_Configuration_type = {
|
|
25
|
+
.wrap_struct_name = "Protocol::QUIC::Configuration",
|
|
26
|
+
.function = {
|
|
27
|
+
.dmark = NULL,
|
|
28
|
+
.dfree = Ruby_Protocol_QUIC_Configuration_free,
|
|
29
|
+
.dsize = Ruby_Protocol_QUIC_Configuration_size,
|
|
30
|
+
},
|
|
31
|
+
.data = NULL,
|
|
32
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
static VALUE Ruby_Protocol_QUIC_Configuration_allocate(VALUE klass) {
|
|
36
|
+
auto configuration = new ::Protocol::QUIC::Configuration();
|
|
37
|
+
|
|
38
|
+
return TypedData_Wrap_Struct(klass, &Ruby_Protocol_QUIC_Configuration_type, configuration);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
::Protocol::QUIC::Configuration * Ruby_Protocol_QUIC_Configuration_get(VALUE self)
|
|
42
|
+
{
|
|
43
|
+
::Protocol::QUIC::Configuration *configuration;
|
|
44
|
+
|
|
45
|
+
TypedData_Get_Struct(self, ::Protocol::QUIC::Configuration, &Ruby_Protocol_QUIC_Configuration_type, configuration);
|
|
46
|
+
|
|
47
|
+
return configuration;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static VALUE Ruby_Protocol_QUIC_Configuration_initialize(VALUE self) {
|
|
51
|
+
::Protocol::QUIC::Configuration *configuration;
|
|
52
|
+
|
|
53
|
+
TypedData_Get_Struct(self, ::Protocol::QUIC::Configuration, &Ruby_Protocol_QUIC_Configuration_type, configuration);
|
|
54
|
+
|
|
55
|
+
return self;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static VALUE Ruby_Protocol_QUIC_Configuration_static_secret(VALUE self) {
|
|
59
|
+
::Protocol::QUIC::Configuration *configuration;
|
|
60
|
+
|
|
61
|
+
TypedData_Get_Struct(self, ::Protocol::QUIC::Configuration, &Ruby_Protocol_QUIC_Configuration_type, configuration);
|
|
62
|
+
|
|
63
|
+
return rb_str_new((const char *)configuration->static_secret.data(), configuration->static_secret.size());
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
void Init_Ruby_Protocol_QUIC_Configuration(VALUE Protocol_QUIC) {
|
|
67
|
+
Ruby_Protocol_QUIC_Configuration =
|
|
68
|
+
rb_define_class_under(Protocol_QUIC, "Configuration", rb_cObject);
|
|
69
|
+
|
|
70
|
+
rb_define_alloc_func(Ruby_Protocol_QUIC_Configuration, Ruby_Protocol_QUIC_Configuration_allocate);
|
|
71
|
+
rb_define_method(Ruby_Protocol_QUIC_Configuration, "initialize", Ruby_Protocol_QUIC_Configuration_initialize, 0);
|
|
72
|
+
|
|
73
|
+
rb_define_method(Ruby_Protocol_QUIC_Configuration, "static_secret", Ruby_Protocol_QUIC_Configuration_static_secret, 0);
|
|
74
|
+
}
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
extern "C" {
|
|
17
17
|
#endif
|
|
18
18
|
|
|
19
|
-
extern VALUE
|
|
19
|
+
extern VALUE Ruby_Protocol_QUIC_Configuration;
|
|
20
20
|
|
|
21
|
-
void
|
|
21
|
+
void Init_Ruby_Protocol_QUIC_Configuration(VALUE Protocol_QUIC);
|
|
22
22
|
|
|
23
|
-
Protocol::QUIC::Configuration *
|
|
23
|
+
::Protocol::QUIC::Configuration * Ruby_Protocol_QUIC_Configuration_get(VALUE self);
|
|
24
24
|
|
|
25
25
|
#ifdef __cplusplus
|
|
26
26
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
|
|
2
|
+
#include <ruby.h>
|
|
3
|
+
|
|
4
|
+
#include "Connection.hpp"
|
|
5
|
+
#include "ruby/internal/intern/vm.h"
|
|
6
|
+
|
|
7
|
+
#include <stdarg.h>
|
|
8
|
+
#include <stdio.h>
|
|
9
|
+
|
|
10
|
+
#include <ngtcp2/ngtcp2.h>
|
|
11
|
+
|
|
12
|
+
VALUE Ruby_Protocol_QUIC_Connection = Qnil;
|
|
13
|
+
|
|
14
|
+
static void Ruby_Protocol_QUIC_Connection_free(void *data)
|
|
15
|
+
{
|
|
16
|
+
if (data) {
|
|
17
|
+
delete reinterpret_cast<::Protocol::QUIC::Connection *>(data);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static size_t Ruby_Protocol_QUIC_Connection_size(const void *data) {
|
|
22
|
+
return sizeof(::Protocol::QUIC::Connection);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const rb_data_type_t Ruby_Protocol_QUIC_Connection_type = {
|
|
26
|
+
.wrap_struct_name = "Protocol::QUIC::Connection",
|
|
27
|
+
.function = {
|
|
28
|
+
.dmark = NULL,
|
|
29
|
+
.dfree = Ruby_Protocol_QUIC_Connection_free,
|
|
30
|
+
.dsize = Ruby_Protocol_QUIC_Connection_size,
|
|
31
|
+
},
|
|
32
|
+
.data = NULL,
|
|
33
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
::Protocol::QUIC::Connection * Ruby_Protocol_QUIC_Connection_get(VALUE self)
|
|
37
|
+
{
|
|
38
|
+
::Protocol::QUIC::Connection *connection;
|
|
39
|
+
|
|
40
|
+
TypedData_Get_Struct(self, ::Protocol::QUIC::Connection, &Ruby_Protocol_QUIC_Connection_type, connection);
|
|
41
|
+
|
|
42
|
+
return connection;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
void Init_Ruby_Protocol_QUIC_Connection(VALUE Protocol_QUIC) {
|
|
46
|
+
Ruby_Protocol_QUIC_Connection =
|
|
47
|
+
rb_define_class_under(Protocol_QUIC, "Connection", rb_cObject);
|
|
48
|
+
|
|
49
|
+
rb_undef_alloc_func(Ruby_Protocol_QUIC_Connection);
|
|
50
|
+
}
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
extern "C" {
|
|
17
17
|
#endif
|
|
18
18
|
|
|
19
|
-
extern VALUE
|
|
19
|
+
extern VALUE Ruby_Protocol_QUIC_Connection;
|
|
20
20
|
|
|
21
|
-
extern const rb_data_type_t
|
|
21
|
+
extern const rb_data_type_t Ruby_Protocol_QUIC_Connection_type;
|
|
22
22
|
|
|
23
|
-
void
|
|
23
|
+
void Init_Ruby_Protocol_QUIC_Connection(VALUE Protocol_QUIC);
|
|
24
24
|
|
|
25
|
-
Protocol::QUIC::Connection *
|
|
25
|
+
::Protocol::QUIC::Connection * Ruby_Protocol_QUIC_Connection_get(VALUE self);
|
|
26
26
|
|
|
27
27
|
#ifdef __cplusplus
|
|
28
28
|
}
|