SENTINEL CONFIG SET */
| 3154 | |
| 3155 | /* SENTINEL CONFIG SET <option> */ |
| 3156 | void sentinelConfigSetCommand(client *c) { |
| 3157 | robj *o = c->argv[3]; |
| 3158 | robj *val = c->argv[4]; |
| 3159 | long long numval; |
| 3160 | int drop_conns = 0; |
| 3161 | |
| 3162 | if (!strcasecmp(o->ptr, "resolve-hostnames")) { |
| 3163 | if ((numval = yesnotoi(val->ptr)) == -1) goto badfmt; |
| 3164 | sentinel.resolve_hostnames = numval; |
| 3165 | } else if (!strcasecmp(o->ptr, "announce-hostnames")) { |
| 3166 | if ((numval = yesnotoi(val->ptr)) == -1) goto badfmt; |
| 3167 | sentinel.announce_hostnames = numval; |
| 3168 | } else if (!strcasecmp(o->ptr, "announce-ip")) { |
| 3169 | if (sentinel.announce_ip) sdsfree(sentinel.announce_ip); |
| 3170 | sentinel.announce_ip = sdsnew(val->ptr); |
| 3171 | } else if (!strcasecmp(o->ptr, "announce-port")) { |
| 3172 | if (getLongLongFromObject(val, &numval) == C_ERR || |
| 3173 | numval < 0 || numval > 65535) |
| 3174 | goto badfmt; |
| 3175 | sentinel.announce_port = numval; |
| 3176 | } else if (!strcasecmp(o->ptr, "sentinel-user")) { |
| 3177 | sdsfree(sentinel.sentinel_auth_user); |
| 3178 | sentinel.sentinel_auth_user = sdslen(val->ptr) == 0 ? |
| 3179 | NULL : sdsdup(val->ptr); |
| 3180 | drop_conns = 1; |
| 3181 | } else if (!strcasecmp(o->ptr, "sentinel-pass")) { |
| 3182 | sdsfree(sentinel.sentinel_auth_pass); |
| 3183 | sentinel.sentinel_auth_pass = sdslen(val->ptr) == 0 ? |
| 3184 | NULL : sdsdup(val->ptr); |
| 3185 | drop_conns = 1; |
| 3186 | } else { |
| 3187 | addReplyErrorFormat(c, "Invalid argument '%s' to SENTINEL CONFIG SET", |
| 3188 | (char *) o->ptr); |
| 3189 | return; |
| 3190 | } |
| 3191 | |
| 3192 | sentinelFlushConfig(); |
| 3193 | addReply(c, shared.ok); |
| 3194 | |
| 3195 | /* Drop Sentinel connections to initiate a reconnect if needed. */ |
| 3196 | if (drop_conns) |
| 3197 | sentinelDropConnections(); |
| 3198 | |
| 3199 | return; |
| 3200 | |
| 3201 | badfmt: |
| 3202 | addReplyErrorFormat(c, "Invalid value '%s' to SENTINEL CONFIG SET '%s'", |
| 3203 | (char *) val->ptr, (char *) o->ptr); |
| 3204 | } |
| 3205 | |
| 3206 | /* SENTINEL CONFIG GET <option> */ |
| 3207 | void sentinelConfigGetCommand(client *c) { |
no test coverage detected