eventmachine 1.0.9.1-java → 1.2.0.1-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/CHANGELOG.md +26 -0
- data/README.md +2 -2
- data/ext/cmain.cpp +77 -5
- data/ext/ed.cpp +112 -42
- data/ext/ed.h +27 -13
- data/ext/em.cpp +105 -163
- data/ext/em.h +10 -7
- data/ext/eventmachine.h +13 -1
- data/ext/extconf.rb +23 -14
- data/ext/fastfilereader/extconf.rb +1 -2
- data/ext/fastfilereader/rubymain.cpp +6 -6
- data/ext/project.h +9 -4
- data/ext/rubymain.cpp +155 -36
- data/ext/ssl.cpp +157 -13
- data/ext/ssl.h +7 -2
- data/lib/em/channel.rb +5 -0
- data/lib/em/completion.rb +2 -2
- data/lib/em/connection.rb +61 -3
- data/lib/em/iterator.rb +26 -5
- data/lib/em/pool.rb +1 -1
- data/lib/em/protocols/line_and_text.rb +1 -1
- data/lib/em/pure_ruby.rb +6 -1
- data/lib/em/queue.rb +16 -7
- data/lib/em/resolver.rb +46 -23
- data/lib/em/threaded_resource.rb +2 -2
- data/lib/em/version.rb +1 -1
- data/lib/eventmachine.rb +59 -42
- data/lib/rubyeventmachine.jar +0 -0
- data/rakelib/package.rake +23 -1
- data/tests/dhparam.pem +13 -0
- data/tests/em_test_helper.rb +79 -0
- data/tests/test_basic.rb +17 -26
- data/tests/test_channel.rb +14 -1
- data/tests/test_connection_write.rb +2 -2
- data/tests/test_defer.rb +17 -0
- data/tests/test_epoll.rb +1 -1
- data/tests/test_fork.rb +75 -0
- data/tests/test_ipv4.rb +125 -0
- data/tests/test_ipv6.rb +131 -0
- data/tests/test_iterator.rb +18 -0
- data/tests/test_many_fds.rb +1 -1
- data/tests/test_queue.rb +14 -0
- data/tests/test_resolver.rb +23 -0
- data/tests/test_set_sock_opt.rb +2 -0
- data/tests/test_ssl_dhparam.rb +83 -0
- data/tests/test_ssl_ecdh_curve.rb +79 -0
- data/tests/test_ssl_extensions.rb +49 -0
- data/tests/test_ssl_methods.rb +19 -0
- data/tests/test_ssl_protocols.rb +246 -0
- data/tests/test_ssl_verify.rb +44 -0
- data/tests/test_system.rb +4 -0
- data/tests/test_unbind_reason.rb +5 -1
- metadata +101 -20
- data/.gitignore +0 -21
- data/.travis.yml +0 -22
- data/.yardopts +0 -7
- data/Gemfile +0 -2
- data/Rakefile +0 -20
- data/eventmachine.gemspec +0 -38
- data/rakelib/cpp.rake_example +0 -77
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 665744e926aea155efe9038c7f1bdc9acd68d45b
|
4
|
+
data.tar.gz: 8df216fd9b7563bfa0d33135ca8bba2f99bc1a1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdbb8272a0b26a4a333f460f5b3a5b9c30a1aff0f4c2af797a1623bf280f661dd5348f75dc92b60ae5a4abc71965e52b6b098b0d7ef5145903893e5ef677f0a2
|
7
|
+
data.tar.gz: 33ffa0e7cde75a462e6c6512628519490520febcc2cb6afe6e8e727087228145539aeaaf5d3d9adfa2728209cd7152124313865eafa1ac7b24417015336fedf9
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,31 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.2.0.1 (March 15, 2016)
|
4
|
+
* Fix crash when accepting IPv6 connections due to struct sockaddr_in [#698, #699]
|
5
|
+
|
6
|
+
## 1.2.0 (March 15, 2016)
|
7
|
+
* Integrate work from the EventMachine-LE 1.1.x versions [#570]
|
8
|
+
* Add start_tls options :ecdh_curve, :dhparam, :fail_if_no_peer_cert [#195, #275, #399, #665]
|
9
|
+
* Add start_tls option :ssl_version for choosing SSL/TLS versions and ciphers [#359, #348, #603, #654]
|
10
|
+
* Add start_tls option :sni_hostname to be passed to TLS params [#593]
|
11
|
+
* Add method EM::Channel#num_subscribers to get the number of subscribers to a channel [#640]
|
12
|
+
* Add support for proc-sources in EM::Iterator [#639]
|
13
|
+
* Factor out method cleanup_machine to cleanup code from EM.run [#650]
|
14
|
+
* Replace Exception class with StandardError [#637]
|
15
|
+
* Close socket on close_connection even after close_connection_after_writing [#694]
|
16
|
+
* Allow reusing of datagram socket/setting bind device [#662]
|
17
|
+
* Handle deferred exceptions in reactor thread [#486]
|
18
|
+
* Reimplement Queue to avoid shift/push performance problem [#311]
|
19
|
+
* Windows: Switch from gethostbyname to getaddrinfo, support IPv6 addresses [#303, #630]
|
20
|
+
* Windows: Use rake-compiler-dock to cross-compile gems [#627]
|
21
|
+
* Windows: Add AppVeyor configuration for Windows CI testing [#578]
|
22
|
+
* Windows: Bump rake-compiler to version 0.9.x [#542]
|
23
|
+
* Fix compilation on AIX (w/ XLC) [#693]
|
24
|
+
* Fix build on OpenBSD [#690]
|
25
|
+
* Fix OpenSSL compile issue on AIX 7.1 [#678]
|
26
|
+
* Fix EventMachine.fork_reactor keeps the threadpool of the original process [#425]
|
27
|
+
* Fix to prevent event machine from stopping when a raise is done in an unbind [#327]
|
28
|
+
|
3
29
|
## 1.0.9.1 (January 14, 2016)
|
4
30
|
* Fix EPROTO not defined on Windows [#676]
|
5
31
|
* Fix missing cast to struct sockaddr * [#671]
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# About EventMachine [](https://codeclimate.com/github/eventmachine/eventmachine)
|
2
2
|
|
3
3
|
|
4
4
|
## What is EventMachine ##
|
@@ -18,7 +18,7 @@ This unique combination makes EventMachine a premier choice for designers of cri
|
|
18
18
|
applications, including Web servers and proxies, email and IM production systems, authentication/authorization
|
19
19
|
processors, and many more.
|
20
20
|
|
21
|
-
EventMachine has been around since the early 2000s and is a mature and battle
|
21
|
+
EventMachine has been around since the early 2000s and is a mature and battle-tested library.
|
22
22
|
|
23
23
|
|
24
24
|
## What EventMachine is good for? ##
|
data/ext/cmain.cpp
CHANGED
@@ -433,6 +433,15 @@ extern "C" void evma_stop_machine()
|
|
433
433
|
EventMachine->ScheduleHalt();
|
434
434
|
}
|
435
435
|
|
436
|
+
/*****************
|
437
|
+
evma_stopping
|
438
|
+
*****************/
|
439
|
+
|
440
|
+
extern "C" bool evma_stopping()
|
441
|
+
{
|
442
|
+
ensure_eventmachine("evma_stopping");
|
443
|
+
return EventMachine->Stopping();
|
444
|
+
}
|
436
445
|
|
437
446
|
/**************
|
438
447
|
evma_start_tls
|
@@ -450,12 +459,12 @@ extern "C" void evma_start_tls (const uintptr_t binding)
|
|
450
459
|
evma_set_tls_parms
|
451
460
|
******************/
|
452
461
|
|
453
|
-
extern "C" void evma_set_tls_parms (const uintptr_t binding, const char *privatekey_filename, const char *certchain_filename, int verify_peer)
|
462
|
+
extern "C" void evma_set_tls_parms (const uintptr_t binding, const char *privatekey_filename, const char *certchain_filename, int verify_peer, int fail_if_no_peer_cert, const char *sni_hostname, const char *cipherlist, const char *ecdh_curve, const char *dhparam, int ssl_version)
|
454
463
|
{
|
455
464
|
ensure_eventmachine("evma_set_tls_parms");
|
456
465
|
EventableDescriptor *ed = dynamic_cast <EventableDescriptor*> (Bindable_t::GetObject (binding));
|
457
466
|
if (ed)
|
458
|
-
ed->SetTlsParms (privatekey_filename, certchain_filename, (verify_peer == 1 ? true : false));
|
467
|
+
ed->SetTlsParms (privatekey_filename, certchain_filename, (verify_peer == 1 ? true : false), (fail_if_no_peer_cert == 1 ? true : false), sni_hostname, cipherlist, ecdh_curve, dhparam, ssl_version);
|
459
468
|
}
|
460
469
|
|
461
470
|
/******************
|
@@ -473,6 +482,66 @@ extern "C" X509 *evma_get_peer_cert (const uintptr_t binding)
|
|
473
482
|
}
|
474
483
|
#endif
|
475
484
|
|
485
|
+
/******************
|
486
|
+
evma_get_cipher_bits
|
487
|
+
******************/
|
488
|
+
|
489
|
+
#ifdef WITH_SSL
|
490
|
+
extern "C" int evma_get_cipher_bits (const uintptr_t binding)
|
491
|
+
{
|
492
|
+
ensure_eventmachine("evma_get_cipher_bits");
|
493
|
+
EventableDescriptor *ed = dynamic_cast <EventableDescriptor*> (Bindable_t::GetObject (binding));
|
494
|
+
if (ed)
|
495
|
+
return ed->GetCipherBits();
|
496
|
+
return -1;
|
497
|
+
}
|
498
|
+
#endif
|
499
|
+
|
500
|
+
/******************
|
501
|
+
evma_get_cipher_name
|
502
|
+
******************/
|
503
|
+
|
504
|
+
#ifdef WITH_SSL
|
505
|
+
extern "C" const char *evma_get_cipher_name (const uintptr_t binding)
|
506
|
+
{
|
507
|
+
ensure_eventmachine("evma_get_cipher_name");
|
508
|
+
EventableDescriptor *ed = dynamic_cast <EventableDescriptor*> (Bindable_t::GetObject (binding));
|
509
|
+
if (ed)
|
510
|
+
return ed->GetCipherName();
|
511
|
+
return NULL;
|
512
|
+
}
|
513
|
+
#endif
|
514
|
+
|
515
|
+
/******************
|
516
|
+
evma_get_cipher_protocol
|
517
|
+
******************/
|
518
|
+
|
519
|
+
#ifdef WITH_SSL
|
520
|
+
extern "C" const char *evma_get_cipher_protocol (const uintptr_t binding)
|
521
|
+
{
|
522
|
+
ensure_eventmachine("evma_get_cipher_protocol");
|
523
|
+
EventableDescriptor *ed = dynamic_cast <EventableDescriptor*> (Bindable_t::GetObject (binding));
|
524
|
+
if (ed)
|
525
|
+
return ed->GetCipherProtocol();
|
526
|
+
return NULL;
|
527
|
+
}
|
528
|
+
#endif
|
529
|
+
|
530
|
+
/******************
|
531
|
+
evma_get_sni_hostname
|
532
|
+
******************/
|
533
|
+
|
534
|
+
#ifdef WITH_SSL
|
535
|
+
extern "C" const char *evma_get_sni_hostname (const uintptr_t binding)
|
536
|
+
{
|
537
|
+
ensure_eventmachine("evma_get_sni_hostname");
|
538
|
+
EventableDescriptor *ed = dynamic_cast <EventableDescriptor*> (Bindable_t::GetObject (binding));
|
539
|
+
if (ed)
|
540
|
+
return ed->GetSNIHostname();
|
541
|
+
return NULL;
|
542
|
+
}
|
543
|
+
#endif
|
544
|
+
|
476
545
|
/********************
|
477
546
|
evma_accept_ssl_peer
|
478
547
|
********************/
|
@@ -521,10 +590,10 @@ extern "C" int evma_get_sockname (const uintptr_t binding, struct sockaddr *sa,
|
|
521
590
|
evma_get_subprocess_pid
|
522
591
|
***********************/
|
523
592
|
|
593
|
+
#ifdef OS_UNIX
|
524
594
|
extern "C" int evma_get_subprocess_pid (const uintptr_t binding, pid_t *pid)
|
525
595
|
{
|
526
596
|
ensure_eventmachine("evma_get_subprocess_pid");
|
527
|
-
#ifdef OS_UNIX
|
528
597
|
PipeDescriptor *pd = dynamic_cast <PipeDescriptor*> (Bindable_t::GetObject (binding));
|
529
598
|
if (pd) {
|
530
599
|
return pd->GetSubprocessPid (pid) ? 1 : 0;
|
@@ -535,10 +604,13 @@ extern "C" int evma_get_subprocess_pid (const uintptr_t binding, pid_t *pid)
|
|
535
604
|
}
|
536
605
|
else
|
537
606
|
return 0;
|
538
|
-
|
607
|
+
}
|
608
|
+
#else
|
609
|
+
extern "C" int evma_get_subprocess_pid (const uintptr_t binding UNUSED, pid_t *pid UNUSED)
|
610
|
+
{
|
539
611
|
return 0;
|
540
|
-
#endif
|
541
612
|
}
|
613
|
+
#endif
|
542
614
|
|
543
615
|
/**************************
|
544
616
|
evma_get_subprocess_status
|
data/ext/ed.cpp
CHANGED
@@ -49,24 +49,26 @@ bool SetSocketNonblocking (SOCKET sd)
|
|
49
49
|
SetFdCloexec
|
50
50
|
************/
|
51
51
|
|
52
|
+
#ifdef OS_UNIX
|
52
53
|
bool SetFdCloexec (int fd)
|
53
54
|
{
|
54
|
-
#ifdef OS_UNIX
|
55
55
|
int flags = fcntl(fd, F_GETFD, 0);
|
56
56
|
assert (flags >= 0);
|
57
57
|
flags |= FD_CLOEXEC;
|
58
58
|
return (fcntl(fd, F_SETFD, FD_CLOEXEC) == 0) ? true : false;
|
59
|
-
|
60
|
-
|
59
|
+
}
|
60
|
+
#else
|
61
|
+
bool SetFdCloexec (int fd UNUSED)
|
62
|
+
{
|
61
63
|
return true;
|
62
|
-
#endif
|
63
64
|
}
|
65
|
+
#endif
|
64
66
|
|
65
67
|
/****************************************
|
66
68
|
EventableDescriptor::EventableDescriptor
|
67
69
|
****************************************/
|
68
70
|
|
69
|
-
EventableDescriptor::EventableDescriptor (
|
71
|
+
EventableDescriptor::EventableDescriptor (SOCKET sd, EventMachine_t *em):
|
70
72
|
bCloseNow (false),
|
71
73
|
bCloseAfterWriting (false),
|
72
74
|
MySocket (sd),
|
@@ -233,8 +235,14 @@ EventableDescriptor::ScheduleClose
|
|
233
235
|
|
234
236
|
void EventableDescriptor::ScheduleClose (bool after_writing)
|
235
237
|
{
|
236
|
-
if (IsCloseScheduled())
|
238
|
+
if (IsCloseScheduled()) {
|
239
|
+
if (!after_writing) {
|
240
|
+
// If closing has become more urgent, then upgrade the scheduled
|
241
|
+
// after_writing close to one NOW.
|
242
|
+
bCloseNow = true;
|
243
|
+
}
|
237
244
|
return;
|
245
|
+
}
|
238
246
|
MyEventMachine->NumCloseScheduled++;
|
239
247
|
// KEEP THIS SYNCHRONIZED WITH ::IsCloseScheduled.
|
240
248
|
if (after_writing)
|
@@ -387,7 +395,7 @@ uint64_t EventableDescriptor::GetNextHeartbeat()
|
|
387
395
|
ConnectionDescriptor::ConnectionDescriptor
|
388
396
|
******************************************/
|
389
397
|
|
390
|
-
ConnectionDescriptor::ConnectionDescriptor (
|
398
|
+
ConnectionDescriptor::ConnectionDescriptor (SOCKET sd, EventMachine_t *em):
|
391
399
|
EventableDescriptor (sd, em),
|
392
400
|
bConnectPending (false),
|
393
401
|
bNotifyReadable (false),
|
@@ -442,6 +450,9 @@ void ConnectionDescriptor::_UpdateEvents(bool read, bool write)
|
|
442
450
|
if (MySocket == INVALID_SOCKET)
|
443
451
|
return;
|
444
452
|
|
453
|
+
if (!read && !write)
|
454
|
+
return;
|
455
|
+
|
445
456
|
#ifdef HAVE_EPOLL
|
446
457
|
unsigned int old = EpollEvent.events;
|
447
458
|
|
@@ -768,7 +779,7 @@ void ConnectionDescriptor::Read()
|
|
768
779
|
* come here more than once after being closed. (FCianfrocca)
|
769
780
|
*/
|
770
781
|
|
771
|
-
|
782
|
+
SOCKET sd = GetSocket();
|
772
783
|
//assert (sd != INVALID_SOCKET); (original, removed 22Aug06)
|
773
784
|
if (sd == INVALID_SOCKET) {
|
774
785
|
assert (!bReadAttemptedAfterClose);
|
@@ -873,6 +884,9 @@ void ConnectionDescriptor::_DispatchInboundData (const char *buffer, unsigned lo
|
|
873
884
|
|
874
885
|
// If our SSL handshake had a problem, shut down the connection.
|
875
886
|
if (s == -2) {
|
887
|
+
#ifndef EPROTO // OpenBSD does not have EPROTO
|
888
|
+
#define EPROTO EINTR
|
889
|
+
#endif
|
876
890
|
#ifdef OS_UNIX
|
877
891
|
UnbindReasonCode = EPROTO;
|
878
892
|
#endif
|
@@ -1010,7 +1024,7 @@ void ConnectionDescriptor::_WriteOutboundData()
|
|
1010
1024
|
* doing it to address some reports of crashing under heavy loads.
|
1011
1025
|
*/
|
1012
1026
|
|
1013
|
-
|
1027
|
+
SOCKET sd = GetSocket();
|
1014
1028
|
//assert (sd != INVALID_SOCKET);
|
1015
1029
|
if (sd == INVALID_SOCKET) {
|
1016
1030
|
assert (!bWriteAttemptedAfterClose);
|
@@ -1180,7 +1194,7 @@ void ConnectionDescriptor::StartTls()
|
|
1180
1194
|
if (SslBox)
|
1181
1195
|
throw std::runtime_error ("SSL/TLS already running on connection");
|
1182
1196
|
|
1183
|
-
SslBox = new SslBox_t (bIsServer, PrivateKeyFilename, CertChainFilename, bSslVerifyPeer, GetBinding());
|
1197
|
+
SslBox = new SslBox_t (bIsServer, PrivateKeyFilename, CertChainFilename, bSslVerifyPeer, bSslFailIfNoPeerCert, SniHostName, CipherList, EcdhCurve, DhParam, Protocols, GetBinding());
|
1184
1198
|
_DispatchCiphertext();
|
1185
1199
|
|
1186
1200
|
}
|
@@ -1197,7 +1211,7 @@ ConnectionDescriptor::SetTlsParms
|
|
1197
1211
|
*********************************/
|
1198
1212
|
|
1199
1213
|
#ifdef WITH_SSL
|
1200
|
-
void ConnectionDescriptor::SetTlsParms (const char *privkey_filename, const char *certchain_filename, bool verify_peer)
|
1214
|
+
void ConnectionDescriptor::SetTlsParms (const char *privkey_filename, const char *certchain_filename, bool verify_peer, bool fail_if_no_peer_cert, const char *sni_hostname, const char *cipherlist, const char *ecdh_curve, const char *dhparam, int protocols)
|
1201
1215
|
{
|
1202
1216
|
if (SslBox)
|
1203
1217
|
throw std::runtime_error ("call SetTlsParms before calling StartTls");
|
@@ -1205,10 +1219,22 @@ void ConnectionDescriptor::SetTlsParms (const char *privkey_filename, const char
|
|
1205
1219
|
PrivateKeyFilename = privkey_filename;
|
1206
1220
|
if (certchain_filename && *certchain_filename)
|
1207
1221
|
CertChainFilename = certchain_filename;
|
1208
|
-
bSslVerifyPeer
|
1222
|
+
bSslVerifyPeer = verify_peer;
|
1223
|
+
bSslFailIfNoPeerCert = fail_if_no_peer_cert;
|
1224
|
+
|
1225
|
+
if (sni_hostname && *sni_hostname)
|
1226
|
+
SniHostName = sni_hostname;
|
1227
|
+
if (cipherlist && *cipherlist)
|
1228
|
+
CipherList = cipherlist;
|
1229
|
+
if (ecdh_curve && *ecdh_curve)
|
1230
|
+
EcdhCurve = ecdh_curve;
|
1231
|
+
if (dhparam && *dhparam)
|
1232
|
+
DhParam = dhparam;
|
1233
|
+
|
1234
|
+
Protocols = protocols;
|
1209
1235
|
}
|
1210
1236
|
#else
|
1211
|
-
void ConnectionDescriptor::SetTlsParms (const char *privkey_filename UNUSED, const char *certchain_filename UNUSED, bool verify_peer UNUSED)
|
1237
|
+
void ConnectionDescriptor::SetTlsParms (const char *privkey_filename UNUSED, const char *certchain_filename UNUSED, bool verify_peer UNUSED, bool fail_if_no_peer_cert UNUSED, const char *sni_hostname UNUSED, const char *cipherlist UNUSED, const char *ecdh_curve UNUSED, const char *dhparam UNUSED, int protocols UNUSED)
|
1212
1238
|
{
|
1213
1239
|
throw std::runtime_error ("Encryption not available on this event-machine");
|
1214
1240
|
}
|
@@ -1229,6 +1255,62 @@ X509 *ConnectionDescriptor::GetPeerCert()
|
|
1229
1255
|
#endif
|
1230
1256
|
|
1231
1257
|
|
1258
|
+
/*********************************
|
1259
|
+
ConnectionDescriptor::GetCipherBits
|
1260
|
+
*********************************/
|
1261
|
+
|
1262
|
+
#ifdef WITH_SSL
|
1263
|
+
int ConnectionDescriptor::GetCipherBits()
|
1264
|
+
{
|
1265
|
+
if (!SslBox)
|
1266
|
+
throw std::runtime_error ("SSL/TLS not running on this connection");
|
1267
|
+
return SslBox->GetCipherBits();
|
1268
|
+
}
|
1269
|
+
#endif
|
1270
|
+
|
1271
|
+
|
1272
|
+
/*********************************
|
1273
|
+
ConnectionDescriptor::GetCipherName
|
1274
|
+
*********************************/
|
1275
|
+
|
1276
|
+
#ifdef WITH_SSL
|
1277
|
+
const char *ConnectionDescriptor::GetCipherName()
|
1278
|
+
{
|
1279
|
+
if (!SslBox)
|
1280
|
+
throw std::runtime_error ("SSL/TLS not running on this connection");
|
1281
|
+
return SslBox->GetCipherName();
|
1282
|
+
}
|
1283
|
+
#endif
|
1284
|
+
|
1285
|
+
|
1286
|
+
/*********************************
|
1287
|
+
ConnectionDescriptor::GetCipherProtocol
|
1288
|
+
*********************************/
|
1289
|
+
|
1290
|
+
#ifdef WITH_SSL
|
1291
|
+
const char *ConnectionDescriptor::GetCipherProtocol()
|
1292
|
+
{
|
1293
|
+
if (!SslBox)
|
1294
|
+
throw std::runtime_error ("SSL/TLS not running on this connection");
|
1295
|
+
return SslBox->GetCipherProtocol();
|
1296
|
+
}
|
1297
|
+
#endif
|
1298
|
+
|
1299
|
+
|
1300
|
+
/*********************************
|
1301
|
+
ConnectionDescriptor::GetSNIHostname
|
1302
|
+
*********************************/
|
1303
|
+
|
1304
|
+
#ifdef WITH_SSL
|
1305
|
+
const char *ConnectionDescriptor::GetSNIHostname()
|
1306
|
+
{
|
1307
|
+
if (!SslBox)
|
1308
|
+
throw std::runtime_error ("SSL/TLS not running on this connection");
|
1309
|
+
return SslBox->GetSNIHostname();
|
1310
|
+
}
|
1311
|
+
#endif
|
1312
|
+
|
1313
|
+
|
1232
1314
|
/***********************************
|
1233
1315
|
ConnectionDescriptor::VerifySslPeer
|
1234
1316
|
***********************************/
|
@@ -1356,7 +1438,7 @@ void ConnectionDescriptor::Heartbeat()
|
|
1356
1438
|
LoopbreakDescriptor::LoopbreakDescriptor
|
1357
1439
|
****************************************/
|
1358
1440
|
|
1359
|
-
LoopbreakDescriptor::LoopbreakDescriptor (
|
1441
|
+
LoopbreakDescriptor::LoopbreakDescriptor (SOCKET sd, EventMachine_t *parent_em):
|
1360
1442
|
EventableDescriptor (sd, parent_em)
|
1361
1443
|
{
|
1362
1444
|
/* This is really bad and ugly. Change someday if possible.
|
@@ -1403,7 +1485,7 @@ void LoopbreakDescriptor::Write()
|
|
1403
1485
|
AcceptorDescriptor::AcceptorDescriptor
|
1404
1486
|
**************************************/
|
1405
1487
|
|
1406
|
-
AcceptorDescriptor::AcceptorDescriptor (
|
1488
|
+
AcceptorDescriptor::AcceptorDescriptor (SOCKET sd, EventMachine_t *parent_em):
|
1407
1489
|
EventableDescriptor (sd, parent_em)
|
1408
1490
|
{
|
1409
1491
|
#ifdef HAVE_EPOLL
|
@@ -1458,20 +1540,20 @@ void AcceptorDescriptor::Read()
|
|
1458
1540
|
*/
|
1459
1541
|
|
1460
1542
|
|
1461
|
-
struct
|
1543
|
+
struct sockaddr_in6 pin;
|
1462
1544
|
socklen_t addrlen = sizeof (pin);
|
1463
1545
|
int accept_count = EventMachine_t::GetSimultaneousAcceptCount();
|
1464
1546
|
|
1465
1547
|
for (int i=0; i < accept_count; i++) {
|
1466
|
-
#if defined(
|
1467
|
-
|
1548
|
+
#if defined(HAVE_CONST_SOCK_CLOEXEC) && defined(HAVE_ACCEPT4)
|
1549
|
+
SOCKET sd = accept4 (GetSocket(), (struct sockaddr*)&pin, &addrlen, SOCK_CLOEXEC);
|
1468
1550
|
if (sd == INVALID_SOCKET) {
|
1469
1551
|
// We may be running in a kernel where
|
1470
1552
|
// SOCK_CLOEXEC is not supported - fall back:
|
1471
1553
|
sd = accept (GetSocket(), (struct sockaddr*)&pin, &addrlen);
|
1472
1554
|
}
|
1473
1555
|
#else
|
1474
|
-
|
1556
|
+
SOCKET sd = accept (GetSocket(), (struct sockaddr*)&pin, &addrlen);
|
1475
1557
|
#endif
|
1476
1558
|
if (sd == INVALID_SOCKET) {
|
1477
1559
|
// This breaks the loop when we've accepted everything on the kernel queue,
|
@@ -1567,7 +1649,7 @@ bool AcceptorDescriptor::GetSockname (struct sockaddr *s, socklen_t *len)
|
|
1567
1649
|
DatagramDescriptor::DatagramDescriptor
|
1568
1650
|
**************************************/
|
1569
1651
|
|
1570
|
-
DatagramDescriptor::DatagramDescriptor (
|
1652
|
+
DatagramDescriptor::DatagramDescriptor (SOCKET sd, EventMachine_t *parent_em):
|
1571
1653
|
EventableDescriptor (sd, parent_em),
|
1572
1654
|
OutboundDataSize (0)
|
1573
1655
|
{
|
@@ -1635,7 +1717,7 @@ DatagramDescriptor::Read
|
|
1635
1717
|
|
1636
1718
|
void DatagramDescriptor::Read()
|
1637
1719
|
{
|
1638
|
-
|
1720
|
+
SOCKET sd = GetSocket();
|
1639
1721
|
assert (sd != INVALID_SOCKET);
|
1640
1722
|
LastActivity = MyEventMachine->GetCurrentLoopTime();
|
1641
1723
|
|
@@ -1651,7 +1733,7 @@ void DatagramDescriptor::Read()
|
|
1651
1733
|
// That's so we can put a guard byte at the end of what we send
|
1652
1734
|
// to user code.
|
1653
1735
|
|
1654
|
-
struct
|
1736
|
+
struct sockaddr_in6 sin;
|
1655
1737
|
socklen_t slen = sizeof (sin);
|
1656
1738
|
memset (&sin, 0, slen);
|
1657
1739
|
|
@@ -1712,7 +1794,7 @@ void DatagramDescriptor::Write()
|
|
1712
1794
|
* TODO, we are currently suppressing the EMSGSIZE error!!!
|
1713
1795
|
*/
|
1714
1796
|
|
1715
|
-
|
1797
|
+
SOCKET sd = GetSocket();
|
1716
1798
|
assert (sd != INVALID_SOCKET);
|
1717
1799
|
LastActivity = MyEventMachine->GetCurrentLoopTime();
|
1718
1800
|
|
@@ -1725,7 +1807,8 @@ void DatagramDescriptor::Write()
|
|
1725
1807
|
OutboundPage *op = &(OutboundPages[0]);
|
1726
1808
|
|
1727
1809
|
// The nasty cast to (char*) is needed because Windows is brain-dead.
|
1728
|
-
int s = sendto (sd, (char*)op->Buffer, op->Length, 0, (struct sockaddr*)&(op->From),
|
1810
|
+
int s = sendto (sd, (char*)op->Buffer, op->Length, 0, (struct sockaddr*)&(op->From),
|
1811
|
+
(op->From.sin6_family == AF_INET6 ? sizeof (struct sockaddr_in6) : sizeof (struct sockaddr_in)));
|
1729
1812
|
#ifdef OS_WIN32
|
1730
1813
|
int e = WSAGetLastError();
|
1731
1814
|
#else
|
@@ -1837,23 +1920,10 @@ int DatagramDescriptor::SendOutboundDatagram (const char *data, unsigned long le
|
|
1837
1920
|
if (!address || !*address || !port)
|
1838
1921
|
return 0;
|
1839
1922
|
|
1840
|
-
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1844
|
-
if (HostAddr == INADDR_NONE) {
|
1845
|
-
// The nasty cast to (char*) is because Windows is brain-dead.
|
1846
|
-
hostent *hp = gethostbyname ((char*)address);
|
1847
|
-
if (!hp)
|
1848
|
-
return 0;
|
1849
|
-
HostAddr = ((in_addr*)(hp->h_addr))->s_addr;
|
1850
|
-
}
|
1851
|
-
|
1852
|
-
memset (&pin, 0, sizeof(pin));
|
1853
|
-
pin.sin_family = AF_INET;
|
1854
|
-
pin.sin_addr.s_addr = HostAddr;
|
1855
|
-
pin.sin_port = htons (port);
|
1856
|
-
|
1923
|
+
struct sockaddr_in6 addr_here;
|
1924
|
+
size_t addr_here_len = sizeof addr_here;
|
1925
|
+
if (!EventMachine_t::name2address (address, port, (struct sockaddr *)&addr_here, &addr_here_len))
|
1926
|
+
return -1;
|
1857
1927
|
|
1858
1928
|
if (!data && (length > 0))
|
1859
1929
|
throw std::runtime_error ("bad outbound data");
|
@@ -1862,7 +1932,7 @@ int DatagramDescriptor::SendOutboundDatagram (const char *data, unsigned long le
|
|
1862
1932
|
throw std::runtime_error ("no allocation for outbound data");
|
1863
1933
|
memcpy (buffer, data, length);
|
1864
1934
|
buffer [length] = 0;
|
1865
|
-
OutboundPages.push_back (OutboundPage (buffer, length,
|
1935
|
+
OutboundPages.push_back (OutboundPage (buffer, length, addr_here));
|
1866
1936
|
OutboundDataSize += length;
|
1867
1937
|
|
1868
1938
|
#ifdef HAVE_EPOLL
|