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 */ /* Connect instruction read */
if (result > 0 && strcmp(instruction.opcode, "connect") == 0) { if (result > 0) {
if (strcmp(instruction.opcode, "connect") == 0) {
/* Get protocol from message */ /* Get protocol from message */
char* protocol = instruction.argv[0]; char* protocol = instruction.argv[0];
@@ -116,8 +118,10 @@ guac_client* guac_get_client(int client_fd) {
/* Load client plugin */ /* Load client plugin */
client->client_plugin_handle = dlopen(protocol_lib, RTLD_LAZY); client->client_plugin_handle = dlopen(protocol_lib, RTLD_LAZY);
if (!(client->client_plugin_handle)) { if (!(client->client_plugin_handle)) {
fprintf(stderr, "Could not open client plugin for protocol \"%s\": %s\n", protocol, dlerror()); syslog(LOG_ERR, "Could not open client plugin for protocol \"%s\": %s\n", protocol, dlerror());
exit(EXIT_FAILURE); guac_send_error(io, "Could not load server-side client plugin.");
guac_free_instruction_data(&instruction);
return NULL;
} }
dlerror(); /* Clear errors */ 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"); alias.obj = dlsym(client->client_plugin_handle, "guac_client_init");
if ((error = dlerror()) != NULL) { if ((error = dlerror()) != NULL) {
fprintf(stderr, "Could not get guac_client_init in plugin: %s\n", error); syslog(LOG_ERR, "Could not get guac_client_init in plugin: %s\n", error);
exit(EXIT_FAILURE); guac_send_error(io, "Invalid server-side client plugin.");
guac_free_instruction_data(&instruction);
return NULL;
} }
/* Initialize client arguments */ /* Initialize client arguments */
argc = instruction.argc; argc = instruction.argc;
argv = instruction.argv; argv = instruction.argv;
break; if (alias.client_init(client, argc, argv) != 0) {
} guac_free_instruction_data(&instruction);
guac_send_error(io, "Error initializing server-side client.");
}
if (alias.client_init(client, argc, argv) != 0)
return NULL; return NULL;
}
guac_free_instruction_data(&instruction); guac_free_instruction_data(&instruction);
return client; 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; int connected_socket_fd;
/* Arguments */ /* Arguments */
int listen_port = -1; int listen_port = 4822; /* Default port */
int opt; int opt;
/* Parse arguments */ /* Parse arguments */
@@ -95,17 +95,11 @@ int main(int argc, char* argv[]) {
} }
} }
else { else {
fprintf(stderr, "USAGE: %s -l LISTENPORT\n", argv[0]); fprintf(stderr, "USAGE: %s [-l LISTENPORT]\n", argv[0]);
exit(EXIT_FAILURE); 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 */ /* Get binding address */
memset(&server_addr, 0, sizeof(server_addr)); /* Zero struct */ memset(&server_addr, 0, sizeof(server_addr)); /* Zero struct */
server_addr.sin_family = AF_INET; server_addr.sin_family = AF_INET;