Changeset 431

Show
Ignore:
Timestamp:
02/06/05 13:14:58 (8 years ago)
Author:
minaguib
Message:

Implemented captive DNS, including new "dnsserver" thread and redirection iptables rules

Location:
branches/CaptiveDNS/wifidog
Files:
2 added
7 modified

Legend:

Unmodified
Added
Removed
  • branches/CaptiveDNS/wifidog/ChangeLog

    r429 r431  
    11# $Header$ 
     2 
     32005-02-06 Mina Naguib <mina@ilesansfil.org> 
     4        * Implemented captive DNS, including new "dnsserver" thread and redirection 
     5        iptables rules 
    26 
    372005-02-04 Mina Naguib <mina@ilesansfil.org> 
  • branches/CaptiveDNS/wifidog/src/Makefile.am

    r274 r431  
    2323        wdctl_thread.c \ 
    2424        ping_thread.c \ 
     25        dnsserver_thread.c \ 
    2526        httpd_thread.c 
    2627 
     
    4041        wdctl.h \ 
    4142        ping_thread.h \ 
     43        dnsserver_thread.h \ 
    4244        httpd_thread.h 
    4345 
  • branches/CaptiveDNS/wifidog/src/conf.c

    r424 r431  
    8585        oSyslogFacility, 
    8686        oFirewallRule, 
    87         oFirewallRuleSet 
     87        oFirewallRuleSet, 
     88        oDNSServerPort 
    8889} OpCodes; 
    8990 
     
    102103        { "gatewayaddress",     oGatewayAddress }, 
    103104        { "gatewayport",        oGatewayPort }, 
     105        { "dnsserverport",        oDNSServerPort }, 
    104106        { "authserver",         oAuthServer }, 
    105107        { "authservmaxtries",   oAuthServMaxTries }, 
     
    149151        config.gw_address = NULL; 
    150152        config.gw_port = DEFAULT_GATEWAYPORT; 
     153        config.dnsserver_port = DEFAULT_DNSSERVERPORT; 
    151154        config.auth_servers = NULL; 
    152155        config.authserv_maxtries = DEFAULT_AUTHSERVMAXTRIES; 
     
    640643                                        sscanf(p1, "%d", &config.gw_port); 
    641644                                        break; 
     645                                case oDNSServerPort: 
     646                                        sscanf(p1, "%d", &config.dnsserver_port); 
     647                                        break; 
    642648                                case oAuthServer: 
    643649                                        parse_auth_server(fd, filename, 
  • branches/CaptiveDNS/wifidog/src/conf.h

    r290 r431  
    3636#define DEFAULT_GATEWAYID "default" 
    3737#define DEFAULT_GATEWAYPORT 2060 
     38#define DEFAULT_DNSSERVERPORT 5353 
    3839#define DEFAULT_HTTPDNAME "WiFiDog" 
    3940#define DEFAULT_CLIENTTIMEOUT 5 
     
    118119                                     logging */ 
    119120    t_firewall_ruleset  *rulesets;      /**< @brief firewall rules */ 
     121    int dnsserver_port;         /**< @brief Port the fake dns server will run on */ 
    120122} s_config; 
    121123 
  • branches/CaptiveDNS/wifidog/src/fw_iptables.c

    r424 r431  
    205205    iptables_do_command("-t nat -N " TABLE_WIFIDOG_UNKNOWN); 
    206206    iptables_do_command("-t nat -A " TABLE_WIFIDOG_UNKNOWN " -j " TABLE_WIFIDOG_AUTHSERVERS); 
     207    iptables_do_command("-t nat -A " TABLE_WIFIDOG_UNKNOWN " -p udp --dport 53 -j REDIRECT --to-ports %d", config->dnsserver_port); 
     208    iptables_do_command("-t nat -A " TABLE_WIFIDOG_UNKNOWN " -p tcp --dport 80 -j REDIRECT --to-ports %d", config->gw_port); 
    207209    iptables_do_command("-t nat -A " TABLE_WIFIDOG_UNKNOWN " -d %s -j ACCEPT", config->gw_address); 
    208210 
     
    212214    iptables_load_ruleset("global", TABLE_WIFIDOG_UNKNOWN); 
    213215    iptables_load_ruleset("unknown-users", TABLE_WIFIDOG_UNKNOWN); 
    214     LOCK_CONFIG(); 
    215  
    216     /* XXX If there's a rule in global for port 80, it overrides this. */ 
    217     iptables_do_command("-t nat -A " TABLE_WIFIDOG_UNKNOWN " -p tcp --dport 80 -j REDIRECT --to-ports %d", config->gw_port); 
    218     UNLOCK_CONFIG(); 
     216 
    219217    iptables_do_command("-t nat -A " TABLE_WIFIDOG_UNKNOWN " -j DROP"); 
    220218 
  • branches/CaptiveDNS/wifidog/src/gateway.c

    r422 r431  
    5858#include "ping_thread.h" 
    5959#include "httpd_thread.h" 
     60#include "dnsserver_thread.h" 
    6061#include "util.h" 
    6162 
     
    214215        /* start heartbeat thread */ 
    215216        pthread_create(&tid, NULL, (void *)thread_ping, NULL); 
     217        pthread_detach(tid); 
     218         
     219        /* start dnsserver thread */ 
     220        pthread_create(&tid, NULL, (void *)thread_dnsserver, NULL); 
    216221        pthread_detach(tid); 
    217222         
  • branches/CaptiveDNS/wifidog/wifidog.conf

    r422 r431  
    9393# GatewayPort 2060 
    9494 
     95# Parameter: DNSServerPort 
     96# Default: 5353 
     97# Optional 
     98# 
     99# Fake DNS server listens on this port 
     100# DNSServerPort 5353 
     101 
    95102# Parameter: HTTPDName 
    96103# Default: WiFiDog