diff --git a/contrib/imczmq/README b/contrib/imczmq/README index 09bc08680..ce0fb0887 100644 --- a/contrib/imczmq/README +++ b/contrib/imczmq/README @@ -13,8 +13,8 @@ input( type="imczmq" endpoints="tcp://*:24555" topics="topic1,topic2,topic3" - socktype="SUB" - conntype="CURVESERVER" + socktype="PULL" + authtype="CURVESERVER" curveclientcert="/etc/curve.d/" curveservercert="/etc/curve.d/example_curve_server_cert" ) @@ -26,11 +26,7 @@ name: name of this action type: type of action (imczmq for this plugin) endpoints: comma delimited list of zeromq endpoints (see zeromq documentation) socktype: zeromq socket type (currently supports PULL and SUB) -conntype: - CLIENT - zeromq connect - SERVER - zeromq bind - CURVECLIENT - zeromq connect with curve encryption - CURVESERVER - zeromq bind with curve encryption +authtype: CURVECLIENT or CURVESERVER curveclientcert: if CURVECLIENT, this client's cert if CURVESERVER, "*" for all, or a directory of allowed public certs diff --git a/contrib/imczmq/imczmq.c b/contrib/imczmq/imczmq.c index f68c83f00..c5aee7a52 100644 --- a/contrib/imczmq/imczmq.c +++ b/contrib/imczmq/imczmq.c @@ -1,4 +1,4 @@ -/* imczmq.c +/* omczmq.c * Copyright (C) 2014 Brian Knox * Copyright (C) 2014 Rainer Gerhards * @@ -59,7 +59,7 @@ struct instanceConf_s { int sockType; char *sockEndpoints; char *topicList; - char *connType; + char *authType; char *clientCertPath; char *serverCertPath; uchar *pszBindRuleset; @@ -102,7 +102,7 @@ static struct cnfparamblk modpblk = { static struct cnfparamdescr inppdescr[] = { { "endpoints", eCmdHdlrGetWord, 1 }, { "socktype", eCmdHdlrGetWord, 1 }, - { "conntype", eCmdHdlrGetWord, 0 }, + { "authtype", eCmdHdlrGetWord, 0 }, { "topics", eCmdHdlrGetWord, 0 }, { "clientcertpath", eCmdHdlrGetWord, 0 }, { "servercertpath", eCmdHdlrGetWord, 0 }, @@ -121,7 +121,7 @@ static void setDefaults(instanceConf_t* iconf) { iconf->sockType = -1; iconf->sockEndpoints = NULL; iconf->topicList = NULL; - iconf->connType = NULL; + iconf->authType = NULL; iconf->clientCertPath = NULL; iconf->serverCertPath = NULL; iconf->pszBindRuleset = NULL; @@ -182,10 +182,6 @@ static rsRetVal createListener(struct cnfparamvals* pvals) { inst->sockType = ZMQ_PULL; } - else if (!strcmp("ROUTER", stringType)) { - inst->sockType = ZMQ_ROUTER; - } - else { errmsg.LogError(0, RS_RET_CONFIG_ERROR, "imczmq: invalid sockType"); @@ -205,19 +201,17 @@ static rsRetVal createListener(struct cnfparamvals* pvals) { } /* get the authentication type to use */ - else if(!strcmp(inppblk.descr[i].name, "conntype")) { - inst->connType = es_str2cstr(pvals[i].val.d.estr, NULL); + else if(!strcmp(inppblk.descr[i].name, "authtype")) { + inst->authType = es_str2cstr(pvals[i].val.d.estr, NULL); /* make sure defined type is supported */ - if ((inst->connType != NULL) && - strcmp("CURVESERVER", inst->connType) && - strcmp("CURVECLIENT", inst->connType) && - strcmp("CLIENT", inst->connType) && - strcmp("SERVER", inst->connType)) - { + if ((inst->authType != NULL) && + strcmp("CURVESERVER", inst->authType) && + strcmp("CURVECLIENT", inst->authType)) { + errmsg.LogError(0, RS_RET_CONFIG_ERROR, - "imczmq: %s is not a valid connType", - inst->connType); + "imczmq: %s is not a valid authType", + inst->authType); ABORT_FINALIZE(RS_RET_CONFIG_ERROR); } } @@ -263,21 +257,17 @@ static rsRetVal addListener(instanceConf_t* iconf){ bool is_server = false; - DBGPRINTF("imczmq: conntype is: %s\n", iconf->connType); - - if (!strcmp(iconf->connType, "CURVESERVER") || - !stcmp(iconf->connType, "SERVER")) - { - is_server = true; - - /* set global auth domain */ - zsock_set_zap_domain(pData->sock, "global"); - } + DBGPRINTF("imczmq: authtype is: %s\n", iconf->authType); /* if we are a CURVE server */ - if (!strcmp(iconf->connType, "CURVESERVER")) { + if (!strcmp(iconf->authType, "CURVESERVER")) { - /* set that we are a curve server */ + is_server = true; + + /* set global auth domain */ + zsock_set_zap_domain(pData->sock, "global"); + + /* set that we are a curve server */ zsock_set_curve_server(pData->sock, 1); /* get and set our server cert */ @@ -297,7 +287,7 @@ static rsRetVal addListener(instanceConf_t* iconf){ } /* if we are a CURVE client */ - if (!strcmp(iconf->connType, "CURVECLIENT")) { + if (!strcmp(iconf->authType, "CURVECLIENT")) { DBGPRINTF("imczmq: we are a curve client...\n"); is_server = false; @@ -313,7 +303,7 @@ static rsRetVal addListener(instanceConf_t* iconf){ zcert_apply(pData->clientCert, pData->sock); /* get the server cert */ - DBGPRINTF("imczmq: server cert is %s...\n", iconf->serverCertPath); + DBGPRINTF("omczmq: server cert is %s...\n", iconf->serverCertPath); pData->serverCert = zcert_load(iconf->serverCertPath); if (!pData->serverCert) { errmsg.LogError(0, NO_ERRCODE, "could not load server cert"); @@ -322,7 +312,7 @@ static rsRetVal addListener(instanceConf_t* iconf){ /* get the server public key and set it for the socket */ char *server_key = zcert_public_txt(pData->serverCert); - DBGPRINTF("imczmq: server public key is %s...\n", server_key); + DBGPRINTF("omczmq: server public key is %s...\n", server_key); zsock_set_curve_serverkey (pData->sock, server_key); } @@ -619,7 +609,7 @@ CODESTARTfreeCnf free(inst->pszBindRuleset); free(inst->sockEndpoints); free(inst->topicList); - free(inst->connType); + free(inst->authType); free(inst->clientCertPath); free(inst->serverCertPath); inst_r = inst; diff --git a/contrib/omczmq/README b/contrib/omczmq/README index ad56f888e..2d6782a22 100644 --- a/contrib/omczmq/README +++ b/contrib/omczmq/README @@ -13,10 +13,10 @@ action( name="curve_server_socket" type="omczmq" endpoints="tcp://some.server.com:24445" - socktype="PUB" - conntype="CURVECLIENT" - curveclientcert="/etc/curve.d/example_curve_client_cert" - curveservercert="/etc/curve.d/example_curve_server_cert" + socktype="PUSH" + authtype="CURVECLIENT" + clientcertpath="/etc/curve.d/example_curve_client_cert" + servercertpath="/etc/curve.d/example_curve_server_cert" ) ------------------------------------------------------------------------------- @@ -26,14 +26,10 @@ name: name of this action type: type of action (omczmq for this plugin) endpoints: comma delimited list of zeromq endpoints (see zeromq documentation) socktype: zeromq socket type (currently supports PUSH and PUB) -conntype: - CLIENT - zeromq connect - SERVER - zeromq bind - CURVECLIENT - zeromq connect with curve encryption - CURVESERVER - zeromq bind with curve encryption -curveclientcert: +authtype: CURVECLIENT or CURVESERVER +clientcertpath: if CURVECLIENT, this client's cert if CURVESERVER, "*" for all, or a directory of allowed public certs -curveservercert: +servercertpath: if CURVECLIENT, the servers public cert you wish to connect to if CURVESERVER, this servers cert diff --git a/contrib/omczmq/omczmq.c b/contrib/omczmq/omczmq.c index 47488e9a2..e5651c659 100644 --- a/contrib/omczmq/omczmq.c +++ b/contrib/omczmq/omczmq.c @@ -53,7 +53,7 @@ typedef struct _instanceData { zcert_t *serverCert; char *sockEndpoints; int sockType; - char *connType; + char *authType; char *clientCertPath; char *serverCertPath; uchar *tplName; @@ -66,7 +66,7 @@ typedef struct wrkrInstanceData { static struct cnfparamdescr actpdescr[] = { { "endpoints", eCmdHdlrGetWord, 1 }, { "socktype", eCmdHdlrGetWord, 1 }, - { "conntype", eCmdHdlrGetWord, 0 }, + { "authtype", eCmdHdlrGetWord, 0 }, { "clientcertpath", eCmdHdlrGetWord, 0 }, { "servercertpath", eCmdHdlrGetWord, 0 }, { "template", eCmdHdlrGetWord, 0 } @@ -106,7 +106,7 @@ static rsRetVal initCZMQ(instanceData* pData) { bool is_server = false; /* if we are a CURVE server */ - if (!strcmp(pData->connType, "CURVESERVER")) { + if (!strcmp(pData->authType, "CURVESERVER")) { DBGPRINTF("omczmq: we are a curve server...\n"); is_server = true; @@ -134,7 +134,7 @@ static rsRetVal initCZMQ(instanceData* pData) { } /* if we are a CURVE client */ - if (!strcmp(pData->connType, "CURVECLIENT")) { + if (!strcmp(pData->authType, "CURVECLIENT")) { DBGPRINTF("omczmq: we are a curve client...\n"); is_server = false; @@ -205,7 +205,7 @@ setInstParamDefaults(instanceData* pData) { pData->tplName = NULL; pData->sockType = -1; pData->authActor = NULL; - pData->connType = NULL; + pData->authType = NULL; pData->clientCertPath = NULL; pData->serverCertPath = NULL; } @@ -242,7 +242,7 @@ CODESTARTfreeInstance zcert_destroy(&pData->clientCert); free(pData->sockEndpoints); - free(pData->connType); + free(pData->authType); free(pData->clientCertPath); free(pData->serverCertPath); free(pData->tplName); @@ -312,10 +312,6 @@ CODESTARTnewActInst pData->sockType = ZMQ_PUSH; } - else if (!strcmp("DEALER", stringType)) { - pData->sockType = ZMQ_DEALER; - } - else { errmsg.LogError(0, RS_RET_CONFIG_ERROR, "omczmq: invalid socktype"); @@ -324,19 +320,18 @@ CODESTARTnewActInst } /* get the authentication type to use */ - else if (!strcmp(actpblk.descr[i].name, "conntype")) { - pData->connType = es_str2cstr(pvals[i].val.d.estr, NULL); + else if (!strcmp(actpblk.descr[i].name, "authtype")) { + pData->authType = es_str2cstr(pvals[i].val.d.estr, NULL); /* make sure defined type is supported */ - if ((inst->connType != NULL) && - strcmp("CURVESERVER", inst->connType) && - strcmp("CURVECLIENT", inst->connType) && - strcmp("CLIENT", inst->connType) && - strcmp("SERVER", inst->connType)) + if ((pData->authType != NULL) && + strcmp("CURVESERVER", pData->authType) && + strcmp("CURVECLIENT", pData->authType)) { + errmsg.LogError(0, RS_RET_CONFIG_ERROR, - "omczmq: %s is not a valid connType", - pData->connType); + "omczmq: %s is not a valid authType", + pData->authType); ABORT_FINALIZE(RS_RET_CONFIG_ERROR); } }