diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-03-10 06:26:38 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-03-10 06:26:38 +0000 |
commit | d877aac5ad96528af9688b4e1ac05ce4242a6470 (patch) | |
tree | c917581a359bbd1b0c30a28c2b386e64b786f4d2 /src | |
parent | c230132562c744e5767f24aee05d81e5c99b7f39 (diff) | |
download | tor-d877aac5ad96528af9688b4e1ac05ce4242a6470.tar tor-d877aac5ad96528af9688b4e1ac05ce4242a6470.tar.gz |
Make windows version correct; initialize windows foolishness so that gethostbyname works.
svn:r1250
Diffstat (limited to 'src')
-rw-r--r-- | src/or/main.c | 32 | ||||
-rw-r--r-- | src/win32/orconfig.h | 2 |
2 files changed, 32 insertions, 2 deletions
diff --git a/src/or/main.c b/src/or/main.c index 766fcfb6b..e0777200c 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -695,12 +695,42 @@ static void dumpstats(int severity) { (int) (stats_n_bytes_read/stats_n_seconds_reading)); } +int network_init(void) +{ +#ifdef MS_WINDOWS + /* This silly exercise is necessary before windows will allow gethostbyname to work. + */ + WSADATA WSAData; + int r; + r = WSAStartup(0x101,&WSAData); + if (r) { + log_fn(LOG_WARN,"Error initializing windows network layer: code was %d",r); + return -1; + } + /* XXXX We should call WSACleanup on exit, I think. */ +#endif + return 0; +} + +void exit_function(void) +{ +#ifdef MS_WINDOWS + WSACleanup(); +#endif +} + int tor_main(int argc, char *argv[]) { /* give it somewhere to log to initially */ add_stream_log(LOG_INFO, "<stdout>", stdout); log_fn(LOG_WARN,"Tor v%s. This is experimental software. Do not use it if you need anonymity.",VERSION); + if (network_init()<0) { + log_fn(LOG_ERR,"Error initializing network; exiting."); + return 1; + } + atexit(exit_function); + if (init_from_config(argc,argv) < 0) return -1; @@ -708,7 +738,7 @@ int tor_main(int argc, char *argv[]) { if(geteuid()==0) log_fn(LOG_WARN,"You are running Tor as root. You don't need to, and you probably shouldn't."); #endif - + if(options.ORPort) { /* only spawn dns handlers if we're a router */ dns_init(); /* initialize the dns resolve tree, and spawn workers */ } diff --git a/src/win32/orconfig.h b/src/win32/orconfig.h index c8e089fb3..6fd90bf37 100644 --- a/src/win32/orconfig.h +++ b/src/win32/orconfig.h @@ -148,7 +148,7 @@ #define STDC_HEADERS /* Version number of package */ -#define VERSION "0.0.2pre6" +#define VERSION "0.0.2pre26" /* XXXX WWWW */ #define CONFDIR "" |