parent
d196719c63
commit
563d1ee2ea
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
[[ -f src.a ]] && rm src.a
|
||||
find ./ -type f | grep -E '\.o$' | xargs -I'{}' rm '{}'
|
||||
find ./obj -type f | grep -E '\.o$' | xargs -I'{}' rm '{}'
|
||||
|
@ -1,7 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
//extern const char* g_server_name;
|
||||
|
||||
#include "app_args.h"
|
||||
extern struct app_args* g_server;
|
||||
|
||||
|
@ -0,0 +1,20 @@
|
||||
#include "process.h"
|
||||
|
||||
struct process
|
||||
{
|
||||
int pid;
|
||||
int section;
|
||||
};
|
||||
|
||||
void process_start_section( int id )
|
||||
{
|
||||
}
|
||||
|
||||
void process_stop()
|
||||
{
|
||||
}
|
||||
|
||||
void process_wait_for_finished()
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
void process_start_section( int id );
|
||||
void process_stop();
|
||||
void process_wait_for_finished();
|
||||
|
@ -0,0 +1,53 @@
|
||||
#include "tor.h"
|
||||
|
||||
#include "model/server.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
int start_tor()
|
||||
{
|
||||
if( g_server->disable_tor ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Replace stdout and stderr with log file
|
||||
int log = open( "data/logs/tor.log", O_CREAT | O_RDWR | O_SYNC, 0644 );
|
||||
dup2( log, 1 );
|
||||
dup2( log, 2 );
|
||||
close(log);
|
||||
|
||||
mkdir( "data/tor", 0755 );
|
||||
chdir( "data/tor" );
|
||||
|
||||
char wd[512];
|
||||
getcwd( wd, sizeof(wd) );
|
||||
|
||||
FILE* f = fopen( "torrc", "w" );
|
||||
fprintf( f, "SOCKSPort %d\n", g_server->tor_socks_port );
|
||||
fprintf( f, "SOCKSPolicy accept 127.0.0.1/8\n" );
|
||||
fprintf( f, "SOCKSPolicy reject *\n" );
|
||||
fprintf( f, "Log notice stdout\n" );
|
||||
fprintf( f, "DataDirectory %s\n", wd );
|
||||
fprintf( f, "HiddenServiceDir %s/hidden_service\n", wd );
|
||||
fprintf( f, "HiddenServicePort 80 127.0.0.1:%d\n", g_server->port );
|
||||
fclose(f);
|
||||
|
||||
printf( "Starting tor...\n" );
|
||||
fflush(stdout);
|
||||
|
||||
static char *argv[] = {
|
||||
"/usr/bin/tor",
|
||||
"-f",
|
||||
"torrc"
|
||||
};
|
||||
execve( "/usr/bin/tor", argv, NULL );
|
||||
|
||||
printf( "Failed to start tor: %s\n", strerror(errno) );
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in new issue