Пример #1
0
        /// <summary>
        /// GUI→Frontに設定を反映
        /// </summary>
        private void SaveSetting()
        {
            // 登録ポート一覧からスケジュールとFrontに設定を反映
            //Frontにはカンマ区切りに直して設定する
            clmSchedulePort.Items.Clear();
            Front.Gui.PortList.Clear();
            using (StringReader sr = new StringReader(optPortList.Text))
            {
                while (sr.Peek() > 0)
                {
                    string s = sr.ReadLine();
                    if (s.Length > 0)
                    {
                        try
                        {
                            int i = int.Parse(s);
                            Front.Gui.PortList.Add(i);
                            clmSchedulePort.Items.Add(s);
                        }
                        catch { }
                    }
                }
            }
            // スケジュール設定のポートリストに「ALL」を追加
            clmSchedulePort.Items.Add("ALL");

            #region 基本設定
            //自動再試行
            Front.Retry.InRetryInterval  = (uint)optInSecond.Value;
            Front.Retry.InRetryTime      = (uint)optInTime.Value;
            Front.Retry.OutRetryInterval = (uint)optOutSecond.Value;
            Front.Retry.OutRetryTime     = (uint)optOutTime.Value;

            //帯域制限
            if (Front.BandStopTypeString[optBandType.SelectedIndex] == "ポート毎に個別設定")
            {
                // 個別設定
                if (Front.BandStopTypeString[Front.BndWth.BandStopMode] != "ポート毎に個別設定")
                {
                    //旧:個別設定以外→新:個別設定に変更になった場合
                    //設定された制限値をすべての起動中鏡に設定
                    foreach (Kagami _k in Front.KagamiList)
                    {
                        _k.Status.GUILimitUPSpeed = (int)optBandValue.Value;
                        _k.Status.LimitUPSpeed    = Front.CnvLimit((int)optBandValue.Value, optBandUnit.SelectedIndex);
                    }
                }
            }
            else
            {
                // 個別設定以外
            }
            Front.BndWth.BandStopMode  = (uint)optBandType.SelectedIndex;
            Front.BndWth.BandStopValue = (uint)optBandValue.Value;
            Front.BndWth.BandStopUnit  = (uint)optBandUnit.SelectedIndex;
            Front.BndWth.BandStopResv  = optBandReserve.Checked;

            //連打キック
            Front.Kick.KickCheckSecond = (uint)optKickSecond.Value;
            Front.Kick.KickCheckTime   = (uint)optKickTime.Value;
            Front.Kick.KickDenyTime    = (uint)optKickDenyTime.Value;

            //ログ出力
            Front.Log.KagamiLogFile = optKagamiLogFile.Text;
            Front.Log.LogDetail     = optKagamiDetailLog.Checked;
            Front.Log.HpLogFile     = optHpLogFile.Text;

            //最小化時
            Front.Form.EnableTrayIcon = optMinTray.Checked;
            #endregion

            #region 鏡置き場
            //エントランス
            Front.Hp.UseHP     = optUseHP.Checked;
            Front.Hp.IpHTTP    = optHPAddr.Text;
            Front.Hp.PublicDir = optHPDir.Text;
            try
            {
                Front.Hp.PortHTTP = uint.Parse(optHPPort.Text);
            }
            catch
            {
                MessageBox.Show("HP公開ポート番号が異常です。\r\n65535以下の数値を設定してください。", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            //エントランス接続制限
            using (StringReader sr = new StringReader(optHPDenyList.Text))
            {
                try
                {
                    string str = "";
                    Front.Acl.HpDenyRemoteHost.Clear();
                    while (sr.Peek() > 0)
                    {
                        str = sr.ReadLine();
                        if (str.Length > 0 && Front.Acl.HpDenyRemoteHost.IndexOf(str) == -1)
                        {
                            Front.Acl.HpDenyRemoteHost.Add(str);
                        }
                    }
                }
                catch { }
            }

            //インポート接続制限
            using (StringReader sr = new StringReader(optDenyList.Text))
            {
                try
                {
                    string str = "";
                    Front.Acl.DenyImportURL.Clear();
                    while (sr.Peek() > 0)
                    {
                        str = sr.ReadLine();
                        if (str.Length > 0 && Front.Acl.DenyImportURL.IndexOf(str) == -1)
                        {
                            Front.Acl.DenyImportURL.Add(str);
                        }
                    }
                }
                catch { }
            }
            ///同一インポートURL接続制限
            if (optSameImportIPKick.Checked)
            {
                Front.Acl.LimitSameImportURL = (uint)optSameImportIPNum.Value;
            }
            else
            {
                Front.Acl.LimitSameImportURL = 0;
            }
            ///長時間インポート接続制限
            if (optImportKick.Checked)
            {
                Front.Acl.ImportOutTime = (uint)optImportOutTime.Value;
            }
            else
            {
                Front.Acl.ImportOutTime = 0;
            }
            ///クライアント数制限
            if (optClientTimeKick.Checked)
            {
                Front.Acl.ClientOutCheck   = true;
                Front.Acl.ClientOutNum     = (uint)optClientNum.Value;
                Front.Acl.ClientOutTime    = (uint)optClientOutTime.Value;
                Front.Acl.ClientNotIPCheck = optClientNotIPEnable.Checked;
            }
            else
            {
                Front.Acl.ClientOutCheck   = false;
                Front.Acl.ClientOutNum     = 0;
                Front.Acl.ClientOutTime    = 10;
                Front.Acl.ClientNotIPCheck = false;
            }
            ///待機中ポートがあれば自動解放しない
            Front.Acl.PortFullOnlyCheck = optPortFullOnly.Checked;
            ///インポートURLと設定者IPの一致チェック
            Front.Acl.SetUserIpCheck = optSetUserIpCheck.Checked;
            #endregion

            #region 詳細設定
            //通信関連
            Front.Sock.SockConnTimeout   = (uint)optConnTimeOut.Value;
            Front.Sock.SockRecvTimeout   = (uint)optRecvTimeOut.Value;
            Front.Sock.SockSendTimeout   = (uint)optSendTimeOut.Value;
            Front.Sock.SockSendQueueSize = (uint)optSendQueueSize.Value;
            Front.Sock.SockCloseDelay    = (uint)optSockCloseDelay.Value;

            //その他詳細
            Front.Opt.BalloonTip      = optBalloonTip.Checked;
            Front.Opt.BrowserView     = optBrowser.Checked;
            Front.Opt.BrowserViewMode = optBrowserHtmlMode.Checked;
            Front.Opt.PriKagamiexe    = optPriKagamiexe.Checked;
            Front.Opt.PriKagamin      = optPriKagamin.Checked;
            Front.Acl.LimitSameClient = optSameClientKick.Checked ? (uint)optSameClientNum.Value : 0;
            Front.Opt.EnablePush      = optEnablePush.Checked;
            if (!optEnablePush.Checked)
            {
                foreach (Kagami _k in Front.KagamiList)
                {
                    _k.Status.DisablePull = false;
                }
            }
            Front.Opt.EnableInfo    = optEnableInfo.Checked;
            Front.Opt.EnableAdmin   = optEnableAdmin.Checked;
            Front.Opt.AdminPass     = optAdminPass.Text;
            Front.Opt.SndConnOkFile = optSndConnOK.Text;
            Front.Opt.SndConnNgFile = optSndConnNG.Text;
            Front.Opt.SndDiscFile   = optSndDisc.Text;
            #endregion

            #region スケジュール起動
            Front.ScheduleItem.Clear();
            for (int _num = 0; _num < scheduleDataView.Rows.Count - 1; _num++)
            {
                // 入力チェック
                if (//scheduleDataView[clmScheduleWeek.DisplayIndex, _num].Value == null ||
                    //scheduleDataView[clmScheduleHour.DisplayIndex, _num].Value == null ||
                    //scheduleDataView[clmScheduleMin.DisplayIndex, _num].Value == null ||
                    scheduleDataView[clmScheduleEvent.DisplayIndex, _num].Value == null)
                {
                    continue;
                }
                // ポート入力必須のイベントは、ポート番号の入力チェック
                string _port;
                switch (scheduleDataView[clmScheduleEvent.DisplayIndex, _num].Value.ToString())
                {
                case "強制切断":
                case "ポート待受開始":
                case "ポート待受停止":
                case "接続枠数変更":
                    if (scheduleDataView[clmSchedulePort.DisplayIndex, _num].Value == null)
                    {
                        continue;
                    }
                    _port = (string)scheduleDataView[clmSchedulePort.DisplayIndex, _num].Value;
                    break;

                default:
                    // とりあえずALLで登録しておく
                    _port = "ALL";
                    break;
                }

                // データ追加
                SCHEDULE _item = new SCHEDULE();
                if (scheduleDataView[clmScheduleEnable.DisplayIndex, _num].Value != null)
                {
                    _item.Enable = (bool)scheduleDataView[clmScheduleEnable.DisplayIndex, _num].Value;
                }
                else
                {
                    _item.Enable = false;
                }
                _item.Event = (uint)clmScheduleEvent.Items.IndexOf(scheduleDataView[clmScheduleEvent.DisplayIndex, _num].Value);
                if (_port == "ALL")
                {
                    _item.Port = 0;
                }
                else
                {
                    _item.Port = uint.Parse(_port);
                }
                string[] _str = scheduleDataView[clmScheduleData.DisplayIndex, _num].Value.ToString().Split(',');
                if (_str.Length == 9)
                {
                    _item.StartType = uint.Parse(_str[0]);
                    _item.Week      = uint.Parse(_str[1]);
                    _item.Hour      = uint.Parse(_str[2]);
                    _item.Min       = uint.Parse(_str[3]);
                    _item.TrfType   = uint.Parse(_str[4]);
                    _item.TrfValue  = uint.Parse(_str[5]);
                    _item.TrfUnit   = uint.Parse(_str[6]);
                    _item.ExecTrf   = false;
                    _item.Conn      = uint.Parse(_str[7]);
                    _item.Resv      = uint.Parse(_str[8]);
                }
                else
                {
                    throw new Exception("illigal schedule data");
                }
                Front.ScheduleItem.Add(_item);
            }
            #endregion
        }