Ejemplo n.º 1
0
        //コンストラクタ
        //リソース定義(Dat)で初期化する場合
        public RrDb(Logger logger, Conf conf, IEnumerable<OneDat> dat, string dname,bool authority)
        {
            //ドメイン名の初期化
            SetDomainName(dname);

            //Ver6.1.0
            Authority = authority;

            //Datの読み込み
            if (dat != null){
                foreach (var o in dat){
                    if (o.Enable){
                        try{
                            AddOneDat(_domainName, o);
                        } catch (ValidObjException e){
                            logger.Set(LogKind.Error, null, 19, string.Format("domain={0} {1}", _domainName, e.Message));
                        }
                    }
                }
            }
            if (conf != null){
                //SOAレコードの追加
                var mail = (string) conf.Get("soaMail");
                var serial = (uint)((int) conf.Get("soaSerial"));
                var refresh = (uint)((int) conf.Get("soaRefresh"));
                var retry = (uint)((int) conf.Get("soaRetry"));
                _expire = (uint)((int) conf.Get("soaExpire")); //expireは、TTL=0のリソースが検索されたとき、TTLに使用するため、クラス変数に保存する
                var minimum = (uint)((int) conf.Get("soaMinimum"));
                if (!InitSoa(_domainName, mail, serial, refresh, retry, _expire, minimum)){
                    logger.Set(LogKind.Error, null, 20, string.Format("domain={0}", _domainName));
                }
            }
        }
Ejemplo n.º 2
0
        public Cache(Kernel kernel, Logger logger, Conf conf)
            : base(logger)
        {
            this.logger = logger;
            //_oneOption = oneOption;
            _conf = conf;
            _useCache = (bool)conf.Get("useCache");

            if (!_useCache)
                return;

            _expires = (int)conf.Get("expires");
            _maxSize = (int)conf.Get("maxSize");
            _diskSize = (int)conf.Get("diskSize");
            _memorySize = (int)conf.Get("memorySize");

            //�L���b�V���Ώۃ��X�g
            _cacheTargetHost = new CacheTarget((Dat)conf.Get("cacheHost"), (int)conf.Get("enableHost"));
            _cacheTargetExt = new CacheTarget((Dat)conf.Get("cacheExt"), (int)conf.Get("enableExt"));

            //�f�B�X�N�L���b�V��
            var cacheDir = (string)conf.Get("cacheDir");//�L���b�V����ۑ�����f�B���N�g��
            if (cacheDir == "" || !Directory.Exists(cacheDir)) {
                logger.Set(LogKind.Error, null, 15, string.Format("dir = {0}", cacheDir));
                _diskSize = 0;
            }
            if (_diskSize != 0) {
                _diskCache = new DiskCache(cacheDir, logger);
            }

            if (_memorySize != 0)//�������L���b�V��
                _memoryCache = new MemoryCache(logger);
        }
Ejemplo n.º 3
0
        WebDavDb _webDavDb; //WevDAVのDethプロパテイを管理するクラス

        #endregion Fields

        #region Constructors

        //通常のServerThreadの子クラスと違い、オプションはリストで受け取る
        //親クラスは、そのリストの0番目のオブジェクトで初期化する
        //コンストラクタ
        public Server(Kernel kernel,Conf conf,OneBind oneBind)
            : base(kernel, conf,oneBind)
        {
            //同一ポートで待ち受けている仮想サーバのオプションをすべてリストする
            WebOptionList = new List<OneOption>();
            foreach (var o in kernel.ListOption) {
                if (o.NameTag.IndexOf("Web-") == 0) {
                    if((int)o.GetValue("port") == (int)Conf.Get("port")){
                        WebOptionList.Add(o);
                    }
                }
            }
            //WebDAVリストの初期化
            foreach (var o in WebOptionList) {
                if(o.UseServer) {
                    _webDavDbList.Add(new WebDavDb(kernel,NameTag));
                }
            }
            _webDavDb = _webDavDbList[0];

            //Ver5.1.2「Cgiパス」「WebDAVパス」「別名」のオプションの修正
            var tagList = new List<string> { "cgiPath", "webDavPath", "aliaseList" };
            foreach(string tag in tagList) {
                var dat = (Dat)Conf.Get(tag);
                var changed = false;
                foreach(var o in dat) {
                    var str = o.StrList[0];
                    if(str[0] != '/') {
                        changed = true;
                        str = '/' + str;
                    }
                    if(str.Length > 1 && str[str.Length - 1] != '/') {
                        changed = true;
                        str = str + '/';
                    }
                    o.StrList[0] = str;
                }
                if(changed)
                    Conf.Set(tag, dat);
            }

            //当初、opBase及びloggerは、weboptionList[0]で暫定的に初期化される
            var protocol = (int)Conf.Get("protocol");
            if (protocol==1) {//HTTPS
                var op = kernel.ListOption.Get("VirtualHost");
                var privateKeyPassword = (string)op.GetValue("privateKeyPassword");
                var certificate = (string)op.GetValue("certificate");

                //サーバ用SSLの初期化
                ssl = new Ssl(Logger, certificate, privateKeyPassword);
            }

            var useAutoAcl = (bool)Conf.Get("useAutoAcl");// ACL拒否リストへ自動追加する
            if (useAutoAcl) {
                const int max = 1; //発生回数
                const int sec = 120; // 対象期間(秒)
                _attackDb = new AttackDb(sec, max);
            }
        }
