示例#1
0
 readonly ReceivedHeader _receivedHeader; //Receivedヘッダ文字列
 public MailSave(MailBox mailBox, Alias alias, MailQueue mailQueue, Logger logger, ReceivedHeader receivedHeader, List <string> domainList)
 {
     _mailBox        = mailBox;
     _alias          = alias;
     _mailQueue      = mailQueue;
     _logger         = logger;
     _receivedHeader = receivedHeader;
     _domainList     = domainList;
     _localBox       = new LocalBox(_logger);
 }
示例#2
0
        int _idCounter; //id作成のための順次番号生成カウンタ

        #endregion Fields

        #region Constructors

        public MailSave(MailBox mailBox, Alias alias,MailQueue mailQueue, Logger logger, ReceivedHeader receivedHeader, List<string> domainList)
        {
            _mailBox = mailBox;
            _alias = alias;
            _mailQueue = mailQueue;
            _logger = logger;
            _receivedHeader = receivedHeader;
            _domainList = domainList;
            _localBox = new LocalBox(_logger);
        }
示例#3
0
文件: Agent.cs 项目: jsakamoto/bjd5
        //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;
        }
示例#4
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;
        }
示例#5
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;
        }
示例#6
0
文件: Agent.cs 项目: schifflee/bjd5
        //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;
        }
示例#7
0
        public Initialization2()
        {
            var tsDir = new TsDir();
            //var tsOption = new TsOption(tsDir);
            //var manageDir = tsDir.Src + "\\TestDir";

            //TmpDir2 = string.Format("{0}/../../TestDir", Directory.GetCurrentDirectory());
            var optionDef = tsDir.Src + "\\Option.def";

            //Docs
            Docs = new List<string>();
            var lines = File.ReadAllLines(optionDef, Encoding.GetEncoding(932));
            foreach (MlDocKind docKind in Enum.GetValues(typeof(MlDocKind))) {
                var tag = string.Format("MEMO=Ml\b{0}Document=", docKind.ToString().ToLower());
                bool hit = false;
                foreach (var l in lines) {
                    if (l.IndexOf(tag) == 0) {
                        Docs.Add(l.Substring(tag.Length));
                        hit = true;
                        break;
                    }
                }
                if (!hit) {
                    Docs.Add("");
                }
            }

            Kernel = new Kernel(null, null, null, null);
            Logger = Kernel.CreateLogger("LOG", true, null);
            domainList = new List<string>() { "example.com" };
            MlAddr = new MlAddr(mlName, domainList);
            var mailQueue = new MailQueue(tsDir.Src + "TestDir");
            var oneOption = new Option(Kernel,"","");
            var mailBox = new MailBox(Kernel, oneOption);
            MailSave = new MailSave(Kernel,mailBox,Logger,mailQueue,"",domainList);
            MlOption = CreateMlOption();
            //MlUserList = CreateMlUsers();

            Ml = new Ml(Kernel, Logger, MailSave, MlOption, mlName, domainList);
            //30件のメールを保存
            for (int i = 0; i < 30; i++) {
                var mail = new Mail(null);
                mail.Init(Encoding.ASCII.GetBytes("\r\n"));//区切り行(ヘッダ終了)
                mail.AddHeader("subject", string.Format("[{0}:{1:D5}]TITLE", mlName, i + 1));
                mail.Init(Encoding.ASCII.GetBytes("1\r\n"));//本文
                mail.Init(Encoding.ASCII.GetBytes("2\r\n"));//本文
                mail.Init(Encoding.ASCII.GetBytes("3\r\n"));//本文

                Ml.Save(mail);
            }
        }
