|
|
|
@ -47,18 +47,26 @@ int main(int argc,char* argv[]) {
|
|
|
|
|
char preferred_transport = 'T';
|
|
|
|
|
struct sockaddr addr_struct;
|
|
|
|
|
int server_sock = create_local(preferred_local_network,preferred_transport,local_addr,local_port,&addr_struct);
|
|
|
|
|
int addrlen = sizeof(addr_struct);
|
|
|
|
|
int addrlen;
|
|
|
|
|
if (check_ip_ver(local_addr) == 4) {
|
|
|
|
|
addrlen = sizeof(struct sockaddr_in);
|
|
|
|
|
} else if (check_ip_ver(local_addr) == 6) {
|
|
|
|
|
addrlen = sizeof(struct sockaddr_in6);
|
|
|
|
|
} else {
|
|
|
|
|
exit(-7);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
listen(server_sock,50); /* Arbitrary number, change later */
|
|
|
|
|
|
|
|
|
|
printf("Listening on %s:%d\n",local_addr,local_port);
|
|
|
|
|
|
|
|
|
|
struct sockaddr remote_addr_struct;
|
|
|
|
|
while (1) {
|
|
|
|
|
int from_client = accept(server_sock,&addr_struct,(socklen_t *)&addrlen);
|
|
|
|
|
int to_server = create_remote(preferred_remote_network,preferred_transport,remote_addr,remote_port);
|
|
|
|
|
int to_server = create_remote(preferred_remote_network,preferred_transport,remote_addr,remote_port,&remote_addr_struct);
|
|
|
|
|
|
|
|
|
|
printf("Connection established to %s:%d\n",remote_addr,remote_port);
|
|
|
|
|
if (fork() == 0) {
|
|
|
|
|
|
|
|
|
|
/* fork returns 0 for a child, so we're in the child's execution
|
|
|
|
|
right now */
|
|
|
|
|
close(server_sock);
|
|
|
|
@ -71,8 +79,6 @@ int main(int argc,char* argv[]) {
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// recv(from_client,buffer,3000,0);
|
|
|
|
|
|
|
|
|
|