Default port (4822) and working connect message

This commit is contained in:
Michael Jumper
2010-11-25 19:05:15 -08:00
parent bb1ed2172a
commit e392fb59b6
2 changed files with 43 additions and 39 deletions

View File

@@ -102,7 +102,9 @@ guac_client* guac_get_client(int client_fd) {
}
/* Connect instruction read */
if (result > 0 && strcmp(instruction.opcode, "connect") == 0) {
if (result > 0) {
if (strcmp(instruction.opcode, "connect") == 0) {
/* Get protocol from message */
char* protocol = instruction.argv[0];
@@ -116,8 +118,10 @@ guac_client* guac_get_client(int client_fd) {
/* Load client plugin */
client->client_plugin_handle = dlopen(protocol_lib, RTLD_LAZY);
if (!(client->client_plugin_handle)) {
fprintf(stderr, "Could not open client plugin for protocol \"%s\": %s\n", protocol, dlerror());
exit(EXIT_FAILURE);
syslog(LOG_ERR, "Could not open client plugin for protocol \"%s\": %s\n", protocol, dlerror());
guac_send_error(io, "Could not load server-side client plugin.");
guac_free_instruction_data(&instruction);
return NULL;
}
dlerror(); /* Clear errors */
@@ -126,26 +130,32 @@ guac_client* guac_get_client(int client_fd) {
alias.obj = dlsym(client->client_plugin_handle, "guac_client_init");
if ((error = dlerror()) != NULL) {
fprintf(stderr, "Could not get guac_client_init in plugin: %s\n", error);
exit(EXIT_FAILURE);
syslog(LOG_ERR, "Could not get guac_client_init in plugin: %s\n", error);
guac_send_error(io, "Invalid server-side client plugin.");
guac_free_instruction_data(&instruction);
return NULL;
}
/* Initialize client arguments */
argc = instruction.argc;
argv = instruction.argv;
break;
}
}
if (alias.client_init(client, argc, argv) != 0)
if (alias.client_init(client, argc, argv) != 0) {
guac_free_instruction_data(&instruction);
guac_send_error(io, "Error initializing server-side client.");
return NULL;
}
guac_free_instruction_data(&instruction);
return client;
} /* end if connect */
guac_free_instruction_data(&instruction);
}
}
}

View File

@@ -82,7 +82,7 @@ int main(int argc, char* argv[]) {
int connected_socket_fd;
/* Arguments */
int listen_port = -1;
int listen_port = 4822; /* Default port */
int opt;
/* Parse arguments */
@@ -95,17 +95,11 @@ int main(int argc, char* argv[]) {
}
}
else {
fprintf(stderr, "USAGE: %s -l LISTENPORT\n", argv[0]);
fprintf(stderr, "USAGE: %s [-l LISTENPORT]\n", argv[0]);
exit(EXIT_FAILURE);
}
}
/* Validate arguments */
if (listen_port < 0) {
fprintf(stderr, "The port to listen on must be specified.\n");
exit(EXIT_FAILURE);
}
/* Get binding address */
memset(&server_addr, 0, sizeof(server_addr)); /* Zero struct */
server_addr.sin_family = AF_INET;