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
8283d499
Unverified
Commit
8283d499
authored
Dec 11, 2020
by
Oleh Nikolaiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-3023 fix 2 commands
parent
d2357217
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
10 deletions
+43
-10
SGXInfoServer.cpp
SGXInfoServer.cpp
+3
-3
SGXWalletServer.cpp
SGXWalletServer.cpp
+0
-1
abstractinfoserver.h
abstractinfoserver.h
+2
-2
sgx_util.cpp
sgx_util.cpp
+38
-4
No files found.
SGXInfoServer.cpp
View file @
8283d499
...
@@ -106,14 +106,14 @@ Json::Value SGXInfoServer::isKeyExist(const string& key) {
...
@@ -106,14 +106,14 @@ Json::Value SGXInfoServer::isKeyExist(const string& key) {
}
}
int
SGXInfoServer
::
initInfoServer
(
uint32_t
_logLevel
,
bool
_autoSign
,
bool
_checkCerts
,
bool
_generateTestKeys
)
{
int
SGXInfoServer
::
initInfoServer
(
uint32_t
_logLevel
,
bool
_autoSign
,
bool
_checkCerts
,
bool
_generateTestKeys
)
{
httpServer
=
make_shared
<
HttpServer
>
(
BASE_PORT
+
5
);
httpServer
=
make_shared
<
HttpServer
>
(
BASE_PORT
+
4
);
server
=
make_shared
<
SGXInfoServer
>
(
*
httpServer
,
JSONRPC_SERVER_V2
,
_logLevel
,
_autoSign
,
_checkCerts
,
_generateTestKeys
);
// hybrid server (json-rpc 1.0 & 2.0)
server
=
make_shared
<
SGXInfoServer
>
(
*
httpServer
,
JSONRPC_SERVER_V2
,
_logLevel
,
_autoSign
,
_checkCerts
,
_generateTestKeys
);
// hybrid server (json-rpc 1.0 & 2.0)
if
(
!
server
->
StartListening
())
{
if
(
!
server
->
StartListening
())
{
spdlog
::
error
(
"Info server could not start listening on port {}"
,
BASE_PORT
+
5
);
spdlog
::
error
(
"Info server could not start listening on port {}"
,
BASE_PORT
+
4
);
exit
(
-
10
);
exit
(
-
10
);
}
else
{
}
else
{
spdlog
::
info
(
"Info server started on port {}"
,
BASE_PORT
+
5
);
spdlog
::
info
(
"Info server started on port {}"
,
BASE_PORT
+
4
);
}
}
return
0
;
return
0
;
...
...
SGXWalletServer.cpp
View file @
8283d499
...
@@ -166,7 +166,6 @@ int SGXWalletServer::initHttpsServer(bool _checkCerts) {
...
@@ -166,7 +166,6 @@ int SGXWalletServer::initHttpsServer(bool _checkCerts) {
}
}
}
}
httpServer
=
make_shared
<
HttpServer
>
(
BASE_PORT
,
certPath
,
keyPath
,
rootCAPath
,
_checkCerts
,
httpServer
=
make_shared
<
HttpServer
>
(
BASE_PORT
,
certPath
,
keyPath
,
rootCAPath
,
_checkCerts
,
NUM_THREADS
);
NUM_THREADS
);
...
...
abstractinfoserver.h
View file @
8283d499
...
@@ -35,7 +35,7 @@ public:
...
@@ -35,7 +35,7 @@ public:
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"getAllKeysInfo"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
NULL
),
&
AbstractInfoServer
::
getAllKeysInfoI
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"getAllKeysInfo"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
NULL
),
&
AbstractInfoServer
::
getAllKeysInfoI
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"getLatestCreatedKey"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
NULL
),
&
AbstractInfoServer
::
getLatestCreatedKeyI
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"getLatestCreatedKey"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
NULL
),
&
AbstractInfoServer
::
getLatestCreatedKeyI
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"getServerConfiguration"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
NULL
),
&
AbstractInfoServer
::
getServerConfigurationI
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"getServerConfiguration"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
NULL
),
&
AbstractInfoServer
::
getServerConfigurationI
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"isKeyExist"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
"key"
,
jsonrpc
::
JSON_STRING
,
NULL
),
&
AbstractInfoServer
::
isKeyExistI
);
this
->
bindAndAddMethod
(
jsonrpc
::
Procedure
(
"isKeyExist"
,
jsonrpc
::
PARAMS_BY_NAME
,
jsonrpc
::
JSON_OBJECT
,
"key
Name
"
,
jsonrpc
::
JSON_STRING
,
NULL
),
&
AbstractInfoServer
::
isKeyExistI
);
}
}
inline
virtual
void
getAllKeysInfoI
(
const
Json
::
Value
&
request
,
Json
::
Value
&
response
)
inline
virtual
void
getAllKeysInfoI
(
const
Json
::
Value
&
request
,
Json
::
Value
&
response
)
...
@@ -55,7 +55,7 @@ public:
...
@@ -55,7 +55,7 @@ public:
inline
virtual
void
isKeyExistI
(
const
Json
::
Value
&
request
,
Json
::
Value
&
response
)
inline
virtual
void
isKeyExistI
(
const
Json
::
Value
&
request
,
Json
::
Value
&
response
)
{
{
response
=
this
->
isKeyExist
(
request
[
"key"
].
asString
());
response
=
this
->
isKeyExist
(
request
[
"key
Name
"
].
asString
());
}
}
...
...
sgx_util.cpp
View file @
8283d499
...
@@ -67,8 +67,28 @@ void getServerConfiguration() {
...
@@ -67,8 +67,28 @@ void getServerConfiguration() {
StubClient
c
(
client
,
jsonrpc
::
JSONRPC_CLIENT_V2
);
StubClient
c
(
client
,
jsonrpc
::
JSONRPC_CLIENT_V2
);
std
::
cout
<<
"Info client inited"
<<
std
::
endl
;
std
::
cout
<<
"Info client inited"
<<
std
::
endl
;
Json
::
Value
response
=
c
.
getServerConfiguration
();
Json
::
Value
response
=
c
.
getServerConfiguration
();
std
::
cout
<<
"OPTION autoConfitm certificates switched to "
<<
response
[
"autoConfitm"
]
<<
'\n'
;
std
::
cout
<<
"OPTION autoConfirm certificates switched to "
<<
response
[
"autoConfirm"
]
<<
'\n'
;
std
::
cout
<<
"OPTION logLevel switched to "
<<
response
[
"logLevel"
]
<<
'\n'
;
uint32_t
logLevel
=
response
[
"logLevel"
].
asInt
();
std
::
string
logLevelStr
;
switch
(
logLevel
)
{
case
0
:
logLevelStr
=
"trace"
;
break
;
case
1
:
logLevelStr
=
"debug"
;
break
;
case
2
:
logLevelStr
=
"info"
;
break
;
case
3
:
logLevelStr
=
"warning"
;
break
;
case
4
:
logLevelStr
=
"error"
;
break
;
}
std
::
cout
<<
"OPTION logLevel switched to "
<<
logLevelStr
<<
'\n'
;
std
::
cout
<<
"OPTION enterBackupKey switched to "
<<
response
[
"enterBackupKey"
]
<<
'\n'
;
std
::
cout
<<
"OPTION enterBackupKey switched to "
<<
response
[
"enterBackupKey"
]
<<
'\n'
;
std
::
cout
<<
"OPTION useHTTPS switched to "
<<
response
[
"useHTTPS"
]
<<
'\n'
;
std
::
cout
<<
"OPTION useHTTPS switched to "
<<
response
[
"useHTTPS"
]
<<
'\n'
;
std
::
cout
<<
"OPTION autoSign certificates switched to "
<<
response
[
"autoSign"
]
<<
'\n'
;
std
::
cout
<<
"OPTION autoSign certificates switched to "
<<
response
[
"autoSign"
]
<<
'\n'
;
...
@@ -82,9 +102,9 @@ void isKeyExists(const std::string& key) {
...
@@ -82,9 +102,9 @@ void isKeyExists(const std::string& key) {
StubClient
c
(
client
,
jsonrpc
::
JSONRPC_CLIENT_V2
);
StubClient
c
(
client
,
jsonrpc
::
JSONRPC_CLIENT_V2
);
std
::
cout
<<
"Info client inited"
<<
std
::
endl
;
std
::
cout
<<
"Info client inited"
<<
std
::
endl
;
if
(
c
.
isKeyExist
(
key
)[
"IsExist"
].
asBool
())
{
if
(
c
.
isKeyExist
(
key
)[
"IsExist"
].
asBool
())
{
std
::
cout
<<
"Key with name "
<<
key
<<
"presents in server database."
;
std
::
cout
<<
"Key with name "
<<
key
<<
"presents in server database.
\n
"
;
}
else
{
}
else
{
std
::
cout
<<
"Key with name "
<<
key
<<
"does not exist in server's database."
;
std
::
cout
<<
"Key with name "
<<
key
<<
"does not exist in server's database.
\n
"
;
}
}
exit
(
0
);
exit
(
0
);
}
}
...
@@ -108,7 +128,9 @@ int main(int argc, char *argv[]) {
...
@@ -108,7 +128,9 @@ int main(int argc, char *argv[]) {
std
::
cout
<<
" -i [name] check if key with such name presents in database"
<<
std
::
endl
;
std
::
cout
<<
" -i [name] check if key with such name presents in database"
<<
std
::
endl
;
exit
(
0
);
exit
(
0
);
}
}
std
::
string
hash
;
std
::
string
hash
;
std
::
string
key
;
while
((
opt
=
getopt
(
argc
,
argv
,
"ps:r:alci:"
))
!=
-
1
)
{
while
((
opt
=
getopt
(
argc
,
argv
,
"ps:r:alci:"
))
!=
-
1
)
{
switch
(
opt
)
{
switch
(
opt
)
{
case
'p'
:
print_hashes
();
case
'p'
:
print_hashes
();
...
@@ -119,6 +141,18 @@ int main(int argc, char *argv[]) {
...
@@ -119,6 +141,18 @@ int main(int argc, char *argv[]) {
case
'r'
:
hash
=
optarg
;
case
'r'
:
hash
=
optarg
;
sign_by_hash
(
hash
,
2
);
sign_by_hash
(
hash
,
2
);
break
;
break
;
case
'a'
:
getAllKeysInfo
();
break
;
case
'l'
:
getLatestCreatedKey
();
break
;
case
'c'
:
getServerConfiguration
();
break
;
case
'i'
:
key
=
optarg
;
isKeyExists
(
key
);
break
;
case
'?'
:
// fprintf(stderr, "unknown flag\n");
case
'?'
:
// fprintf(stderr, "unknown flag\n");
exit
(
1
);
exit
(
1
);
}
}
...
...
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