is useful is unclear but it turned out to be easy to do.
* time to time so that we detect broken connections reasonably quickly. The
* server just ignores these bytes.
*/
* time to time so that we detect broken connections reasonably quickly. The
* server just ignores these bytes.
*/
+
+ /** @brief Protocol version */
+ int protocol;
};
/* Forward declarations ******************************************************/
};
/* Forward declarations ******************************************************/
disorder_eclient_close(c);
return;
}
disorder_eclient_close(c);
return;
}
+ switch(nrvec) {
+ case 1:
+ protocol = "1";
+ algorithm = "sha1";
+ challenge = *rvec++;
+ break;
+ case 2:
+ protocol = "1";
+ algorithm = *rvec++;
+ challenge = *rvec++;
+ break;
+ case 3:
+ protocol = *rvec++;
+ algorithm = *rvec++;
+ challenge = *rvec++;
+ break;
+ default:
protocol_error(c, op, c->rc, "%s: %s", c->ident, c->line);
disorder_eclient_close(c);
protocol_error(c, op, c->rc, "%s: %s", c->ident, c->line);
disorder_eclient_close(c);
- protocol = *rvec++;
- algorithm = *rvec++;
- challenge = *rvec++;
- if(strcmp(protocol, "2")) {
+ c->protocol = atoi(protocol);
+ if(c->protocol < 1 || c->protocol > 2) {
protocol_error(c, op, c->rc, "%s: %s", c->ident, c->line);
disorder_eclient_close(c);
protocol_error(c, op, c->rc, "%s: %s", c->ident, c->line);
disorder_eclient_close(c);
}
nonce = unhex(challenge, &nonce_len);
res = authhash(nonce, nonce_len, config->password, algorithm);
}
nonce = unhex(challenge, &nonce_len);
res = authhash(nonce, nonce_len, config->password, algorithm);
D(("string_response_callback"));
if(c->rc / 100 == 2) {
if(op->completed) {
D(("string_response_callback"));
if(c->rc / 100 == 2) {
if(op->completed) {
- char **rr = split(c->line + 4, 0, SPLIT_QUOTES, 0, 0);
-
- if(rr && *rr)
- ((disorder_eclient_string_response *)op->completed)(op->v, *rr);
- else
- protocol_error(c, op, c->rc, "%s: %s", c->ident, c->line);
+ if(c->protocol >= 2) {
+ char **rr = split(c->line + 4, 0, SPLIT_QUOTES, 0, 0);
+
+ if(rr && *rr)
+ ((disorder_eclient_string_response *)op->completed)(op->v, *rr);
+ else
+ protocol_error(c, op, c->rc, "%s: %s", c->ident, c->line);
+ } else
+ ((disorder_eclient_string_response *)op->completed)(op->v,
+ c->line + 4);
}
} else
protocol_error(c, op, c->rc, "%s: %s", c->ident, c->line);
}
} else
protocol_error(c, op, c->rc, "%s: %s", c->ident, c->line);