# ADD BSC32 /nologo\r
LINK32=link.exe\r
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\r
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib libeay32.lib ssleay32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"d:\openssl\lib\vc"\r
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib libeay32.lib ssleay32.lib /nologo /subsystem:console /debug /machine:I386 /out:"Debug/tor.exe" /pdbtype:sept /libpath:"d:\openssl\lib\vc"\r
\r
!ENDIF \r
\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\src\or\connection_ap.c\r
-# End Source File\r
-# Begin Source File\r
-\r
SOURCE=..\..\src\or\connection_edge.c\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\src\or\connection_exit.c\r
+SOURCE=..\..\src\or\connection_or.c\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\src\or\connection_or.c\r
+SOURCE=..\..\src\or\cpuworker.c\r
# End Source File\r
# Begin Source File\r
\r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=..\..\src\or\dirserv.c\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=..\..\src\or\dns.c\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=..\..\src\or\routers.c\r
+SOURCE=..\..\src\or\router.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\src\or\routerlist.c\r
# End Source File\r
# Begin Source File\r
\r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=..\..\src\common\tortls.c\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=..\..\src\common\util.c\r
# End Source File\r
# End Group\r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=..\..\src\common\tortls.h\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=..\..\src\or\tree.h\r
# End Source File\r
# Begin Source File\r
int
tor_poll(struct pollfd *ufds, unsigned int nfds, int timeout)
{
- int idx, maxfd, fd;
+ unsigned int idx, maxfd, fd;
int r;
#ifdef MS_WINDOWS
int any_fds_set = 0;
/* $Id$ */
#include "../or/or.h"
+#ifdef MS_WINDOWS
+#define vsnprintf _vsnprintf
+#endif
struct logfile_t;
typedef struct logfile_t {
{
time_t t;
struct timeval now;
- int n;
+ size_t n;
buf_len -= 2; /* subtract 2 characters so we have room for \n\0 */
lenout = X509_NAME_get_text_by_NID(name, nid, buf, buflen);
if (lenout == -1)
goto error;
- if (strspn(buf, LEGAL_NICKNAME_CHARACTERS) != lenout) {
+ if (((int)strspn(buf, LEGAL_NICKNAME_CHARACTERS)) < lenout) {
log_fn(LOG_WARN, "Peer certificate nickname has illegal characters.");
goto error;
}
/* a wrapper for write(2) that makes sure to write all count bytes.
* Only use if fd is a blocking fd. */
int write_all(int fd, const char *buf, size_t count) {
- int written = 0;
+ size_t written = 0;
int result;
while(written != count) {
/* a wrapper for read(2) that makes sure to read all count bytes.
* Only use if fd is a blocking fd. */
int read_all(int fd, char *buf, size_t count) {
- int numread = 0;
+ size_t numread = 0;
int result;
while(numread != count) {
0. Else returns -1. */
int check_private_dir(const char *dirname, int create)
{
+ int r;
struct stat st;
if (stat(dirname, &st)) {
if (errno != ENOENT) {
return -1;
}
log(LOG_INFO, "Creating directory %s", dirname);
- if (mkdir(dirname, 0700)) {
+#ifdef MS_WINDOWS
+ r = mkdir(dirname);
+#else
+ r = mkdir(dirname, 0700);
+#endif
+ if (r) {
log(LOG_WARN, "Error creating directory %s: %s", dirname,
strerror(errno));
return -1;
log(LOG_WARN, "%s is not a directory", dirname);
return -1;
}
+#ifndef MS_WINDOWS
if (st.st_uid != getuid()) {
log(LOG_WARN, "%s is not owned by this UID (%d)", dirname, (int)getuid());
return -1;
return 0;
}
}
+#endif
return 0;
}
}
#else
/* defined(MS_WINDOWS) */
-void start_daemon(void) {}
+void start_daemon(char *cp) {}
void finish_daemon(void) {}
#endif
return -1;
}
+int tor_inet_aton(const char *c, struct in_addr* addr)
+{
+#ifndef MS_WINDOWS
+ /* XXXX WWWW Should be HAVE_INET_ATON */
+ return inet_aton(c, addr);
+#else
+ uint32_t r;
+ assert(c && addr);
+ if (strcmp(c, "255.255.255.255") == 0) {
+ addr->s_addr = 0xFFFFFFFFu;
+ return 1;
+ }
+ r = inet_addr(c);
+ if (r == INADDR_NONE)
+ return 0;
+ addr->s_addr = r;
+ return 1;
+#endif
+}
\ No newline at end of file
void write_pidfile(char *filename);
int switch_id(char *user, char *group);
+struct in_addr;
+int tor_inet_aton(const char *cp, struct in_addr *addr);
+
/* For stupid historical reasons, windows sockets have an independent set of
* errnos which they use as the fancy strikes them.
*/
log_fn(LOG_WARN,"socks5: offered methods don't include 'no auth'. Rejecting.");
req->replylen = 2; /* 2 bytes of response */
req->reply[0] = 5; /* socks5 reply */
- req->reply[1] = 0xFF; /* reject all methods */
+ req->reply[1] = '\xFF'; /* reject all methods */
return -1;
}
buf_remove_from_front(buf,2+nummethods);/* remove packet from buf */
extern or_options_t options; /* command-line and config-file options */
-static int relay_crypt(circuit_t *circ, cell_t *cell, char cell_direction,
+static int relay_crypt(circuit_t *circ, cell_t *cell, int cell_direction,
crypt_path_t **layer_hint, char *recognized);
static connection_t *relay_lookup_conn(circuit_t *circ, cell_t *cell, int cell_direction);
static void circuit_free_cpath_node(crypt_path_t *victim);
}
/* wrap this into receive_relay_cell one day */
-static int relay_crypt(circuit_t *circ, cell_t *cell, char cell_direction,
+static int relay_crypt(circuit_t *circ, cell_t *cell, int cell_direction,
crypt_path_t **layer_hint, char *recognized) {
crypt_path_t *thishop;
relay_header_t rh;
return -1;
}
- setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
+ setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (void*) &one, sizeof(one));
if(bind(s,(struct sockaddr *)&bindaddr,sizeof(bindaddr)) < 0) {
log_fn(LOG_WARN,"Could not bind to port %u: %s",bindport,strerror(errno));
if(options.ORPort) {
listener_close_if_present(CONN_TYPE_OR_LISTENER);
- if(connection_create_listener(options.ORBindAddress, options.ORPort,
+ if(connection_create_listener(options.ORBindAddress,
+ (uint16_t) options.ORPort,
CONN_TYPE_OR_LISTENER) < 0)
return -1;
}
if(options.DirPort) {
listener_close_if_present(CONN_TYPE_DIR_LISTENER);
- if(connection_create_listener(options.DirBindAddress, options.DirPort,
+ if(connection_create_listener(options.DirBindAddress,
+ (uint16_t) options.DirPort,
CONN_TYPE_DIR_LISTENER) < 0)
return -1;
}
if(options.SocksPort) {
listener_close_if_present(CONN_TYPE_AP_LISTENER);
- if(connection_create_listener(options.SocksBindAddress, options.SocksPort,
+ if(connection_create_listener(options.SocksBindAddress,
+ (uint16_t) options.SocksPort,
CONN_TYPE_AP_LISTENER) < 0)
return -1;
}
assert(address);
- if (inet_aton(address, &in)) {
+ if (tor_inet_aton(address, &in)) {
log_fn(LOG_DEBUG, "Using static address %s (%08lX)", address,
(unsigned long)ntohl(in.s_addr));
return ntohl(in.s_addr);
assert(address);
assert(val);
- if (inet_aton(address, &in))
+ if (tor_inet_aton(address, &in))
return;
search.address = (char*) address;
now = time(NULL);
#ifdef MS_WINDOWS
#include <io.h>
#include <process.h>
+#include <direct.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define snprintf _snprintf
* This is always in the range 0..1<<15-1.*/
/* bandwidth and receiver_bucket only used by ORs in OPEN state: */
- uint32_t bandwidth; /* connection bandwidth. */
+ int bandwidth; /* connection bandwidth. */
int receiver_bucket; /* when this hits 0, stop receiving. Every second we
* add 'bandwidth' to this, capping it at 10*bandwidth.
*/
== ADDR_POLICY_REJECTED;
}
+static time_t parse_time(const char *cp)
+{
+ struct tm st_tm;
+ /* XXXX WWWW should be HAVE_STRPTIME */
+#ifndef MS_WINDOWS
+ if (!strptime(cp, "%Y-%m-%d %H:%M:%S", &st_tm)) {
+ log_fn(LOG_WARN, "Published time was unparseable"); return 0;
+ }
+#else
+ unsigned int year=0, month=0, day=0, hour=100, minute=100, second=100;
+ if (scanf("%u-%u-%u %u:%u:%u", cp, &year, &month,
+ &day, &hour, &minute, &second) < 6) {
+ log_fn(LOG_WARN, "Published time was unparseable"); return 0;
+ }
+ if (year < 2000 || month < 1 || month > 12 || day < 1 || day > 31 ||
+ hour > 24 || minute > 61 || second > 62) {
+ log_fn(LOG_WARN, "Published time was nonsensical"); return 0;
+ }
+ st_tm.tm_year = year;
+ st_tm.tm_mon = month;
+ st_tm.tm_mday = day;
+ st_tm.tm_hour = hour;
+ st_tm.tm_min = minute;
+ st_tm.tm_sec = second;
+#endif
+ return tor_timegm(&st_tm);
+
+}
+
+
/* Helper function: parse a directory from 's' and, when done, store the
* resulting routerlist in *dest, freeing the old value if necessary.
* If pkey is provided, we check the directory signature with pkey.
char signed_digest[128];
routerlist_t *new_dir = NULL;
char *versions = NULL;
- struct tm published;
time_t published_on;
char *good_nickname_lst[1024];
int n_good_nicknames = 0;
}
assert(tok->n_args == 1);
- if (!strptime(tok->args[0], "%Y-%m-%d %H:%M:%S", &published)) {
- log_fn(LOG_WARN, "Published time was unparseable"); goto err;
+ if (!(published_on = parse_time(tok->args[0]))) {
+ goto err;
}
- published_on = tor_timegm(&published);
if (!(tok = find_first_by_keyword(tokens, K_RECOMMENDED_SOFTWARE))) {
log_fn(LOG_WARN, "Missing recommended-software line from directory.");
char digest[128];
smartlist_t *tokens = NULL, *exit_policy_tokens = NULL;
directory_token_t *tok;
- struct tm published;
int t, i;
int ports_set, bw_set;
log_fn(LOG_WARN, "Missing published time"); goto err;
}
assert(tok->n_args == 1);
- if (!strptime(tok->args[0], "%Y-%m-%d %H:%M:%S", &published)) {
- log_fn(LOG_WARN, "Published time was unparseable"); goto err;
- }
- router->published_on = tor_timegm(&published);
-
+ if (!(router->published_on = parse_time(tok->args[0])))
+ goto err;
if (!(tok = find_first_by_keyword(tokens, K_ONION_KEY))) {
log_fn(LOG_WARN, "Missing onion key"); goto err;
if (strcmp(address, "*") == 0) {
newe->addr = 0;
- } else if (inet_aton(address, &in) != 0) {
+ } else if (tor_inet_aton(address, &in) != 0) {
newe->addr = ntohl(in.s_addr);
} else {
log_fn(LOG_WARN, "Malformed IP %s in exit policy; rejecting.",
if (!*endptr) {
/* strtol handled the whole mask. */
newe->msk = ~((1<<(32-bits))-1);
- } else if (inet_aton(mask, &in) != 0) {
+ } else if (tor_inet_aton(mask, &in) != 0) {
newe->msk = ntohl(in.s_addr);
} else {
log_fn(LOG_WARN, "Malformed mask %s on exit policy; rejecting.",
newe->prt_max = 65535;
} else {
endptr = NULL;
- newe->prt_min = strtol(port, &endptr, 10);
+ newe->prt_min = (uint16_t) strtol(port, &endptr, 10);
if (*endptr == '-') {
port = endptr+1;
endptr = NULL;
- newe->prt_max = strtol(port, &endptr, 10);
+ newe->prt_max = (uint16_t) strtol(port, &endptr, 10);
if (*endptr) {
log_fn(LOG_WARN, "Malformed port %s on exit policy; rejecting.",
port);
/* Version number of package */
#define VERSION "0.0.2pre6"
+
+/* XXXX WWWW */
+#define CONFDIR ""
\ No newline at end of file