@@ -33,12 +33,14 @@ namespace libbitcoin {
33
33
namespace protocol {
34
34
namespace zmq {
35
35
36
+ using namespace bc ::system;
37
+
36
38
// ZAP endpoint, see: rfc.zeromq.org/spec:27/ZAP
37
- const system:: config::endpoint authenticator::endpoint (
39
+ const config::endpoint authenticator::endpoint (
38
40
" inproc://zeromq.zap.01" );
39
41
40
42
// There may be only one authenticator per process.
41
- authenticator::authenticator (system:: thread_priority priority)
43
+ authenticator::authenticator (thread_priority priority)
42
44
: worker(priority),
43
45
context_ (false ),
44
46
require_allow_(false )
@@ -61,7 +63,7 @@ bool authenticator::start()
61
63
// Context is thread safe, this critical section is for start atomicity.
62
64
// /////////////////////////////////////////////////////////////////////////
63
65
// Critical Section
64
- system:: unique_lock lock (stop_mutex_);
66
+ unique_lock lock (stop_mutex_);
65
67
66
68
return context_.start () && worker::start ();
67
69
// /////////////////////////////////////////////////////////////////////////
@@ -72,7 +74,7 @@ bool authenticator::stop()
72
74
// Context is thread safe, this critical section is for stop atomicity.
73
75
// /////////////////////////////////////////////////////////////////////////
74
76
// Critical Section
75
- system:: unique_lock lock (stop_mutex_);
77
+ unique_lock lock (stop_mutex_);
76
78
77
79
// Stop the context first in case a blocking proxy is in use.
78
80
return context_.stop () && worker::stop ();
@@ -85,7 +87,7 @@ void authenticator::work()
85
87
{
86
88
socket replier (context_, zmq::socket::role::replier);
87
89
88
- if (!started (replier.bind (endpoint) == system:: error::success))
90
+ if (!started (replier.bind (endpoint) == error::success))
89
91
return ;
90
92
91
93
poller poller;
@@ -106,7 +108,7 @@ void authenticator::work()
106
108
message request;
107
109
auto ec = replier.receive (request);
108
110
109
- if (ec != system:: error::success || request.size () < 6 )
111
+ if (ec != error::success || request.size () < 6 )
110
112
{
111
113
status_code = " 500" ;
112
114
status_text = " Internal error." ;
@@ -171,7 +173,7 @@ void authenticator::work()
171
173
}
172
174
else
173
175
{
174
- system:: hash_digest public_key;
176
+ hash_digest public_key;
175
177
176
178
if (!request.dequeue (public_key))
177
179
{
@@ -265,11 +267,11 @@ bool authenticator::apply(socket& socket, const std::string& domain,
265
267
}
266
268
267
269
void authenticator::set_private_key (
268
- const system:: config::sodium& private_key)
270
+ const config::sodium& private_key)
269
271
{
270
272
// /////////////////////////////////////////////////////////////////////////
271
273
// Critical Section
272
- system:: unique_lock lock (property_mutex_);
274
+ unique_lock lock (property_mutex_);
273
275
274
276
private_key_ = private_key;
275
277
// /////////////////////////////////////////////////////////////////////////
@@ -279,7 +281,7 @@ bool authenticator::allowed_address(const std::string& ip_address) const
279
281
{
280
282
// /////////////////////////////////////////////////////////////////////////
281
283
// Critical Section
282
- system:: shared_lock lock (property_mutex_);
284
+ shared_lock lock (property_mutex_);
283
285
284
286
const auto entry = adresses_.find (ip_address);
285
287
const auto found = entry != adresses_.end ();
@@ -288,11 +290,11 @@ bool authenticator::allowed_address(const std::string& ip_address) const
288
290
// /////////////////////////////////////////////////////////////////////////
289
291
}
290
292
291
- bool authenticator::allowed_key (const system:: hash_digest& public_key) const
293
+ bool authenticator::allowed_key (const hash_digest& public_key) const
292
294
{
293
295
// /////////////////////////////////////////////////////////////////////////
294
296
// Critical Section
295
- system:: shared_lock lock (property_mutex_);
297
+ shared_lock lock (property_mutex_);
296
298
297
299
return keys_.empty () || keys_.find (public_key) != keys_.end ();
298
300
// /////////////////////////////////////////////////////////////////////////
@@ -302,27 +304,27 @@ bool authenticator::allowed_weak(const std::string& domain) const
302
304
{
303
305
// /////////////////////////////////////////////////////////////////////////
304
306
// Critical Section
305
- system:: shared_lock lock (property_mutex_);
307
+ shared_lock lock (property_mutex_);
306
308
307
309
return weak_domains_.find (domain) != weak_domains_.end ();
308
310
// /////////////////////////////////////////////////////////////////////////
309
311
}
310
312
311
- void authenticator::allow (const system:: hash_digest& public_key)
313
+ void authenticator::allow (const hash_digest& public_key)
312
314
{
313
315
// /////////////////////////////////////////////////////////////////////////
314
316
// Critical Section
315
- system:: unique_lock lock (property_mutex_);
317
+ unique_lock lock (property_mutex_);
316
318
317
319
keys_.emplace (public_key);
318
320
// /////////////////////////////////////////////////////////////////////////
319
321
}
320
322
321
- void authenticator::allow (const system:: config::authority& address)
323
+ void authenticator::allow (const config::authority& address)
322
324
{
323
325
// /////////////////////////////////////////////////////////////////////////
324
326
// Critical Section
325
- system:: unique_lock lock (property_mutex_);
327
+ unique_lock lock (property_mutex_);
326
328
327
329
require_allow_ = true ;
328
330
@@ -331,11 +333,11 @@ void authenticator::allow(const system::config::authority& address)
331
333
// /////////////////////////////////////////////////////////////////////////
332
334
}
333
335
334
- void authenticator::deny (const system:: config::authority& address)
336
+ void authenticator::deny (const config::authority& address)
335
337
{
336
338
// /////////////////////////////////////////////////////////////////////////
337
339
// Critical Section
338
- system:: unique_lock lock (property_mutex_);
340
+ unique_lock lock (property_mutex_);
339
341
340
342
// Denial is effective independent of whitelisting.
341
343
// Due to emplace behavior, first writer wins allow/deny conflict.
0 commit comments