# PROP Ignore_Export_Lib 0\r
# PROP Target_Dir ""\r
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c\r
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\src\win32" /I "D:\openssl\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c\r
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\src\win32" /I "D:\openssl\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c\r
# ADD BASE RSC /l 0x409 /d "_DEBUG"\r
# ADD RSC /l 0x409 /d "_DEBUG"\r
BSC32=bscmake.exe\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\src\or\circuit.c\r
+SOURCE=..\..\src\or\circuitbuild.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\src\or\circuitlist.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\src\or\circuituse.c\r
# End Source File\r
# Begin Source File\r
\r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=..\..\src\or\relay.c\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=..\..\src\or\rendclient.c\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=..\..\src\or\routerparse.c\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=..\..\src\or\tor_main.c\r
# End Source File\r
# Begin Source File\r
#include "orconfig.h"
#include "fakepoll.h"
+#define MAXCONNECTIONS 10000 /* XXXX copied from or.h */
+#define FD_SETSIZE MAXCONNECTIONS
+
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
}
#else
-#define FD_SETSIZE MAXCONNECTIONS
-
int
tor_poll(struct pollfd *ufds, unsigned int nfds, int timeout)
{
}
}
+#ifndef MS_WINDOWS
+struct tor_mutex_t {
+};
+tor_mutex_t *tor_mutex_new(void) { return NULL; }
+void tor_mutex_acquire(tor_mutex_t *m) { }
+void tor_mutex_release(tor_mutex_t *m) { }
+void tor_mutex_free(tor_mutex_t *m) { }
+#else
+struct tor_mutex_t {
+ HANDLE handle;
+};
+tor_mutex_t *tor_mutex_new(void)
+{
+ tor_mutex_t *m;
+ m = tor_malloc_zero(sizeof(tor_mutex_t));
+ m->handle = CreateMutex(NULL, FALSE, NULL);
+ tor_assert(m->handle != NULL);
+ return m;
+}
+void tor_mutex_free(tor_mutex_t *m)
+{
+ CloseHandle(m->handle);
+ tor_free(m);
+}
+void tor_mutex_acquire(tor_mutex_t *m)
+{
+ DWORD r;
+ r = WaitForSingleObject(m->handle, INFINITE);
+ switch (r) {
+ case WAIT_ABANDONED: /* holding thread exited. */
+ case WAIT_OBJECT_0: /* we got the mutex normally. */
+ break;
+ case WAIT_TIMEOUT: /* Should never happen. */
+ tor_assert(0);
+ break;
+ case WAIT_FAILED:
+ log_fn(LOG_WARN, "Failed to acquire mutex: %d", GetLastError());
+ }
+}
+void tor_mutex_release(tor_mutex_t *m)
+{
+ BOOL r;
+ r = ReleaseMutex(m->handle);
+ if (!r) {
+ log_fn(LOG_WARN, "Failed to release mutex: %d", GetLastError());
+ }
+}
+
+#endif
+
/*
Local Variables:
mode:c
int spawn_func(int (*func)(void *), void *data);
void spawn_exit();
+/* Because we use threads instead of processes on Windows, we need locking on Windows.
+ * On Unixy platforms, these functions are no-ops. */
+typedef struct tor_mutex_t tor_mutex_t;
+tor_mutex_t *tor_mutex_new(void);
+void tor_mutex_acquire(tor_mutex_t *m);
+void tor_mutex_release(tor_mutex_t *m);
+void tor_mutex_free(tor_mutex_t *m);
+
int tor_socketpair(int family, int type, int protocol, int fd[2]);
int is_internal_IP(uint32_t ip);
memset(&bindaddr,0,sizeof(struct sockaddr_in));
bindaddr.sin_family = AF_INET;
- bindaddr.sin_port = htons(usePort);
+ bindaddr.sin_port = htons((uint16_t) usePort);
if(tor_lookup_hostname(hostname, &(bindaddr.sin_addr.s_addr)) != 0) {
log_fn(LOG_WARN,"Can't resolve BindAddress %s",hostname);
tor_free(hostname);
connection_free_all(); /* so the child doesn't hold the parent's fd's open */
#endif
- /* XXXX WINDOWS lock here. */
- onion_key = crypto_pk_dup_key(get_onion_key());
- if (get_previous_onion_key())
- last_onion_key = crypto_pk_dup_key(get_previous_onion_key());
+ dup_onion_keys(&onion_key, &last_onion_key);
for(;;) {
time_t get_onion_key_set_at(void);
void set_identity_key(crypto_pk_env_t *k);
crypto_pk_env_t *get_identity_key(void);
+void dup_onion_keys(crypto_pk_env_t **key, crypto_pk_env_t **last);
int init_keys(void);
crypto_pk_env_t *init_key_from_file(const char *fname);
void rotate_onion_key(void);
/** Private keys for this OR. There is also an SSL key managed by tortls.c.
*/
+static tor_mutex_t *key_lock=NULL;
static time_t onionkey_set_at=0; /* When was onionkey last changed? */
static crypto_pk_env_t *onionkey=NULL;
static crypto_pk_env_t *lastonionkey=NULL;
* to update onionkey correctly, call rotate_onion_key().
*/
void set_onion_key(crypto_pk_env_t *k) {
+ tor_mutex_acquire(key_lock);
onionkey = k;
onionkey_set_at = time(NULL);
+ tor_mutex_release(key_lock);
}
/** Return the current onion key. Requires that the onion key has been
return lastonionkey;
}
+void dup_onion_keys(crypto_pk_env_t **key, crypto_pk_env_t **last)
+{
+ tor_assert(key && last);
+ tor_mutex_acquire(key_lock);
+ *key = crypto_pk_dup_key(onionkey);
+ if (lastonionkey)
+ *last = crypto_pk_dup_key(lastonionkey);
+ else
+ *last = NULL;
+ tor_mutex_release(key_lock);
+}
+
/** Return the time when the onion key was last set. This is either the time
* when the process launched, or the time of the most recent key rotation since
* the process launched.
log(LOG_ERR, "Couldn't write generated key to %s.", fname);
goto error;
}
+ tor_mutex_acquire(key_lock);
if (lastonionkey)
crypto_free_pk_env(lastonionkey);
- /* XXXX WINDOWS on windows, we need to protect this next bit with a lock.
- */
log_fn(LOG_INFO, "Rotating onion key");
lastonionkey = onionkey;
set_onion_key(prkey);
+ tor_mutex_release(key_lock);
return;
error:
log_fn(LOG_WARN, "Couldn't rotate onion key.");
const char *tmp, *mydesc;
crypto_pk_env_t *prkey;
+ if (!key_lock)
+ key_lock = tor_mutex_new();
+
/* OP's don't need keys. Just initialize the TLS context.*/
if (!options.ORPort) {
tor_assert(!options.DirPort);
ri->socks_port = options.SocksPort;
ri->dir_port = options.DirPort;
ri->published_on = time(NULL);
- ri->onion_pkey = crypto_pk_dup_key(get_onion_key());
+ ri->onion_pkey = crypto_pk_dup_key(get_onion_key()); /* must invoke from main thread */
ri->identity_pkey = crypto_pk_dup_key(get_identity_key());
get_platform_str(platform, sizeof(platform));
ri->platform = tor_strdup(platform);
/* The size of a `uint8_t', as computed by sizeof. */
#undef SIZEOF_UINT8_T
+/* The size of a `void *', as computed by sizeof. */
+#define SIZEOF_VOID_P 4
+
/* The size of a `__int64', as computed by sizeof. */
#define SIZEOF___INT64 8
#define UNALIGNED_INT_ACCESS_OK
/* Version number of package */
-#define VERSION "0.0.6"
+#define VERSION "0.0.7rc1-cvs"