1
0
mirror of https://github.com/rofl0r/proxychains-ng synced 2026-05-14 09:32:35 +08:00
Commit Graph

6 Commits

  • hook close() to prevent rude programs like ssh to close our pipes
    those pipes are needed to talk with the dns-name allocator thread.
    
    closes #9
  • replace hostent lookup with better performing in-memory copy.
    the central dns resolver function proxy_gethostbyname() used
    to iterate over the gethostent() db (/etc/hosts) on each dns
    request.
    since this is not threadsafe, we synchronized access to it
    previously using mutexes. the parsing of this file is slow,
    and blocking all threads to do it even moreso.
    since gethostent_r() is only available on a few platforms,
    i decided to read the hostent db once and then use a quick
    in-memory lookup on further usage.
    
    + some further refactoring.
  • preliminary first fork-safe version
    instead of allocating memory in the child, we now use the allocator
    thread to do all the necessary allocations himself.
    additionally we provide a clean API to query the ip <-> dns mapping.
    these functions connect via a pipe to the allocator thread, and
    exchange messages.
    
    further cleanup is needed, but it seems to work so far.
    thread-safety is not yet guaranteed.
    
    closes #1
  • failed attempt to use shared memory for the ip <-> dns mapping
    this is in order to get irssi, which forks for DNS lookups,
    and similar programs, to work as intended.
    
    in a previous attempt i learned that shared memory created in a
    child process is not visible to the parent;
    in this attempt i spin off a thread from the parent which listens
    on a pipe and manages the shared memory allocation from the parent
    address-space. however this doesnt work as expected:
    memory allocated in the parent after the child forked is not visi-
    ble to the child as well.
    
    so what happens is: irssi starts a child process, the thread allocs
    memory and hands it to the child, the child attempts to write and
    segfaults. however irssi doesnt crash. since now the memory is
    already allocated, doing the dns lookup again will succeed.
    
    i.e. the dns lookup works now in irssi by luck.
    all but the first dns lookups will suceed.
    
    however this is not good enough for me to be satisfied, i commit
    this only for documentation purposes.