Added dummy proxy implementation, moved client, added main Makefile.
15
guacamole/Makefile
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
.PHONY: client proxy clean
|
||||
|
||||
all: client proxy
|
||||
|
||||
client:
|
||||
$(MAKE) -C client all
|
||||
|
||||
proxy:
|
||||
$(MAKE) -C proxy all
|
||||
|
||||
clean:
|
||||
$(MAKE) -C client clean
|
||||
$(MAKE) -C proxy clean
|
||||
|
11
guacamole/client/Makefile
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
.PHONY: client clean
|
||||
|
||||
all: client
|
||||
|
||||
client:
|
||||
ant war
|
||||
|
||||
clean:
|
||||
ant clean
|
||||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 208 B After Width: | Height: | Size: 208 B |
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 6.4 KiB |
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 6.4 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 766 B After Width: | Height: | Size: 766 B |
Before Width: | Height: | Size: 71 B After Width: | Height: | Size: 71 B |
Before Width: | Height: | Size: 72 B After Width: | Height: | Size: 72 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
20
guacamole/proxy/Makefile
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
all: guacd
|
||||
|
||||
guacd: daemon.o proxy.o
|
||||
$(CC) daemon.o proxy.o -o guacd
|
||||
|
||||
proxy.o: proxy.c proxy.h
|
||||
$(CC) -c -ansi -pedantic proxy.c
|
||||
|
||||
daemon.o: daemon.c proxy.h
|
||||
$(CC) -c -ansi -pedantic daemon.c
|
||||
|
||||
clean:
|
||||
$(RM) *.o guacd
|
||||
|
||||
distclean: clean
|
||||
$(RM) *~
|
||||
|
96
guacamole/proxy/daemon.c
Normal file
@@ -0,0 +1,96 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include "proxy.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
/* Server */
|
||||
int socket_fd;
|
||||
struct sockaddr_in server_addr;
|
||||
|
||||
/* Client */
|
||||
struct sockaddr_in client_addr;
|
||||
unsigned int client_addr_len;
|
||||
int connected_socket_fd;
|
||||
pid_t proxy_pid ;
|
||||
|
||||
/* Get binding address */
|
||||
memset(&server_addr, 0, sizeof(server_addr)); /* Zero struct */
|
||||
server_addr.sin_family = AF_INET;
|
||||
server_addr.sin_addr.s_addr = INADDR_ANY;
|
||||
server_addr.sin_port = htons(1234);
|
||||
|
||||
/* Get socket */
|
||||
socket_fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (socket_fd < 0) {
|
||||
perror("Error opening socket");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Bind socket to address */
|
||||
if (bind(socket_fd, (struct sockaddr*) &server_addr,
|
||||
sizeof(server_addr)) < 0) {
|
||||
perror("Error binding socket");
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* Daemon loop */
|
||||
for (;;) {
|
||||
|
||||
fprintf(stderr, "Listening...\n");
|
||||
|
||||
/* Listen for connections */
|
||||
if (listen(socket_fd, 5) < 0) {
|
||||
perror("Error listening on socket");
|
||||
return 3;
|
||||
}
|
||||
|
||||
/* Accept connection */
|
||||
client_addr_len = sizeof(client_addr);
|
||||
connected_socket_fd = accept(socket_fd, (struct sockaddr*) &client_addr, &client_addr_len);
|
||||
if (connected_socket_fd < 0) {
|
||||
perror("Error accepting client");
|
||||
return 3;
|
||||
}
|
||||
|
||||
/* Fork proxy */
|
||||
proxy_pid = fork();
|
||||
if (proxy_pid < 0) {
|
||||
perror("Could not fork child");
|
||||
}
|
||||
|
||||
/* In child ... */
|
||||
else if (proxy_pid == 0) {
|
||||
proxy(connected_socket_fd);
|
||||
|
||||
/* Close socket */
|
||||
if (close(connected_socket_fd) < 0) {
|
||||
perror("Error closing connection");
|
||||
return 3;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Child exiting.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
else
|
||||
fprintf(stderr, "Child forked.\n");
|
||||
|
||||
}
|
||||
|
||||
/* Close socket */
|
||||
if (close(socket_fd) < 0) {
|
||||
perror("Error closing socket");
|
||||
return 3;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
11
guacamole/proxy/proxy.c
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "proxy.h"
|
||||
|
||||
void proxy(int client_fd) {
|
||||
|
||||
write(client_fd, "name:hello;size:1024,768;error:Test finished.;", 46);
|
||||
|
||||
}
|
||||
|
6
guacamole/proxy/proxy.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef _PROXY_H_
|
||||
#define _PROXY_H
|
||||
|
||||
void proxy(int client_fd);
|
||||
|
||||
#endif
|