Ejemplo n.º 4
0
 public void SetUp()
 {
     //設定ファイルの退避と上書き
     _op = new TmpOption("BJDTest","MailBoxTest.ini");
     var kernel = new Kernel();
     var oneOption = new OptionMailBox(kernel,"");
     _conf = new Conf(oneOption);
 }
Ejemplo n.º 5
0
        public void FullPathTest(string uri, string path)
        {
            Conf conf = new Conf(option);
            var sut = new Target(conf, null);
            var fullPath = string.Format("{0}\\{1}", _v4Sv.DocumentRoot, path);

            sut.InitFromUri(uri);
            Assert.AreEqual(sut.FullPath,fullPath);
        }
Ejemplo n.º 6
0
 public Server(Kernel kernel, Conf conf, OneBind oneBind)
     : base(kernel, conf, oneBind)
 {
     _bannerMessage = kernel.ChangeTag((String) Conf.Get("bannerMessage"));
     //���[�U���
     _listUser = new ListUser((Dat) Conf.Get("user"));
     //���z�t�H���_
     _listMount = new ListMount((Dat) Conf.Get("mountList"));
 }
Ejemplo n.º 7
0
        int _indexServer; //サーバ側にどこまで送信を完了したかのインデックス

        #endregion Fields

        #region Constructors

        public ProxyHttp(Proxy proxy, Kernel kernel, Conf conf, Cache cache, LimitString limitString)
            : base(proxy)
        {
            _kernel = kernel;
            //_oneOption = oneOption;
            _conf = conf;
            _cache = cache;
            LimitString = limitString;
            KeepAlive = true;//デフォルトで継続型
        }
Ejemplo n.º 8
0
        public void DocumentRootTest()
        {
            Conf conf = new Conf(option);
            var sut = new Target(conf, null);

            //無効なドキュメントルートを設定する
            conf.Set("documentRoot", "q:\\");
            sut = new Target(conf, null);
            Assert.AreEqual(sut.DocumentRoot, null);
        }
Ejemplo n.º 9
0
        public void SetUp()
        {
            //設定ファイルの退避と上書き
            _op = new TmpOption("WebServerTest","WebServerTest.ini");
            Kernel kernel = new Kernel();
            var option = kernel.ListOption.Get("Web-localhost:88");
            Conf conf = new Conf(option);

            _contentType = new ContentType(conf);
        }
Ejemplo n.º 10
0
        public void SetUp()
        {
            var datUser = new Dat(new CtrlType[2] { CtrlType.TextBox, CtrlType.TextBox });
            datUser.Add(true, "user1\t3OuFXZzV8+iY6TC747UpCA==");
            datUser.Add(true, "user2\tNKfF4/Tw/WMhHZvTilAuJQ==");
            datUser.Add(true, "user3\tXXX");

            _conf = new Conf();
            _conf.Add("user", datUser);

            _mailBox = new MailBox(new Logger(), datUser, "c:\\tmp2\\bjd5\\Pop3Server\\mailbox");
        }
Ejemplo n.º 11
0
        string _timeFmt = "ddd M dd hh:mm:ss yyyy"; //(SSI用)日付書式文字列

        #endregion Fields

        #region Constructors

        public Ssi(Kernel kernel, Logger logger, Conf conf, SockTcp tcpObj, Request request, Header recvHeader)
        {
            _kernel = kernel;
            _logger = logger;
            //_oneOption = oneOption;
            _conf = conf;

            //子プロセスでCGIを実行する場合に使用する
            _sockTcp = tcpObj;
            _request = request;
            _recvHeader = recvHeader;
        }
Ejemplo n.º 12
0
        //�e�X�g�p�R���X�g���N�^(MailBox�̂ݏ�����)
        public Kernel(String option)
        {
            _isTest = true;
            DefaultInitialize(null, null, null, null);

            if (option.IndexOf("MailBox") != -1){
                var op = ListOption.Get("MailBox");
                var conf = new Conf(op);
                var dir = ReplaceOptionEnv((String)conf.Get("dir"));
                var datUser = (Dat)conf.Get("user");
                MailBox = new MailBox(null, datUser, dir);
            }
        }
Ejemplo n.º 13
0
        //public Agent(Server server, Kernel kernel, MailQueue mailQueue, SaveMail saveMail,bool always):base(kernel,"Agent") {
        public Agent(Kernel kernel, Server server,Conf conf, Logger logger,MailQueue mailQueue, bool always)
            : base(kernel.CreateLogger("Agent",true, null))
        {
            _conf = conf;
            _logger = logger;
            _mailQueue = mailQueue;

            _always = always;

            //�b��
            _kernel = kernel;
            _server = server;
        }
Ejemplo n.º 14
0
        public OneAgent(Kernel kernel, Server server,Conf conf,Logger logger, MailQueue mailQueue, OneQueue oneQueue)
            : base(kernel.CreateLogger("OneAgent",true,null))
        {
            _conf = conf;
            _logger = logger;
            _mailQueue = mailQueue;
            _oneQueue = oneQueue;
            _smtpClient2 = new SmtpClient2();

            //暫定
            _kernel = kernel;
            _server = server;
        }
Ejemplo n.º 15
0
        public ProxyFtp(Proxy proxy, Kernel kernel, Conf conf, Server server, int dataPort)
            : base(proxy)
        {
            _kernel = kernel;
            //_oneOption = oneOption;
            _conf = conf;
            _server = server;

            DataPort = dataPort;

            //USER PASSのデフォルト値
            _user = "******";
            _pass = (string)conf.Get("anonymousAddress");
        }
Ejemplo n.º 16
0
        //�R���X�g���N�^
        public Server(Kernel kernel,Conf conf,OneBind oneBind)
            : base(kernel, conf, oneBind)
        {
            _targetServer = (string)Conf.Get("targetServer");
            _targetPort = (int)Conf.Get("targetPort");

            if (_targetServer == "") {
                Logger.Set(LogKind.Error,null, 1, "");
            }
            if (_targetPort == 0) {
                Logger.Set(LogKind.Error, null,2, "");
            }

            _protocolKind = oneBind.Protocol;
        }
Ejemplo n.º 17
0
        public static void BeforeClass()
        {
            //設定ファイルの退避と上書き
            _op = new TmpOption("WebServerTest","WebServerTest.ini");
            var kernel = new Kernel();
            var option = kernel.ListOption.Get("Web-localhost:88");
            Conf conf = new Conf(option);

            //サーバ起動
            _v4Sv = new Server(kernel, conf, new OneBind(new Ip(IpKind.V4Localhost), ProtocolKind.Tcp));
            _v4Sv.Start();

            _v6Sv = new Server(kernel, conf, new OneBind(new Ip(IpKind.V6Localhost), ProtocolKind.Tcp));
            _v6Sv.Start();
        }
Ejemplo n.º 18
0
        public Target(Conf conf, Logger logger)
        {
            //_oneOption = oneOption;
            _conf = conf;
            _logger = logger;

            DocumentRoot = (string)_conf.Get("documentRoot");
            if (!Directory.Exists(DocumentRoot)) {
                DocumentRoot = null;//�h�L�������g���[�g����
            }
            FullPath = "";
            TargetKind = TargetKind.Non;
            Attr = new FileAttributes();
            FileInfo = null;
            CgiCmd = "";
            Uri = null;
        }
Ejemplo n.º 19
0
        public static void BeforeClass()
        {
            TestUtil.CopyLangTxt();//BJD.Lang.txt

            //設定ファイルの退避と上書き
            _op = new TmpOption("SipServerTest","SipServerTest.ini");
            var kernel = new Kernel();
            var option = kernel.ListOption.Get("Sip");
            var conf = new Conf(option);

            //サーバ起動
            _v4Sv = new Server(kernel, conf, new OneBind(new Ip(IpKind.V4Localhost), ProtocolKind.Tcp));
            _v4Sv.Start();

            _v6Sv = new Server(kernel, conf, new OneBind(new Ip(IpKind.V6Localhost), ProtocolKind.Tcp));
            _v6Sv.Start();
        }
Ejemplo n.º 20
0
        public static void BeforeClass()
        {
            //srcDir = string.Format("{0}\\ProxyHttpServerTest", TestUtil.ProhjectDirectory());

            //設定ファイルの退避と上書き
            _op = new TmpOption("ProxyHttpServerTest", "ProxyHttpServerTest.ini");
            Kernel kernel = new Kernel();
            var option = kernel.ListOption.Get("ProxyHttp");
            Conf conf = new Conf(option);

            //サーバ起動
            _v4Sv = new Server(kernel, conf, new OneBind(new Ip(IpKind.V4Localhost), ProtocolKind.Tcp));
            _v4Sv.Start();

            _v6Sv = new Server(kernel, conf, new OneBind(new Ip(IpKind.V6Localhost), ProtocolKind.Tcp));
            _v6Sv.Start();
        }
Ejemplo n.º 21
0
        private readonly AttackDb _attackDb; //��������

        #endregion Fields

        #region Constructors

        //�R���X�g���N�^
        public Server(Kernel kernel, Conf conf, OneBind oneBind)
            : base(kernel, conf, oneBind)
        {
            //Ver5.8.9
            if (kernel.RunMode == RunMode.Normal || kernel.RunMode == RunMode.Service){
                //���[���{�b�N�X�̏�������Ԋm�F
                if (kernel.MailBox == null || !kernel.MailBox.Status){
                    Logger.Set(LogKind.Error, null, 4, "");
                }
            }

            var useAutoAcl = (bool) Conf.Get("useAutoAcl"); // ACL���ۃ��X�g�֎����lj�����
            if (!useAutoAcl)
                return;
            var max = (int) Conf.Get("autoAclMax"); // �F�؎��s���i��j
            var sec = (int) Conf.Get("autoAclSec"); // �Ώۊ���(�b)
            _attackDb = new AttackDb(sec, max);
        }
Ejemplo n.º 22
0
        public void Option及びServerインスタンスの生成()
        {
            var kernel = new Kernel();
            const string currentDir = @"C:\tmp2\bjd5\BJD\out";

            var sut = new ListPlugin(string.Format("{0}\\bin\\plugins", currentDir));
            foreach (var onePlugin in sut) {
            //Optionインスタンス生成
            var oneOption = onePlugin.CreateOption(kernel,"Option","nameTag");
            Assert.NotNull(oneOption);

            //Serverインスタンス生成
            var conf = new Conf(oneOption);
            var oneBind = new OneBind(new Ip(IpKind.V4Localhost), ProtocolKind.Tcp);
            var oneServer = onePlugin.CreateServer(kernel, conf, oneBind);
            Assert.NotNull(oneServer);
            }
        }
Ejemplo n.º 23
0
        public Document(Kernel kernel, Logger logger, Conf conf, SockTcp tcpObj, ContentType contentType)
        {
            //this.kernel = kernel;
            _logger = logger;
            //_oneOption = oneOption;
            _conf = conf;
            _sockTcp = tcpObj;
            _contentType = contentType;

            SetRangeTo = false;

            //���M�w�b�_������
            _sendHeader = new Header();
            _sendHeader.Replace("Server", Util.SwapStr("$v", kernel.Ver.Version(), (string)_conf.Get("serverHeader")));
            _sendHeader.Replace("MIME-Version","1.0");
            _sendHeader.Replace("Date",Util.UtcTime2Str(DateTime.UtcNow));

            _body = new Body();
        }
Ejemplo n.º 24
0
        public void OptionTest(string key, string val)
        {
            var request = new Request(null,null);

            var conf = new Conf(option);
            conf.Set("documentRoot", val);

            var header = new Header();
            var tcpObj = new SockTcp(new Kernel(), new Ip("0.0.0.0"), 88, 1, null);
            const string fileName = "";
            var env = new Env(_kernel,conf, request, header,tcpObj, fileName);
            foreach (var e in env) {
                if (e.Key == key) {
                    Assert.AreEqual(e.Val, val);
                    return;
                }
            }
            Assert.AreEqual(key, "");
        }
Ejemplo n.º 25
0
        public static void BeforeClass()
        {
            TestUtil.CopyLangTxt();//BJD.Lang.txt

            //named.caのコピー
            var src = string.Format("{0}\\DnsServerTest\\named.ca", TestUtil.ProjectDirectory());
            var dst = string.Format("{0}\\BJD\\out\\named.ca", TestUtil.ProjectDirectory());
            File.Copy(src, dst, true);

            //設定ファイルの退避と上書き
            _op = new TmpOption("DnsServerTest","DnsServerTest.ini");
            OneBind oneBind = new OneBind(new Ip(IpKind.V4Localhost), ProtocolKind.Udp);
            Kernel kernel = new Kernel();
            var option = kernel.ListOption.Get("Dns");
            Conf conf = new Conf(option);

            //サーバ起動
            _sv = new Server(kernel, conf, oneBind);
            _sv.Start();
        }
Ejemplo n.º 26
0
 //パスワード変更
 public static bool Change(string user, string pass, MailBox mailBox, Conf conf)
 {
     if (pass == null){
         //無効なパスワードの指定は失敗する
         return false;
     }
     var dat = (Dat) conf.Get("user");
     foreach (var o in dat){
         if (o.StrList[0] == user){
             o.StrList[1] = Crypt.Encrypt(pass);
             conf.Set("user", dat); //データ変更
             if (mailBox.SetPass(user, pass)){
                 if (mailBox.Auth(user, pass)){
                     return true;
                 }
             }
             return false;
         }
     }
     return false;
 }
Ejemplo n.º 27
0
        public static void BeforeClass()
        {
            //設定ファイルの退避と上書き
            _op = new TmpOption("WebApiServerTest", "WebApiServerTest.ini");

            //MailBoxのみ初期化する特別なテスト用Kernelコンストラクタ
            var kernel = new Kernel("MailBox");
            var option = kernel.ListOption.Get("WebApi");
            var conf = new Conf(option);

            //メールボックスの初期化
            MailBoxBackup();
            MailBoxSetup();

            //サーバ起動
            _v4Sv = new Server(kernel, conf, new OneBind(new Ip(IpKind.V4Localhost), ProtocolKind.Tcp));
            _v4Sv.Start();

            _v6Sv = new Server(kernel, conf, new OneBind(new Ip(IpKind.V6Localhost), ProtocolKind.Tcp));
            _v6Sv.Start();
        }
Ejemplo n.º 28
0
        //�R���X�g���N�^
        protected OneServer(Kernel kernel, Conf conf, OneBind oneBind)
            : base(kernel.CreateLogger(conf.NameTag,true,null))
        {
            Kernel = kernel;
            NameTag = conf.NameTag;
            Conf = conf;
            _oneBind = oneBind;
            IsJp = kernel.IsJp();

            //Ver6.1.6
            Lang = new Lang(IsJp ? LangKind.Jp : LangKind.En, "Server" + conf.NameTag);
            CheckLang();//��`�̃e�X�g

            //�e�X�g�p
            if (Conf == null){
                var optionSample = new OptionSample(kernel, "");
                Conf = new Conf(optionSample);
                Conf.Set("port", 9990);
                Conf.Set("multiple", 10);
                Conf.Set("acl", new Dat(new CtrlType[0]));
                Conf.Set("enableAcl", 1);
                Conf.Set("timeOut", 3);
            }
            //�e�X�g�p
            if (_oneBind == null){
                var ip = new Ip(IpKind.V4Localhost);
                _oneBind = new OneBind(ip, ProtocolKind.Tcp);
            }

            Logger = kernel.CreateLogger(conf.NameTag, (bool)Conf.Get("useDetailsLog"), this);
            _multiple = (int) Conf.Get("multiple");

            //DHCP�ɂ�ACL�����݂��Ȃ�
            if (NameTag != "Dhcp"){
                //ACL���X�g ��`�������ꍇ�́AaclList�𐶐����Ȃ�
                var acl = (Dat)Conf.Get("acl");
                AclList = new AclList(acl, (int)Conf.Get("enableAcl"), Logger);
            }
            Timeout = (int) Conf.Get("timeOut");
        }
Ejemplo n.º 29
0
        readonly string _wpadUrl; //WPAD

        #endregion Fields

        #region Constructors

        //�R���X�g���N�^
        public Server(Kernel kernel, Conf conf,OneBind oneBind)
            : base(kernel, conf, oneBind)
        {
            //�I�v�V�����̓ǂݍ���
                _maskIp = (Ip)Conf.Get("maskIp");
                _gwIp = (Ip)Conf.Get("gwIp");
                _dnsIp0 = (Ip)Conf.Get("dnsIp0");
                _dnsIp1 = (Ip)Conf.Get("dnsIp1");
                _leaseTime = (int)Conf.Get("leaseTime");
            if (_leaseTime <= 0)
                _leaseTime = 86400;
            if ((bool)Conf.Get("useWpad")) {
                _wpadUrl = (string)Conf.Get("wpadUrl");
            }

            //DB����
            string fileName = string.Format("{0}\\lease.db", kernel.ProgDir());
            var startIp = (Ip)Conf.Get("startIp");
            var endIp = (Ip)Conf.Get("endIp");
            _macAcl = (Dat)Conf.Get("macAcl");
            //�ݒ肪�����ꍇ�́A���Dat�𐶐�����
            if (_macAcl == null){
                _macAcl = new Dat(new CtrlType[]{CtrlType.TextBox,CtrlType.AddressV4, CtrlType.TextBox});
            }

            //Ver5.6.8
            //�J�������u���O�i�\����)�v�𑝂₵�����Ƃɂ��݊����ێ�
            if (_macAcl.Count > 0) {
                foreach (OneDat t in _macAcl){
                    if (t.StrList.Count == 2) {
                        t.StrList.Add(string.Format("host_{0}",t.StrList[1]));
                    }
                }
            }
            _lease = new Lease(fileName, startIp, endIp, _leaseTime, _macAcl);

            //�T�[�o�A�h���X�̏�����
            _serverAddress = Define.ServerAddress();
        }
Ejemplo n.º 30
0
        public Server(Kernel kernel, Conf conf,OneBind oneBind)
            : base(kernel, conf,oneBind)
        {
            _cache = new Cache(kernel,this.Logger,conf);

            // 上位プロキシを経由しないサーバのリスト
            foreach (var o in (Dat)Conf.Get("disableAddress")) {
                if (o.Enable) {//有効なデータだけを対象にする
                    _disableAddressList.Add(o.StrList[0]);
                }
            }
            //URL制限
            var allow = (Dat)Conf.Get("limitUrlAllow");
            var deny = (Dat)Conf.Get("limitUrlDeny");
            //Ver5.4.5正規表現の誤りをチェックする
            for (var i = 0; i < 2; i++) {
                foreach (var a in (i == 0) ? allow : deny) {
                    if (a.Enable && a.StrList[1] == "3") {//正規表現
                        try {
                            var regex = new Regex(a.StrList[0]);
                        } catch {
                            Logger.Set(LogKind.Error, null, 28, a.StrList[0]);
                        }
                    }
                }
            }
            _limitUrl = new LimitUrl(allow,deny);

            //リクエストを通常ログで表示する
            _useRequestLog = (bool)Conf.Get("useRequestLog");

            //コンテンツ制限
            _limitString = new LimitString((Dat)Conf.Get("limitString"));
            if (_limitString.Length == 0)
                _limitString = null;

            _dataPort = DataPortMin;
        }