示例#8
0
        public void SetUp()
        {
            var tsDir = new TsDir();
            _tsOption = new TsOption(tsDir);
            _tsOption.Set("FOLDER", "MailBox", "dir", string.Format("{0}\\MailBox", tsDir.Src));
            //user1,user2,user3
            _tsOption.Set("DAT", "MailBox", "user", "user1\tpass\buser2\tpass\buser3\tpass");

            var kernel = new Kernel(null, null, null, null);
            var logger = new Logger(kernel, "LOG", false, null);
            var manageDir = tsDir.Src + "\\TestDir";
            //MailQueue
            _mailQueue = new MailQueue(tsDir.Src + "\\MailQueue");
            var oneOption = kernel.ListOption.Get("MailBox");

            _mailBox = new MailBox(kernel, oneOption);

            var mailSave = new MailSave(kernel, _mailBox, logger, _mailQueue, "", _domainList);//モック

            var memberList = new Dat();
            memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER1", "*****@*****.**", false, true, true, "")); //一般・読者・投稿
            memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER2", "*****@*****.**", false, true, false, ""));//一般・読者・×
            memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER3", "*****@*****.**", false, false, true, ""));//一般・×・投稿
            //memberList.Add(false, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER6" , "*****@*****.**" , false, false, true, ""));//一般・×・投稿 (Disable)
            //memberList.Add(true,  string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN" , "*****@*****.**" , true, false, true, "123"));//管理者・×・投稿
            //memberList.Add(true,  string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN2", "*****@*****.**", true, true, true, "456"));//管理者・読者・投稿
            //memberList.Add(false, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN3", "*****@*****.**", true, true, true, "789"));//管理者・読者・投稿 (Disable)
            var docs = (from object o in Enum.GetValues(typeof(MLDocKind)) select "").ToList();
            const int maxSummary = 10;
            const int getMax = 10;
            const bool autoRegistration = true;
            const int titleKind = 1;
            var mlOption = new MlOption(maxSummary, getMax, autoRegistration, titleKind, docs, manageDir, memberList);

            _ml = new Ml(kernel, logger, mailSave, mlOption, _mlName, _domainList);
        }
示例#9
0
文件: Server.cs 项目: jsakamoto/bjd5
        Fetch _fetch; //自動受信

        #endregion Fields

        #region Constructors

        //#endif
        //コンストラクタ
        public Server(Kernel kernel, Conf conf, OneBind oneBind)
            : base(kernel, conf, oneBind)
        {
            //Ver5.8.9
            if (kernel.RunMode == RunMode.Normal || kernel.RunMode == RunMode.Service) {
                //メールボックスの初期化状態確認
                if (kernel.MailBox == null || !kernel.MailBox.Status) {
                    Logger.Set(LogKind.Error, null, 4, "");
                    return; //初期化失敗(サーバは機能しない)
                }
            }

            //ドメイン名のリスト整備
            DomainList = new List<string>();
            foreach (var s in ((string)Conf.Get("domainName")).Split(',')) {
                //Ver6.1.9
                // 設定時に誤って空白が入ってしまった際、強制的に削除する
                DomainList.Add(s.Trim());
                //DomainList.Add(s);
            }
            if (DomainList.Count == 0) {
                Logger.Set(LogKind.Error, null, 3, "");
                return;//初期化失敗(サーバは機能しない)
            }

            //エリアス初期化
            Alias = new Alias(DomainList, kernel.MailBox);
            foreach (var dat in (Dat)Conf.Get("aliasList")) {
                if (dat.Enable) {
                    var name = dat.StrList[0];
                    var alias = dat.StrList[1];
                    Alias.Add(name, alias, Logger);
                }
            }

            //メールキューの初期化
            _mailQueue = new MailQueue(kernel.ProgDir());

            //SaveMail初期化
            var receivedHeader = new ReceivedHeader(kernel, (string)Conf.Get("receivedHeader"));
            _mailSave = new MailSave(kernel.MailBox,Alias, _mailQueue,Logger, receivedHeader, DomainList);

            var always = (bool)Conf.Get("always");//キュー常時処理
            _agent = new Agent(kernel, this, Conf, Logger, _mailQueue, always);

            //中継許可の初期化
            _relay = new Relay((Dat)Conf.Get("allowList"), (Dat)Conf.Get("denyList"), (int)Conf.Get("order"), Logger);

            //PopBeforeSmtp
            _popBeforeSmtp = new PopBeforeSmtp((bool)conf.Get("usePopBeforeSmtp"), (int)conf.Get("timePopBeforeSmtp"), kernel.MailBox);

            //usePopAccountがfalseの時、内部でmailBoxが無効化される
            _smtpAuthUserList = new SmtpAuthUserList((bool)Conf.Get("usePopAcount"), Kernel.MailBox, (Dat)Conf.Get("esmtpUserList"));
            _smtpAuthRange = new SmtpAuthRange((Dat)Conf.Get("range"), (int)Conf.Get("enableEsmtp"), Logger);

            //ヘッダ置換
            _changeHeader = new ChangeHeader((Dat)Conf.Get("patternList"), (Dat)Conf.Get("appendList"));

            //Ver5.3.3 Ver5.2以前のバージョンのカラムの違いを修正する
            var d = (Dat)Conf.Get("hostList");
            if (d.Count > 0 && d[0].StrList.Count == 6) {
                foreach (var o in d) {
                    o.StrList.Add("False");
                }
                conf.Set("hostList", d);
                conf.Save(kernel.IniDb);
            }

            //#if ML_SERVER
            _mlList = new MlList(kernel,this,_mailSave, DomainList);
            //#endif
        }
示例#10
0
文件: Server.cs 项目: schifflee/bjd5
        readonly MlList _mlList;//MLリスト
//#endif

        //コンストラクタ
        public Server(Kernel kernel, Conf conf, OneBind oneBind)
            : base(kernel, conf, oneBind)
        {
            //Ver5.8.9
            if (kernel.RunMode == RunMode.Normal || kernel.RunMode == RunMode.Service)
            {
                //メールボックスの初期化状態確認
                if (kernel.MailBox == null || !kernel.MailBox.Status)
                {
                    Logger.Set(LogKind.Error, null, 4, "");
                    return; //初期化失敗(サーバは機能しない)
                }
            }


            //ドメイン名のリスト整備
            DomainList = new List <string>();
            foreach (var s in ((string)Conf.Get("domainName")).Split(','))
            {
                //Ver6.1.9
                // 設定時に誤って空白が入ってしまった際、強制的に削除する
                DomainList.Add(s.Trim());
                //DomainList.Add(s);
            }
            if (DomainList.Count == 0)
            {
                Logger.Set(LogKind.Error, null, 3, "");
                return;//初期化失敗(サーバは機能しない)
            }

            //エリアス初期化
            Alias = new Alias(DomainList, kernel.MailBox);
            foreach (var dat in (Dat)Conf.Get("aliasList"))
            {
                if (dat.Enable)
                {
                    var name  = dat.StrList[0];
                    var alias = dat.StrList[1];
                    Alias.Add(name, alias, Logger);
                }
            }

            //メールキューの初期化
            _mailQueue = new MailQueue(kernel.ProgDir());

            //SaveMail初期化
            var receivedHeader = new ReceivedHeader(kernel, (string)Conf.Get("receivedHeader"));

            _mailSave = new MailSave(kernel.MailBox, Alias, _mailQueue, Logger, receivedHeader, DomainList);

            var always = (bool)Conf.Get("always");//キュー常時処理

            _agent = new Agent(kernel, this, Conf, Logger, _mailQueue, always);

            //中継許可の初期化
            _relay = new Relay((Dat)Conf.Get("allowList"), (Dat)Conf.Get("denyList"), (int)Conf.Get("order"), Logger);

            //PopBeforeSmtp
            _popBeforeSmtp = new PopBeforeSmtp((bool)conf.Get("usePopBeforeSmtp"), (int)conf.Get("timePopBeforeSmtp"), kernel.MailBox);


            //usePopAccountがfalseの時、内部でmailBoxが無効化される
            _smtpAuthUserList = new SmtpAuthUserList((bool)Conf.Get("usePopAcount"), Kernel.MailBox, (Dat)Conf.Get("esmtpUserList"));
            _smtpAuthRange    = new SmtpAuthRange((Dat)Conf.Get("range"), (int)Conf.Get("enableEsmtp"), Logger);

            //ヘッダ置換
            _changeHeader = new ChangeHeader((Dat)Conf.Get("patternList"), (Dat)Conf.Get("appendList"));


            //Ver5.3.3 Ver5.2以前のバージョンのカラムの違いを修正する
            var d = (Dat)Conf.Get("hostList");

            if (d.Count > 0 && d[0].StrList.Count == 6)
            {
                foreach (var o in d)
                {
                    o.StrList.Add("False");
                }
                conf.Set("hostList", d);
                conf.Save(kernel.IniDb);
            }

//#if ML_SERVER
            _mlList = new MlList(kernel, this, _mailSave, DomainList);
//#endif
        }
示例#11
0
 public Mail Mail(MailQueue mailQueue)
 {
     var mail = new Mail();
     return mailQueue.Read(_fname, ref mail) ? mail : null;
 }
示例#12
0
 public void Delete(MailQueue mailQueue)
 {
     mailQueue.Delete(_fname);
 }
示例#13
0
 public void Delete(MailQueue mailQueue)
 {
     mailQueue.Delete(_fname);
 }
示例#14
0
        public Mail Mail(MailQueue mailQueue)
        {
            var mail = new Mail();

            return(mailQueue.Read(_fname, ref mail) ? mail : null);
        }
示例#15
0
 public void SetUp()
 {
     sut = new MailQueue("c:\\tmp2\\bjd5\\SmtpServerTest");
 }