Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sgxwallet
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董子豪
sgxwallet
Commits
5bf09563
Unverified
Commit
5bf09563
authored
Jan 28, 2021
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug/SKALE-3751-enable-zeromq
parent
b0d5ac3e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
5 deletions
+40
-5
ServerWorker.cpp
ServerWorker.cpp
+9
-1
ServerWorker.h
ServerWorker.h
+4
-1
ZMQClient.cpp
ZMQClient.cpp
+14
-0
ZMQClient.h
ZMQClient.h
+3
-2
ZMQServer.cpp
ZMQServer.cpp
+9
-1
ZMQServer.h
ZMQServer.h
+1
-0
No files found.
ServerWorker.cpp
View file @
5bf09563
...
...
@@ -15,9 +15,17 @@
std
::
atomic
<
uint64_t
>
ServerWorker
::
workerCount
(
1
);
ServerWorker
::
ServerWorker
(
zmq
::
context_t
&
ctx
,
int
sock_type
)
:
ctx_
(
ctx
),
ServerWorker
::
ServerWorker
(
zmq
::
context_t
&
ctx
,
int
sock_type
,
bool
_checkSignature
,
const
string
&
_caCert
)
:
checkSignature
(
_checkSignature
),
caCert
(
_caCert
),
ctx_
(
ctx
),
worker_
(
ctx_
,
sock_type
),
isExitRequested
(
false
)
{
if
(
checkSignature
)
{
CHECK_STATE
(
!
caCert
.
empty
())
}
index
=
workerCount
.
fetch_add
(
1
);
int
linger
=
0
;
zmq_setsockopt
(
worker_
,
ZMQ_LINGER
,
&
linger
,
sizeof
(
linger
));
...
...
ServerWorker.h
View file @
5bf09563
...
...
@@ -19,8 +19,11 @@
class
ServerWorker
{
bool
checkSignature
=
true
;
string
caCert
=
""
;
public
:
ServerWorker
(
zmq
::
context_t
&
ctx
,
int
sock_type
);
ServerWorker
(
zmq
::
context_t
&
ctx
,
int
sock_type
,
bool
_checkSignature
,
const
string
&
_caCert
);
void
work
();
...
...
ZMQClient.cpp
View file @
5bf09563
...
...
@@ -25,6 +25,9 @@
#include <sys/types.h>
#include <sys/syscall.h>
#include <fstream>
#include <streambuf>
#include "common.h"
#include "BLSSignReqMessage.h"
...
...
@@ -38,6 +41,10 @@ shared_ptr <ZMQMessage> ZMQClient::doRequestReply(Json::Value &_req) {
Json
::
FastWriter
fastWriter
;
string
reqStr
=
fastWriter
.
write
(
_req
);
//if (sign) {
_req
[
"cert"
]
=
certificate
;
//}
reqStr
=
reqStr
.
substr
(
0
,
reqStr
.
size
()
-
1
);
CHECK_STATE
(
reqStr
.
front
()
==
'{'
);
CHECK_STATE
(
reqStr
.
at
(
reqStr
.
size
()
-
1
)
==
'}'
);
...
...
@@ -116,6 +123,13 @@ ZMQClient::ZMQClient(const string &ip, uint16_t port, bool _sign, const string &
if
(
_sign
)
{
CHECK_STATE
(
!
_certFileName
.
empty
());
CHECK_STATE
(
!
_certKeyName
.
empty
());
ifstream
t
(
_certFileName
);
string
str
((
istreambuf_iterator
<
char
>
(
t
)),
istreambuf_iterator
<
char
>
());
certificate
=
str
;
CHECK_STATE
(
!
certificate
.
empty
());
}
else
{
CHECK_STATE
(
_certFileName
.
empty
());
CHECK_STATE
(
_certKeyName
.
empty
());
...
...
ZMQClient.h
View file @
5bf09563
...
...
@@ -46,8 +46,9 @@ private:
bool
sign
;
string
certFileName
;
string
certKeyName
;
string
certFileName
=
""
;
string
certificate
=
""
;
string
certKeyName
=
""
;
recursive_mutex
mutex
;
...
...
ZMQServer.cpp
View file @
5bf09563
...
...
@@ -21,6 +21,9 @@
@date 2019
*/
#include <fstream>
#include <streambuf>
#include "third_party/spdlog/spdlog.h"
...
...
@@ -42,6 +45,10 @@ ZMQServer::ZMQServer(bool _checkSignature, const string& _caCertFile)
if
(
_checkSignature
)
{
CHECK_STATE
(
!
_caCertFile
.
empty
());
ifstream
t
(
_caCertFile
);
string
str
((
istreambuf_iterator
<
char
>
(
t
)),
istreambuf_iterator
<
char
>
());
caCert
=
str
;
CHECK_STATE
(
!
caCert
.
empty
())
}
int
linger
=
0
;
...
...
@@ -78,7 +85,8 @@ void ZMQServer::run() {
try
{
for
(
int
i
=
0
;
i
<
kMaxThread
;
++
i
)
{
workers
.
push_back
(
make_shared
<
ServerWorker
>
(
*
ctx_
,
ZMQ_DEALER
));
workers
.
push_back
(
make_shared
<
ServerWorker
>
(
*
ctx_
,
ZMQ_DEALER
,
this
->
checkSignature
,
this
->
caCert
));
auto
th
=
make_shared
<
std
::
thread
>
(
std
::
bind
(
&
ServerWorker
::
work
,
workers
[
i
]));
th
->
detach
();
worker_threads
.
push_back
(
th
);
...
...
ZMQServer.h
View file @
5bf09563
...
...
@@ -46,6 +46,7 @@ public:
bool
checkSignature
=
false
;
string
caCertFile
=
""
;
string
caCert
=
""
;
static
ZMQServer
*
zmqServer
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment