<commit_before>using DNS.Protocol;
using DNS.Protocol.ResourceRecords;
using DNS.Server;
using System.Collections.Generic;
using System.Net;
using System.Threading;
using UnityEngine;

namespace HappyFunTimes {

    public class HFTDnsRunner
    {
        public void Start()
        {
            GameObject go = new GameObject("HFTDnsEventProcessor");
            eventProcessor_ = go.AddComponent<HFTEventProcessor>();
            helper_ = new HFTDnsRunnerHelper(eventProcessor_);
            dnsThread_ = new Thread(helper_.DoWork);
            dnsThread_.Start();
        }

        public void Stop()
        {
            helper_.Close();
            dnsThread_.Join();
            if (eventProcessor_ != null)
            {
                UnityEngine.Object.Destroy(eventProcessor_.gameObject);
            }
        }

        Thread dnsThread_;
        HFTDnsRunnerHelper helper_;
        HFTEventProcessor eventProcessor_;
    }

    class HFTDnsServer : DNS.Server.DnsServer {
        public HFTDnsServer(string ipAddressToReturnForAllDomains) : base (new DNSAll(ipAddressToReturnForAllDomains))
        {
        }

        override protected IResponse ResolveRemote(Request request)
        {
            #pragma warning disable
                throw new System.InvalidOperationException("should never get here!");
                return null;
            #pragma warning restore
        }
    }

    class HFTDnsRunnerHelper
    {
        public HFTDnsRunnerHelper(HFTEventProcessor ep)
        {
            eventProcessor_ = ep;
        }

        public void DoWork()
        {
            int port = 53;

            try
            {
                log_.Info("DNS DoWork -start-");
                dnsServer_ = new HFTDnsServer("172.16.58.3");
                dnsServer_.Listen(port);
                log_.Info("DNS DoWork -end-");
            }
            catch (System.Exception ex)
            {
                string msg =
                    "Could not start DNS Server on port:" + port + "\n" +
                    "Did you run from the command line with sudo?\n\n" + ex.ToString();

                if (!HFTGlobalEventEmitter.GetInstance().QueueEvent(HFTGlobalEventType.Error, msg))
                {
                    // No one handled it. Let's do it ourselves.
                    eventProcessor_.QueueEvent(() => {
                        HFTDialog.MessageBox("ERROR", msg);
                    });
                }
            }
        }<commit_msg>add reminder to fix dns ip<commit_after>using DNS.Protocol;
using DNS.Protocol.ResourceRecords;
using DNS.Server;
using System.Collections.Generic;
using System.Net;
using System.Threading;
using UnityEngine;

namespace HappyFunTimes {

    public class HFTDnsRunner
    {
        public void Start()
        {
            GameObject go = new GameObject("HFTDnsEventProcessor");
            eventProcessor_ = go.AddComponent<HFTEventProcessor>();
            helper_ = new HFTDnsRunnerHelper(eventProcessor_);
            dnsThread_ = new Thread(helper_.DoWork);
            dnsThread_.Start();
        }

        public void Stop()
        {
            helper_.Close();
            dnsThread_.Join();
            if (eventProcessor_ != null)
            {
                UnityEngine.Object.Destroy(eventProcessor_.gameObject);
            }
        }

        Thread dnsThread_;
        HFTDnsRunnerHelper helper_;
        HFTEventProcessor eventProcessor_;
    }

    class HFTDnsServer : DNS.Server.DnsServer {
        public HFTDnsServer(string ipAddressToReturnForAllDomains) : base (new DNSAll(ipAddressToReturnForAllDomains))
        {
        }

        override protected IResponse ResolveRemote(Request request)
        {
            #pragma warning disable
                throw new System.InvalidOperationException("should never get here!");
                return null;
            #pragma warning restore
        }
    }

    class HFTDnsRunnerHelper
    {
        public HFTDnsRunnerHelper(HFTEventProcessor ep)
        {
            eventProcessor_ = ep;
        }

        public void DoWork()
        {
            int port = 53;

            try
            {
                log_.Info("DNS DoWork -start-");
                log_.Tell("FIX: hard coded dns");
                dnsServer_ = new HFTDnsServer("192.168.2.9");
                dnsServer_.Listen(port);
                log_.Info("DNS DoWork -end-");
            }
            catch (System.Exception ex)
            {
                string msg =
                    "Could not start DNS Server on port:" + port + "\n" +
                    "Did you run from the command line with sudo?\n\n" + ex.ToString();

                if (!HFTGlobalEventEmitter.GetInstance().QueueEvent(HFTGlobalEventType.Error, msg))
                {
                    // No one handled it. Let's do it ourselves.
                    eventProcessor_.QueueEvent(() => {
                        HFTDialog.MessageBox("ERROR", msg);
                    });
                }
            }
        }
{'fraction_non_alphanumeric': 0.08467182232797937, 'fraction_numerical': 0.00396589331746976, 'mean_word_length': 1.5565129244804865, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '979471', 'n_tokens_mistral': 1334, 'n_tokens_neox': 1258, 'n_words': 289}