Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
05a66cc1
Commit
05a66cc1
authored
5 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
proxy client: use common jsonReader
parent
ed6df886
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/opendht/dht_proxy_client.h
+3
-3
3 additions, 3 deletions
include/opendht/dht_proxy_client.h
src/dht_proxy_client.cpp
+9
-13
9 additions, 13 deletions
src/dht_proxy_client.cpp
with
12 additions
and
16 deletions
include/opendht/dht_proxy_client.h
+
3
−
3
View file @
05a66cc1
...
...
@@ -53,9 +53,9 @@ public:
DhtProxyClient
();
explicit
DhtProxyClient
(
std
::
shared_ptr
<
dht
::
crypto
::
Certificate
>
serverCA
,
dht
::
crypto
::
Identity
clientIdentity
,
std
::
shared_ptr
<
crypto
::
Certificate
>
serverCA
,
crypto
::
Identity
clientIdentity
,
std
::
function
<
void
()
>
loopSignal
,
const
std
::
string
&
serverHost
,
const
std
::
string
&
pushClientId
=
""
,
std
::
shared_ptr
<
dht
::
Logger
>
logger
=
{});
const
std
::
string
&
pushClientId
=
""
,
std
::
shared_ptr
<
Logger
>
logger
=
{});
void
setHeaderFields
(
http
::
Request
&
request
);
...
...
@@ -404,7 +404,7 @@ private:
#endif // OPENDHT_PUSH_NOTIFICATIONS
Json
::
StreamWriterBuilder
jsonBuilder_
;
Json
::
CharReader
Builder
jsonReader
Builder
_
;
std
::
unique_ptr
<
Json
::
CharReader
>
jsonReader_
;
std
::
shared_ptr
<
dht
::
Logger
>
logger_
;
std
::
shared_ptr
<
http
::
Request
>
buildRequest
(
const
std
::
string
&
target
=
{});
...
...
This diff is collapsed.
Click to expand it.
src/dht_proxy_client.cpp
+
9
−
13
View file @
05a66cc1
...
...
@@ -99,16 +99,15 @@ DhtProxyClient::DhtProxyClient(
std
::
shared_ptr
<
dht
::
crypto
::
Certificate
>
serverCA
,
dht
::
crypto
::
Identity
clientIdentity
,
std
::
function
<
void
()
>
signal
,
const
std
::
string
&
serverHost
,
const
std
::
string
&
pushClientId
,
std
::
shared_ptr
<
dht
::
Logger
>
logger
)
:
clientIdentity_
(
clientIdentity
),
serverCertificate_
(
serverCA
),
pushClientId_
(
pushClientId
),
loopSignal_
(
signal
),
logger_
(
logger
)
:
proxyUrl_
(
serverHost
)
,
clientIdentity_
(
clientIdentity
),
serverCertificate_
(
serverCA
)
,
pushClientId_
(
pushClientId
),
loopSignal_
(
signal
)
,
jsonReader_
(
Json
::
CharReaderBuilder
{}.
newCharReader
())
,
logger_
(
logger
)
{
// build http client
proxyUrl_
=
serverHost
;
jsonBuilder_
[
"commentStyle"
]
=
"None"
;
jsonBuilder_
[
"indentation"
]
=
""
;
if
(
logger_
){
if
(
logger_
)
{
if
(
serverCertificate_
)
logger_
->
d
(
"[proxy:client] using ca certificate for ssl:
\n
%s"
,
serverCertificate_
->
toString
(
false
/*chain*/
).
c_str
());
...
...
@@ -320,8 +319,7 @@ DhtProxyClient::get(const InfoHash& key, GetCallback cb, DoneCallback donecb, Va
std
::
string
err
;
Json
::
Value
json
;
const
auto
&
line
=
b
.
line
();
auto
reader
=
std
::
unique_ptr
<
Json
::
CharReader
>
(
jsonReaderBuilder_
.
newCharReader
());
if
(
!
reader
->
parse
(
line
.
data
(),
line
.
data
()
+
line
.
size
(),
&
json
,
&
err
)){
if
(
!
jsonReader_
->
parse
(
line
.
data
(),
line
.
data
()
+
line
.
size
(),
&
json
,
&
err
)){
opstate
->
ok
.
store
(
false
);
return
;
}
...
...
@@ -615,8 +613,7 @@ DhtProxyClient::queryProxyInfo(std::shared_ptr<InfoState> infoState, sa_family_t
}
else
{
std
::
string
err
;
Json
::
Value
proxyInfos
;
auto
reader
=
std
::
unique_ptr
<
Json
::
CharReader
>
(
jsonReaderBuilder_
.
newCharReader
());
if
(
!
reader
->
parse
(
response
.
body
.
data
(),
response
.
body
.
data
()
+
response
.
body
.
size
(),
&
proxyInfos
,
&
err
)){
if
(
!
jsonReader_
->
parse
(
response
.
body
.
data
(),
response
.
body
.
data
()
+
response
.
body
.
size
(),
&
proxyInfos
,
&
err
)){
onProxyInfos
(
Json
::
Value
{},
family
);
return
;
}
...
...
@@ -964,8 +961,7 @@ DhtProxyClient::sendListen(const restinio::http_request_header_t header,
std
::
string
err
;
Json
::
Value
json
;
const
auto
&
line
=
b
.
line
();
auto
reader
=
std
::
unique_ptr
<
Json
::
CharReader
>
(
jsonReaderBuilder_
.
newCharReader
());
if
(
!
reader
->
parse
(
line
.
data
(),
line
.
data
()
+
line
.
size
(),
&
json
,
&
err
)){
if
(
!
jsonReader_
->
parse
(
line
.
data
(),
line
.
data
()
+
line
.
size
(),
&
json
,
&
err
)){
opstate
->
ok
.
store
(
false
);
return
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment