summaryrefslogtreecommitdiff
path: root/src/or/geoip.c
AgeCommit message (Collapse)Author
2018-07-05Move literally everything out of src/orNick Mathewson
This commit won't build yet -- it just puts everything in a slightly more logical place. The reasoning here is that "src/core" will hold the stuff that every (or nearly every) tor instance will need in order to do onion routing. Other features (including some necessary ones) will live in "src/feature". The "src/app" directory will hold the stuff needed to have Tor be an application you can actually run. This commit DOES NOT refactor the former contents of src/or into a logical set of acyclic libraries, or change any code at all. That will have to come in the future. We will continue to move things around and split them in the future, but I hope this lays a reasonable groundwork for doing so.
2018-07-03Return U64_PRINTF_ARG and U64_FORMATNick Mathewson
The standard is printf("%"PRIu64, x);
2018-06-28Fix paths for buffers.h; automated.Nick Mathewson
2018-06-28Extract time functionality into lib/wallclock and lib/timeNick Mathewson
2018-06-22Remove bloom filters, order statistics, and bitarrays from container.hNick Mathewson
2018-06-21Merge branch 'maint-0.3.4'Nick Mathewson
2018-06-20eol@eof is still the law in 0.3.4 :(Nick Mathewson
2018-06-20Merge branch 'maint-0.3.4'Nick Mathewson
2018-06-20Fix clang warnings introduced by 9f2b887c5d251b93ee9def708Nick Mathewson
2018-06-20Run rectify_include_paths.pyNick Mathewson
2018-06-20Update copyrights to 2018.Nick Mathewson
2018-06-04Avoid casting smartlist index implicitlyrl1987
2018-04-05Switch to use should_record_bridge_info()Neel Chauhan
Both in geoip_note_client_seen() and options_need_geoip_info(), switch from accessing the options directly to using the should_record_bridge_info() helper function. Fixes #25290 Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-03-15On geoip_free_all, reset geoip[6]_digest.Nick Mathewson
2018-02-05Merge remote-tracking branch 'dgoulet/ticket24902_029_05'Nick Mathewson
2018-02-05geoip: Make geoip_client_cache_total_allocation() return the counterDavid Goulet
The HT_FOREACH() is insanely heavy on the CPU and this is part of the fast path so make it return the nice memory size counter we added in 4d812e29b9b1ec88. Fixes #25148 Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-02-02Merge remote-tracking branch 'dgoulet/ticket24902_029_05'Nick Mathewson
2018-02-02Merge branch 'ticket25122_029_02' into ticket24902_029_05David Goulet
2018-02-02geoip: Add clientmap_entry_new() functionDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-02-02geoip: Increment and decrement functions for the geoip client cacheDavid Goulet
These functions protect againts over and underflow. They BUG() in case we overflow the counter. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-02-02geoip: Hook the client history cache into the OOM handlerDavid Goulet
If the cache is using 20% of our maximum allowed memory, clean 10% of it. Same behavior as the HS descriptor cache. Closes #25122 Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-01-30Merge branch 'ticket24902_029_05' into ticket24902_033_02David Goulet
2018-01-30dos: Clear connection tracked flag if geoip entry is removedDavid Goulet
Imagine this scenario. We had 10 connections over the 24h lifetime of a geoip cache entry. The lifetime of the entry has been reached so it is about to get freed but 2 connections remain for it. After the free, a third connection comes in thus making us create a new geoip entry for that address matching the 2 previous ones that are still alive. If they end up being closed, we'll have a concurrent count desynch from what the reality is. To mitigate this probably very rare scenario in practice, when we free a geoip entry and it has a concurrent count above 0, we'll go over all connections matching the address and clear out the tracked flag. So once they are closed, we don't try to decrement the count. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-01-30geoip: Remember client stats if DoS mitigation is enabledDavid Goulet
Make the geoip cache track client address if the DoS subsystem is enabled. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-01-25geoip: Add a lookup function for client map entryDavid Goulet
The upcoming DoS mitigation subsytem needs to keep information on a per-IP basis which is also what the geoip clientmap does. For another subsystem to access that clientmap, this commit adds a lookup function that returns the entry. For this, the clientmap_entry_t had to be moved to the header file. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-12-08Convert remaining function (mostly static) to new free styleNick Mathewson
2017-11-02Merge branch 'buf_for_stringbuffer_squashed'Nick Mathewson
2017-11-02Refactor geoip_get_dirreq_history to use buf_tNick Mathewson
2017-08-25New GETINFO target to check if geoip is loadedNick Mathewson
Closes ticket 23237.
2017-06-05Merge branch 'maint-0.3.0'Nick Mathewson
2017-06-05Merge branch 'maint-0.2.9' into maint-0.3.0Nick Mathewson
2017-06-05Merge branch 'maint-0.2.8' into maint-0.2.9Nick Mathewson
2017-06-05Merge branch 'maint-0.2.7-redux' into maint-0.2.8Nick Mathewson
2017-06-05Merge branch 'maint-0.2.5' into maint-0.2.6Nick Mathewson
2017-06-05Merge branch 'maint-0.2.4' into maint-0.2.5Nick Mathewson
2017-06-05Fix undefined behavior in geoip_parse_entry().Nick Mathewson
Fixes bug 22490; bugfix on 6a241ff3ffe7dc1 in 0.2.4.6-alpha. Found by teor using clang-5.0's AddressSanitizer stack-use-after-scope.
2017-03-15Run the copyright update script.Nick Mathewson
2017-03-09Remove fgets() compatbility function and related tests.Alexander Færøy
This patch removes the `tor_fgets()` wrapper around `fgets(3)` since it is no longer needed. The function was created due to inconsistency between the returned values of `fgets(3)` on different versions of Unix when using `fgets(3)` on non-blocking file descriptors, but with the recent changes in bug #21654 we switch from unbuffered to direct I/O on non-blocking file descriptors in our utility module. We continue to use `fgets(3)` directly in the geoip and dirserv module since this usage is considered safe. This patch also removes the test-case that was created to detect differences in the implementation of `fgets(3)` as well as the changes file since these changes was not included in any releases yet. See: https://bugs.torproject.org/21654
2017-03-01Use tor_fgets() instead of fgets().Alexander Færøy
This patch changes our use of fgets() to tor_fgets() for more consistent error handling across different versions of the C library.
2016-10-27Automated change to use smartlist_add_strdupovercaffeinated
Use the following coccinelle script to change uses of smartlist_add(sl, tor_strdup(str)) to smartlist_add_strdup(sl, string) (coccinelle script from nickm via bug 20048): @@ expression a; expression b; @@ - smartlist_add + smartlist_add_strdup (a, - tor_strdup( b - ) )
2016-10-17Write a bunch of module documentation.Nick Mathewson
This commit adds or improves the module-level documenation for: buffers.c circuitstats.c command.c connection_edge.c control.c cpuworker.c crypto_curve25519.c crypto_curve25519.h crypto_ed25519.c crypto_format.c dircollate.c dirserv.c dns.c dns_structs.h fp_pair.c geoip.c hibernate.c keypin.c ntmain.c onion.c onion_fast.c onion_ntor.c onion_tap.c periodic.c protover.c protover.h reasons.c rephist.c replaycache.c routerlist.c routerparse.c routerset.c statefile.c status.c tor_main.c workqueue.c In particular, I've tried to explain (for each documented module) what each module does, what's in it, what the big idea is, why it belongs in Tor, and who calls it. In a few cases, I've added TODO notes about refactoring opportunities. I've also renamed an argument, and fixed a few DOCDOC comments.
2016-07-28Fix all -Wshadow warnings on LinuxNick Mathewson
This is a partial fix for 18902.
2016-06-11Add the -Wextra-semi warning from clang, and fix the cases where it triggersNick Mathewson
2016-06-11Enable -Wnull-dereference (GCC >=6.1), and fix the easy casesNick Mathewson
This warning, IIUC, means that the compiler doesn't like it when it sees a NULL check _after_ we've already dereferenced the variable. In such cases, it considers itself free to eliminate the NULL check. There are a couple of tricky cases: One was the case related to the fact that tor_addr_to_in6() can return NULL if it gets a non-AF_INET6 address. The fix was to create a variant which asserts on the address type, and never returns NULL.
2016-02-27Update the copyright year.Nick Mathewson
2015-12-18Fix a null-pointer deref when writing geoip statsNick Mathewson
Found by coverity; CID 1327892.
2015-12-15Replace usage of INLINE with inlinecypherpunks
This patch was generated using; sed -i -e "s/\bINLINE\b/inline/" src/*/*.[ch] src/*/*/*.[ch]
2015-11-23fix two typos in commentsRoger Dingledine
2015-09-15Add tests for directory_handle_command_getReinaldo de Souza Jr
2015-02-03Merge branch 'bug6852'Nick Mathewson
Conflicts: src/or/status.c