def makeDefaultDnsmasqConfFile(restartDNSMasq=True):
     #Only write file if its a dreamplug
     #bluegiga captiveportal takes care of this automatically
     if Platform.getPlatform() == Platform.PLATFORM_LINUX_DREAMPLUG:
         try:
             ProcessExecutor.setCorrectBackhaulInterface()
             logger.info("writing dnsmasq file %s" % ClientURISettings.DNSMASQ_DEFAULT_FILE)         
             content = default_dnsmasq.CONTENT.replace("PROXIMUS_DNSMASQ_CONFIG_FILE", ClientURISettings.DNSMASQ_CONFIG_FILE).replace("PROXIMUS_DNS_INTERFACE", SystemWriter.getCurrentAccessPointInterface())            
             SystemWriter.writeFile(ClientURISettings.DNSMASQ_DEFAULT_FILE, content)
             if (restartDNSMasq):
                 ProcessExecutor.restartDNS()
                 
         except Exception as err:
             logger.error(err)
 def makeDnsmasqConfFile(restartDNSMasq=True):
     try:
         logger.info("writing dnsmasq.conf file %s" % ClientURISettings.DNSMASQ_CONFIG_FILE)      
                     
         range = "dhcp-range=192.168.45.50,192.168.45.150,1h"          
         leases = "dhcp-leasefile=%s" % (ClientURISettings.DNSMASQ_LEASES_FILE)
         config_dir = "conf-dir=/home/proximus/config/dnsmasq.d" 
         if Platform.getPlatform() == Platform.PLATFORM_LINUX_DREAMPLUG:
             pass 
         content = dnsmasq.CONTENT.replace("PROXIMUS_DHCP_RANGE", range).replace("PROXIMUS_DNS_LEASES_FILE", leases).replace("PROXIMUS_DNS_CONFIG_DIR", config_dir)
         SystemWriter.writeFile(ClientURISettings.DNSMASQ_CONFIG_FILE, content)           
         if (restartDNSMasq):
             ProcessExecutor.restartDNS()
     
     except Exception as err:
         logger.error(err)
Beispiel #3
0
 def ensureDNSMasqCorrect(campaign):
     needsDNSRestart = False
     
     try:
         if (campaign == None):
             correctDomains = []
         else:
             correctDomains = campaign.wifiCampaign.hotspotDomains
         
         DEFAULT_HOTSPOT = "hotspot_rule"
         DEFAULT_CAPTIVE = "captive_rule"
         
         if (campaign != None and int(campaign.wifiCampaign.hotspotMode) == int(ClientURISettings.CAMPAIGN_HOTSPOT)):
             correctDomains.append(DEFAULT_HOTSPOT)
         elif (campaign != None and int(campaign.wifiCampaign.hotspotMode) == int(ClientURISettings.CAMPAIGN_FACEBOOK)):
             logger.debug("Facebook campaign, no DNS rules")
         else:
             correctDomains.append(DEFAULT_CAPTIVE)
         
         
         for domain_file in os.listdir(ClientURISettings.DNSMASQ_CONFIG_FOLDER):
             if domain_file not in correctDomains:
                 filepath = ClientURISettings.DNSMASQ_CONFIG_FOLDER + os.sep + domain_file
                 if (os.path.exists(filepath)):
                     logger.info("Deleting old hotspot domain %s" % domain_file)
                     os.remove(ClientURISettings.DNSMASQ_CONFIG_FOLDER + os.sep + domain_file)
                     needsDNSRestart = True
         for domain in correctDomains:
             filepath = ClientURISettings.DNSMASQ_CONFIG_FOLDER + os.sep + domain
             if not os.path.isfile(filepath):    
                 if (domain == DEFAULT_HOTSPOT):
                     strContent = "# disabled in hotspot mode\n#address=/#/192.168.45.3"
                     SystemWriter.writeFile(filepath, strContent)
                 elif (domain == DEFAULT_CAPTIVE):
                     strContent = "address=/#/192.168.45.3"
                     SystemWriter.writeFile(filepath, strContent)
                 else:
                     strContent = "server=/%s/#\n" % domain
                     SystemWriter.writeFile(filepath, strContent)
                 needsDNSRestart = True
         
     except Exception as err:
         logger.error(err)
         
     if (needsDNSRestart == True):
         ProcessExecutor.restartDNS()
    def makeDefaultDnsmasqConfFile(restartDNSMasq=True):
        #Only write file if its a dreamplug
        #bluegiga captiveportal takes care of this automatically
        if Platform.getPlatform() == Platform.PLATFORM_LINUX_DREAMPLUG:
            try:
                ProcessExecutor.setCorrectBackhaulInterface()
                logger.info("writing dnsmasq file %s" %
                            ClientURISettings.DNSMASQ_DEFAULT_FILE)
                content = default_dnsmasq.CONTENT.replace(
                    "PROXIMUS_DNSMASQ_CONFIG_FILE",
                    ClientURISettings.DNSMASQ_CONFIG_FILE).replace(
                        "PROXIMUS_DNS_INTERFACE",
                        SystemWriter.getCurrentAccessPointInterface())
                SystemWriter.writeFile(ClientURISettings.DNSMASQ_DEFAULT_FILE,
                                       content)
                if (restartDNSMasq):
                    ProcessExecutor.restartDNS()

            except Exception as err:
                logger.error(err)
    def makeDnsmasqConfFile(restartDNSMasq=True):
        try:
            logger.info("writing dnsmasq.conf file %s" %
                        ClientURISettings.DNSMASQ_CONFIG_FILE)

            range = "dhcp-range=192.168.45.50,192.168.45.150,1h"
            leases = "dhcp-leasefile=%s" % (
                ClientURISettings.DNSMASQ_LEASES_FILE)
            config_dir = "conf-dir=/home/proximus/config/dnsmasq.d"
            if Platform.getPlatform() == Platform.PLATFORM_LINUX_DREAMPLUG:
                pass
            content = dnsmasq.CONTENT.replace(
                "PROXIMUS_DHCP_RANGE",
                range).replace("PROXIMUS_DNS_LEASES_FILE",
                               leases).replace("PROXIMUS_DNS_CONFIG_DIR",
                                               config_dir)
            SystemWriter.writeFile(ClientURISettings.DNSMASQ_CONFIG_FILE,
                                   content)
            if (restartDNSMasq):
                ProcessExecutor.restartDNS()

        except Exception as err:
            logger.error(err)