diff --git a/src/server/distrend.c b/src/server/distrend.c --- a/src/server/distrend.c +++ b/src/server/distrend.c @@ -85,6 +85,7 @@ int distrend_do_config(int argc, char *a int distrend_config_free(struct distrend_config *config); int distrend_handle_request(struct distrend_client *client, struct distren_request *req, void *reqdata, struct general_info *geninfo); + /* **************XML Functions**************** */ void update_general_info(struct general_info *geninfo); int import_general_info(struct general_info *general_info); @@ -210,6 +211,8 @@ int main(int argc, char *argv[]) int distrend_handle_request(struct distrend_client *client, struct distren_request *req, void *reqdata, struct general_info *geninfo) { size_t counter; + char *tmp_str; + char fixedbuf[32]; /* for response requests... if that makes any less sense ;-) */ struct distren_request *newreq; @@ -222,6 +225,30 @@ int distrend_handle_request(struct distr switch(req->type) { case DISTREN_REQUEST_VERSION: + if(strlen(PACKAGE_STRING) == req->len + && !strncmp(PACKAGE_STRING, reqdata, req->len)) + { + /** + The client and I claim to be of the same version of distren :-D + Now we will mark the client as valid. + */ + + } + else + { + /** + The client claims to be of a different version of distren. + Now we will just send a disconnect packet and disconnect the client. + */ + strncpy(fixedbuf, reqdata, 31); + fixedbuf[31] = '\0'; + if(req->len < 31) + fixedbuf[req->len] = '\0'; + + _distren_asprintf(&tmp_str, "You have tried to connect to a %s server when your client claims to be running %s. Bye ;-)\n", PACKAGE_STRING, fixedbuf); + distrend_send_disconnect(client, tmp_str); + } + distren_request_new(&newreq, strlen(VERSION), DISTREN_REQUEST_VERSION); distrend_client_write_request(client, newreq, VERSION); distren_request_free(newreq);