Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map addresses back to hostnames #102

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Conversation

RoganDawes
Copy link

This code provides a basis for mapping IP addresses (so far, only really tested with IPv4, but I think that IPv6 may also work).

See #23

This implementation establishes a new subsystem "rdns" (for reverse dns), which can be configured with a path to a fifo. Supplying "ad.dr.e.ss hostname" entries (one per line) will populate a hashtable, from which these mappings can subsequently be looked up by e.g. http-connect.c (or the socksX.c files, but this will require more sophisticated coding to create the appropriate socks messages with hostnames rather than addresses).

The implementation in http-connect has been omitted, as it is not clear to me how to establish a link between the rdns subsystem and the redsocks subsystem to allow calls to get_hostname_for_addr(). Advice on this would be appreciated.

Entries written to the designated input pipe are parsed as if it were a hosts file,
although only the first hostname per line is used.

As long as the fifo is held open, the contents of the mapping will remain intact.
Should the fifo be closed, the mapping will be cleared. This allows simple management
of the size of the hostname cache, simply by closing and reopening the fifo periodically.

A sample rdns config stanza would look something like:

rdns {
	fifo = "/tmp/redsocks_dns.fifo";
}
This prevent duplicate functions being declared if rdns.h is included by another file
Only works for http-connect upstream at the moment.
@RoganDawes
Copy link
Author

I have updated my branch with a very rudimentary/hackish implementation for http-connect.

I'm sure I have done several things wrong, for instance, using a single hostnames hashtable, even though the rdns subsystem could be instantiated multiple times, etc, etc. But as a proof of concept, it works :-)

I'd appreciate feedback and improvements to get it up to standard for inclusion.

@darkk darkk force-pushed the master branch 6 times, most recently from 7fa694d to 5df6a30 Compare February 1, 2018 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant