Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
1206f457
Commit
1206f457
authored
Sep 17, 2013
by
Laurent Alebarde
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oblige the application to explicitely set the node type for PLAIN
parent
bfd472f9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
16 deletions
+17
-16
zmq.h
include/zmq.h
+2
-2
options.cpp
src/options.cpp
+7
-9
test_security_curve.cpp
tests/test_security_curve.cpp
+2
-2
test_security_plain.cpp
tests/test_security_plain.cpp
+6
-3
No files found.
include/zmq.h
View file @
1206f457
...
...
@@ -269,10 +269,10 @@ ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg, int option, int optval);
#define ZMQ_ROUTER_RAW 41
#define ZMQ_IPV6 42
#define ZMQ_MECHANISM 43
#define ZMQ_PLAIN_
SERVER
44
#define ZMQ_PLAIN_
NODE
44
#define ZMQ_PLAIN_USERNAME 45
#define ZMQ_PLAIN_PASSWORD 46
#define ZMQ_CURVE_
SERVER
47
#define ZMQ_CURVE_
NODE
47
#define ZMQ_CURVE_OUR_PERMA_PUB_KEY 48
#define ZMQ_CURVE_OUR_PERMA_SEC_KEY 49
#define ZMQ_CURVE_PEER_PERMA_PUB_KEY 50
...
...
src/options.cpp
View file @
1206f457
...
...
@@ -275,10 +275,10 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
}
break
;
case
ZMQ_PLAIN_
SERVER
:
if
(
is_int
&&
(
value
==
0
||
value
==
1
))
{
case
ZMQ_PLAIN_
NODE
:
if
(
is_int
&&
(
value
==
ZMQ_CLIENT
||
value
==
ZMQ_SERVER
))
{
as_server
=
value
;
mechanism
=
value
?
ZMQ_PLAIN
:
ZMQ_NULL
;
mechanism
=
ZMQ_PLAIN
;
return
0
;
}
break
;
...
...
@@ -291,7 +291,6 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
else
if
(
optvallen_
>
0
&&
optvallen_
<
256
&&
optval_
!=
NULL
)
{
plain_username
.
assign
((
const
char
*
)
optval_
,
optvallen_
);
as_server
=
0
;
mechanism
=
ZMQ_PLAIN
;
return
0
;
}
...
...
@@ -305,7 +304,6 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
else
if
(
optvallen_
>
0
&&
optvallen_
<
256
&&
optval_
!=
NULL
)
{
plain_password
.
assign
((
const
char
*
)
optval_
,
optvallen_
);
as_server
=
0
;
mechanism
=
ZMQ_PLAIN
;
return
0
;
}
...
...
@@ -320,7 +318,7 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
// If libsodium isn't installed, these options provoke EINVAL
# ifdef HAVE_LIBSODIUM
case
ZMQ_CURVE_
SERVER
:
case
ZMQ_CURVE_
NODE
:
if
(
is_int
&&
(
value
==
ZMQ_CLIENT
||
value
==
ZMQ_SERVER
))
{
as_server
=
value
;
mechanism
=
ZMQ_CURVE
;
...
...
@@ -542,9 +540,9 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
}
break
;
case
ZMQ_PLAIN_
SERVER
:
case
ZMQ_PLAIN_
NODE
:
if
(
is_int
)
{
*
value
=
as_server
&&
mechanism
==
ZMQ_PLAIN
;
*
value
=
as_server
;
return
0
;
}
break
;
...
...
@@ -575,7 +573,7 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
// If libsodium isn't installed, these options provoke EINVAL
# ifdef HAVE_LIBSODIUM
case
ZMQ_CURVE_
SERVER
:
case
ZMQ_CURVE_
NODE
:
if
(
is_int
)
{
*
value
=
as_server
;
return
0
;
...
...
tests/test_security_curve.cpp
View file @
1206f457
...
...
@@ -103,7 +103,7 @@ int main (void)
void
*
server
=
zmq_socket
(
ctx
,
ZMQ_DEALER
);
assert
(
server
);
int
as_server
=
ZMQ_SERVER
;
rc
=
zmq_setsockopt
(
server
,
ZMQ_CURVE_
SERVER
,
&
as_server
,
sizeof
(
int
));
rc
=
zmq_setsockopt
(
server
,
ZMQ_CURVE_
NODE
,
&
as_server
,
sizeof
(
int
));
assert
(
rc
==
0
);
rc
=
zmq_setsockopt
(
server
,
ZMQ_CURVE_OUR_PERMA_SEC_KEY
,
server_secret
,
40
);
assert
(
rc
==
0
);
...
...
@@ -116,7 +116,7 @@ int main (void)
void
*
client
=
zmq_socket
(
ctx
,
ZMQ_DEALER
);
assert
(
client
);
as_server
=
ZMQ_CLIENT
;
rc
=
zmq_setsockopt
(
client
,
ZMQ_CURVE_
SERVER
,
&
as_server
,
sizeof
(
int
));
rc
=
zmq_setsockopt
(
client
,
ZMQ_CURVE_
NODE
,
&
as_server
,
sizeof
(
int
));
assert
(
rc
==
0
);
rc
=
zmq_setsockopt
(
client
,
ZMQ_CURVE_PEER_PERMA_PUB_KEY
,
server_public
,
40
);
assert
(
rc
==
0
);
...
...
tests/test_security_plain.cpp
View file @
1206f457
...
...
@@ -87,8 +87,8 @@ int main (void)
assert
(
server
);
int
rc
=
zmq_setsockopt
(
server
,
ZMQ_IDENTITY
,
"IDENT"
,
6
);
assert
(
rc
==
0
);
int
as_server
=
1
;
rc
=
zmq_setsockopt
(
server
,
ZMQ_PLAIN_
SERVER
,
&
as_server
,
sizeof
(
int
));
int
as_server
=
ZMQ_SERVER
;
rc
=
zmq_setsockopt
(
server
,
ZMQ_PLAIN_
NODE
,
&
as_server
,
sizeof
(
int
));
assert
(
rc
==
0
);
rc
=
zmq_bind
(
server
,
"tcp://*:9998"
);
assert
(
rc
==
0
);
...
...
@@ -99,6 +99,9 @@ int main (void)
// Check PLAIN security with correct username/password
void
*
client
=
zmq_socket
(
ctx
,
ZMQ_DEALER
);
assert
(
client
);
as_server
=
ZMQ_CLIENT
;
rc
=
zmq_setsockopt
(
server
,
ZMQ_PLAIN_NODE
,
&
as_server
,
sizeof
(
int
));
assert
(
rc
==
0
);
strcpy
(
username
,
"admin"
);
rc
=
zmq_setsockopt
(
client
,
ZMQ_PLAIN_USERNAME
,
username
,
strlen
(
username
));
assert
(
rc
==
0
);
...
...
@@ -116,7 +119,7 @@ int main (void)
client
=
zmq_socket
(
ctx
,
ZMQ_DEALER
);
assert
(
client
);
as_server
=
1
;
rc
=
zmq_setsockopt
(
client
,
ZMQ_PLAIN_
SERVER
,
&
as_server
,
sizeof
(
int
));
rc
=
zmq_setsockopt
(
client
,
ZMQ_PLAIN_
NODE
,
&
as_server
,
sizeof
(
int
));
assert
(
rc
==
0
);
rc
=
zmq_connect
(
client
,
"tcp://localhost:9998"
);
assert
(
rc
==
0
);
...
...
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