summaryrefslogtreecommitdiff
path: root/src/or/connection_edge.c
AgeCommit message (Collapse)Author
2011-10-19Merge remote-tracking branch 'origin/maint-0.2.2'Nick Mathewson
2011-10-19Fix crash when changing node restrictions with DNS lookup in progressNick Mathewson
Fixes bug 4259, bugfix on 0.2.2.25-alpha. Bugfix by "Tey'". Original message by submitter: Changing nodes restrictions using a controller while Tor is doing DNS resolution could makes Tor crashes (on WinXP at least). The problem can be repeated by trying to reach a non-existent domain using Tor: curl --socks4a 127.0.0.1:9050 inexistantdomain.ext .. and changing the ExitNodes parameter through the control port before Tor returns a DNS resolution error (of course, the following command won't work directly if the control port is password protected): echo SETCONF ExitNodes=TinyTurtle | nc -v 127.0.0.1 9051 Using a non-existent domain is needed to repeat the issue so that Tor takes a few seconds for resolving the domain (which allows us to change the configuration). Tor will crash while processing the configuration change. The bug is located in the addressmap_clear_excluded_trackexithosts method which iterates over the entries of the addresses map in order to check whether the changes made to the configuration will impact those entries. When a DNS resolving is in progress, the new_adress field of the associated entry will be set to NULL. The method doesn't expect this field to be NULL, hence the crash.
2011-10-11Stop using addr_port_lookup as an address splitting functionNick Mathewson
It's too risky to have a function where if you leave one parameter NULL, it splits up address:port strings, but if you set it, it does hostname resolution.
2011-10-11Change "reverse_lookup_name" functions to refer to "PTR_name"sNick Mathewson
Under the new convention, having a tor_addr.*lookup function that doesn't do hostname resolution is too close for comfort. I used this script here, and have made no other changes. s/tor_addr_parse_reverse_lookup_name/tor_addr_parse_PTR_name/g; s/tor_addr_to_reverse_lookup_name/tor_addr_to_PTR_name/g;
2011-10-11Fix names of functions that convert strings to addrsNick Mathewson
Now let's have "lookup" indicate that there can be a hostname resolution, and "parse" indicate that there wasn't. Previously, we had one "lookup" function that did resolution; four "parse" functions, half of which did resolution; and a "from_str()" function that didn't do resolution. That's confusing and error-prone! The code changes in this commit are exactly the result of this perl script, run under "perl -p -i.bak" : s/tor_addr_port_parse/tor_addr_port_lookup/g; s/parse_addr_port(?=[^_])/addr_port_lookup/g; s/tor_addr_from_str/tor_addr_parse/g; This patch leaves aton and pton alone: their naming convention and behavior is is determined by the sockets API. More renaming may be needed.
2011-10-03Fix compilation of 3335 and 3825 fixesNick Mathewson
In master, they ran into problems with the edge_conn/entry_conn split.
2011-10-03Merge remote-tracking branch 'rransom-tor/bug3335-v2'Nick Mathewson
Conflicts: src/or/connection_edge.c src/or/rendclient.c
2011-10-02Clear the timed_out flag when an HS connection attempt endsRobert Ransom
2011-09-24trivial whitespace changes, take twoRoger Dingledine
2011-09-24Trivial whitespace fixesNick Mathewson
2011-09-07Fix whitespace issues in patches merged today so farNick Mathewson
2011-09-07Merge remote-tracking branch 'public/split_entry_conn'Nick Mathewson
Conflicts: src/or/connection.c src/or/connection_edge.c src/or/connection_edge.h src/or/dnsserv.c Some of these were a little tricky, since they touched code that changed because of the prop171 fixes.
2011-09-06Merge remote-tracking branch 'origin/maint-0.2.2'Nick Mathewson
Conflicts: src/or/connection_edge.c Conflicted on a router->node transition; fix was easy.
2011-09-06Fix assertion in addressmap_clear_excluded_trackexithostsNick Mathewson
Fixes bug 3923; bugfix on 0.2.2.25-alpha; bugfix from 'laruldan' on trac.
2011-08-09Sticking a size_t into long generates a warn on winSebastian Hahn
2011-08-08Remove connection_edge_streams_are_compatibleRobert Ransom
It's dead code (not used anywhere by the current proposal 171 algorithm).
2011-08-08Fix handling of ISO_STREAMRobert Ransom
Now we track *which* stream with ISO_STREAM set is associated to a particular circuit, so that we won't think that stream is incompatible with its circuit and launch another one a second later, and we use that same field to mark circuits which have had an ISO_STREAM stream attached to them, so that we won't ever put a second stream on that circuit. Fixes bug 3695.
2011-08-06Fix log message typoRobert Ransom
2011-08-05Clear socks auth fields before freeNick Mathewson
2011-08-04Treat socks_request->{username,password} as non-NUL-terminatedNick Mathewson
They *are* non-NUL-terminated, after all (and they have to be, since the SOCKS5 spec allows them to contain embedded NULs. But the code to implement proposal 171 was copying them with tor_strdup and comparing them with strcmp_opt. Fix for bug on 3683; bug not present in any yet-released version.
2011-08-02Implement protocol-type isolation correctly.Nick Mathewson
Previously we'd just looked at the connection type, but that's always CONN_TYPE_AP. Instead, we should be looking at the type of the listener that created the connection. Spotted by rransom; fixes bug 3636.
2011-07-21Move entry-only fields from edge_connection_t to entry_connection_tNick Mathewson
Also, refactor the code accordingly.
2011-07-21Add a new type entry_connection_t for entry connectionsNick Mathewson
No fields have moved there yet; for now, it's just a placeholder type.
2011-07-21Improve log messages for optimistic data retryIan Goldberg
2011-07-20For accuracy, s/exit_allows_optimistic_data/may_use_optimistic_data/Nick Mathewson
2011-07-20Merge branch 'optimistic-client'Nick Mathewson
The conflicts are with the proposal 171 circuit isolation code, and they're all trivial: they're just a matter of both branches adding some unrelated code in the same places. Conflicts: src/or/circuituse.c src/or/connection.c
2011-07-19Take a smarter approach to clearing isolation infoNick Mathewson
Back when I added this logic in 20c0581a79, the rule was that whenever a circuit finished building, we cleared its isolation info. I did that so that we would still use the circuit even if all the streams that had previously led us to tentatively set its isolation info had closed. But there were problems with that approach: We could pretty easily get into a case where S1 had led us to launch C1 and S2 had led us to launch C2, but when C1 finished, we cleared its isolation and attached S2 first. Since C2 was still marked in a way that made S1 unattachable to it, we'd then launch another circuit needlessly. So instead, we try the following approach now: when a circuit is done building, we try to attach streams to it. If it remains unused after we try attaching streams, then we clear its isolation info, and try again to attach streams. Thanks to Sebastian for helping me figure this out.
2011-07-19Use socks username/password information in stream isolationNick Mathewson
2011-07-19Implement sensible isolation for tunneled directory connsNick Mathewson
One-hop dirconn streams all share a session group, and get the ISO_SESSIONGRP flag: they may share circuits with each other and nothing else. Anonymized dirconn streams get a new internal-use-only ISO_STREAM flag: they may not share circuits with anything, including each other.
2011-07-19Implement destaddr-based isolationNick Mathewson
The new candidate rule, which arma suggested and I like, is that the original address as received from the client connection or as rewritten by the controller is the address that counts.
2011-07-19Launch sufficient circuits to satisfy pending isolated streamsNick Mathewson
Our old "do we need to launch a circuit for stream S" logic was, more or less, that if we had a pending circuit that could handle S, we didn't need to launch a new one. But now that we have streams isolated from one another, we need something stronger here: It's possible that some pending C can handle either S1 or S2, but not both. This patch reuses the existing isolation logic for a simple solution: when we decide during circuit launching that some pending C would satisfy stream S1, we "hypothetically" mark C as though S1 had been connected to it. Now if S2 is incompatible with S1, it won't be something that can attach to C, and so we'll launch a new stream. When the circuit becomes OPEN for the first time (with no streams attached to it), we reset the circuit's isolation status. I'm not too sure about this part: I wanted some way to be sure that, if all streams that would have used a circuit die before the circuit is done, the circuit can still get used. But I worry that this approach could also lead to us launching too many circuits. Careful thought needed here.
2011-07-19Add a new isolation type and field: "nym epoch"Nick Mathewson
The "nym epoch" of a stream is defined as the number of times that NEWNYM had been called before the stream was opened. All streams are isolated by nym epoch. This feature should be redundant with existing signewnym stuff, but it provides a good belt-and-suspenders way for us to avoid ever letting any circuit type bypass signewnym.
2011-07-19Const-ify a few functionsNick Mathewson
2011-07-19(Unused) backend logic for stream isolationNick Mathewson
This patch adds fields to track how streams should be isolated, and ensures that those fields are set correctly. It also adds fields to track what streams can go on a circuit, and adds functions to see whether a streams can go on a circuit and update the circuit accordingly. Those functions aren't yet called.
2011-07-18Remember optimistically sent data until we have gotten a CONNECTEDNick Mathewson
Since we can retry failed streams under some circumstances, we need to be ready to send data queued on them.
2011-07-18Only use optimistic data with exits that support itNick Mathewson
This adds a little code complexity: we need to remember for each node whether it supports the right feature, and then check for each connection whether it's exiting at such a node. We store this in a flag in the edge_connection_t, and set that flag at link time.
2011-07-18Initial optimistic_client fixesNick Mathewson
- Conform to make check-spaces - Build without warnings from passing size_t to %d - Use connection_get_inbuf_len(), not buf_datalen (otherwise bufferevents won't work). - Don't log that we're using this feature at warn.
2011-07-18Implement the client side of optimistic data (proposal 174)Ian Goldberg
2011-07-15Fix a wide line. "Tradition!"Nick Mathewson
2011-07-15Remove compare_addr_to_node_policyNick Mathewson
Instead, use compare_tor_addr_to_node_policy everywhere. One advantage of this is that compare_tor_addr_to_node_policy can better distinguish 0.0.0.0 from "unknown", which caused a nasty bug with microdesc users.
2011-07-13Resolve a warning from the bug1666 branchNick Mathewson
2011-07-13Merge remote-tracking branch 'public/bug1666'Nick Mathewson
Conflicts: doc/spec/socks-extensions.txt src/or/buffers.c src/or/config.c src/or/connection_edge.c
2011-07-11Split connection_about_to_close_connection into separate functionsNick Mathewson
This patch does NOTHING but: - move code - add declarations and includes as needed to make the new code work - declare the new functions.
2011-07-07Kill redundant checks around routerset_contains_*()Nick Mathewson
All of the routerset_contains*() functions return 0 if their routerset_t argument is NULL. Therefore, there's no point in doing "if (ExcludeNodes && routerset_contains*(ExcludeNodes...))", for example. This patch fixes every instance of if (X && routerstatus_contains*(X,...)) Note that there are other patterns that _aren't_ redundant. For example, we *don't* want to change: if (EntryNodes && !routerstatus_contains(EntryNodes,...)) Fixes #2797. No bug here; just needless code.
2011-07-07Merge remote-tracking branch 'origin/maint-0.2.2'Nick Mathewson
2011-07-07Correctly send a SUCCEEDED event for rdns requestsSebastian Hahn
The issue was that we overlooked the possibility of reverse DNS success at the end of connection_ap_handshake_socks_resolved(). Issue discovered by katmagic, thanks!
2011-06-29Refactor fetch_from_buf_socks() to be greedyNick Mathewson
Previously, fetch_from_buf_socks() might return 0 if there was still data on the buffer and a subsequent call to fetch_from_buf_socks() would return 1. This was making some of the socks5 unit tests harder to write, and could potentially have caused misbehavior with some overly verbose SOCKS implementations. Now, fetch_from_buf_socks() does as much processing as it can, and returns 0 only if it really needs more data. This brings it into line with the evbuffer socks implementation.
2011-06-14Make the get_options() return constNick Mathewson
This lets us make a lot of other stuff const, allows the compiler to generate (slightly) better code, and will make me get slightly fewer patches from folks who stick mutable stuff into or_options_t. const: because not every input is an output!
2011-05-30Merge remote-tracking branch 'origin/maint-0.2.2'Nick Mathewson
The conflicts were mainly caused by the routerinfo->node transition. Conflicts: src/or/circuitbuild.c src/or/command.c src/or/connection_edge.c src/or/directory.c src/or/dirserv.c src/or/relay.c src/or/rendservice.c src/or/routerlist.c
2011-05-15Log descriptions of nodes, not just nicknames.Nick Mathewson
This patch introduces a few new functions in router.c to produce a more helpful description of a node than its nickame, and then tweaks nearly all log messages taking a nickname as an argument to call these functions instead. There are a few cases where I left the old log messages alone: in these cases, the nickname was that of an authority (whose nicknames are useful and unique), or the message already included an identity and/or an address. I might have missed a couple more too. This is a fix for bug 3045.