zeromq: support no auth and multi frame

This commit is contained in:
Brian Knox 2016-05-13 06:49:31 -04:00
parent 299f5a637f
commit 7f6da6456a
2 changed files with 39 additions and 33 deletions

View File

@ -358,7 +358,8 @@ static rsRetVal rcvData(){
pData = zlist_next(listenerList);
}
zframe_t *frame;
zsock_t *which = (zsock_t *)zpoller_wait(poller, -1);
while (which) {
pData = zlist_first(listenerList);
@ -370,7 +371,9 @@ static rsRetVal rcvData(){
DBGPRINTF("imczmq: found matching socket\n");
}
char *buf = zstr_recv(which);
frame = zframe_recv(which);
char *buf = zframe_strdup(frame);
if (buf == NULL) {
DBGPRINTF("imczmq: null buffer\n");
continue;
@ -389,10 +392,11 @@ static rsRetVal rcvData(){
submitMsg2(pMsg);
}
zstr_free(&buf);
free(buf);
which = (zsock_t *)zpoller_wait(poller, -1);
}
finalize_it:
zframe_destroy(&frame);
zpoller_destroy(&poller);
pData = zlist_first(listenerList);
while(pData) {

View File

@ -113,38 +113,40 @@ static rsRetVal initCZMQ(instanceData* pData) {
ABORT_FINALIZE(RS_RET_SUSPENDED);
}
zsock_set_sndtimeo (pData->sock, pData->sendTimeout);
if (!strcmp((const char *)runModConf->authType, "CURVESERVER")) {
zcert_t *serverCert = zcert_load(runModConf->serverCertPath);
if (!serverCert) {
errmsg.LogError(0, NO_ERRCODE, "could not load cert %s",
runModConf->serverCertPath);
ABORT_FINALIZE(RS_RET_ERR);
}
zsock_set_zap_domain(pData->sock, "global");
zsock_set_curve_server(pData->sock, 1);
zcert_apply(serverCert, pData->sock);
zcert_destroy(&serverCert);
}
else if (!strcmp((const char *)runModConf->authType, "CURVECLIENT")) {
zcert_t *serverCert = zcert_load(runModConf->serverCertPath);
if (!serverCert) {
errmsg.LogError(0, NO_ERRCODE, "could not load cert %s",
runModConf->serverCertPath);
ABORT_FINALIZE(RS_RET_ERR);
}
const char *server_key = zcert_public_txt(serverCert);
zcert_destroy(&serverCert);
zsock_set_curve_serverkey(pData->sock, server_key);
zcert_t *clientCert = zcert_load(runModConf->clientCertPath);
if (!clientCert) {
errmsg.LogError(0, NO_ERRCODE, "could not load cert %s",
runModConf->clientCertPath);
ABORT_FINALIZE(RS_RET_ERR);
if(runModConf->authType) {
if (!strcmp((const char *)runModConf->authType, "CURVESERVER")) {
zcert_t *serverCert = zcert_load(runModConf->serverCertPath);
if (!serverCert) {
errmsg.LogError(0, NO_ERRCODE, "could not load cert %s",
runModConf->serverCertPath);
ABORT_FINALIZE(RS_RET_ERR);
}
zsock_set_zap_domain(pData->sock, "global");
zsock_set_curve_server(pData->sock, 1);
zcert_apply(serverCert, pData->sock);
zcert_destroy(&serverCert);
}
else if (!strcmp((const char *)runModConf->authType, "CURVECLIENT")) {
zcert_t *serverCert = zcert_load(runModConf->serverCertPath);
if (!serverCert) {
errmsg.LogError(0, NO_ERRCODE, "could not load cert %s",
runModConf->serverCertPath);
ABORT_FINALIZE(RS_RET_ERR);
}
const char *server_key = zcert_public_txt(serverCert);
zcert_destroy(&serverCert);
zsock_set_curve_serverkey(pData->sock, server_key);
zcert_t *clientCert = zcert_load(runModConf->clientCertPath);
if (!clientCert) {
errmsg.LogError(0, NO_ERRCODE, "could not load cert %s",
runModConf->clientCertPath);
ABORT_FINALIZE(RS_RET_ERR);
}
zcert_apply(clientCert, pData->sock);
zcert_destroy(&clientCert);
}
zcert_apply(clientCert, pData->sock);
zcert_destroy(&clientCert);
}
switch (pData->sockType) {