//ウインドウサイズの復元 public void Read(Form form) { if (_reg == null) { //初期化に失敗している return; } if (form == null) { return; } if (_conf == null) { return; //リモート操作の時、ここでオプション取得に失敗する } var useLastSize = (bool)_conf.Get("useLastSize"); if (!useLastSize) { return; } int w = 0; int h = 0; try{ w = _reg.GetInt(string.Format("{0}_width", form.Text)); h = _reg.GetInt(string.Format("{0}_hight", form.Text)); } catch (Exception) { w = -1; h = -1; } if (h <= 0) { h = 400; } if (w <= 0) { w = 800; } form.Height = h; form.Width = w; try { int y = _reg.GetInt(string.Format("{0}_top", form.Text)); int x = _reg.GetInt(string.Format("{0}_left", form.Text)); if (y <= 0) { y = 0; } if (x <= 0) { x = 0; } form.Top = y; form.Left = x; } catch (Exception) { // 読み込めない場合は、何も処理しない } }
//データオブジェクトの追加 override public void Add(OneObj oneObj) { //オプション指定によるヘッダの追加処理 if (!(bool)_conf.Get("useBrowserHedaer")) { if ((bool)_conf.Get("addHeaderRemoteHost")) { // oneObj.Header[cs].Append(key,val); oneObj.Header[CS.Client].Append("Remote-Host-Wp", Encoding.ASCII.GetBytes(Define.ServerAddress())); } if ((bool)_conf.Get("addHeaderXForwardedFor")) { oneObj.Header[CS.Client].Append("X-Forwarded-For", Encoding.ASCII.GetBytes(Define.ServerAddress())); } if ((bool)_conf.Get("addHeaderForwarded")) { string str = string.Format("by {0} (Version {1}) for {2}", Define.ApplicationName(), _kernel.Ver.Version(), Define.ServerAddress()); oneObj.Header[CS.Client].Append("Forwarded", Encoding.ASCII.GetBytes(str)); } } if (_ar.Count == 0) { if (oneObj.Request.HttpVer != "HTTP/1.1") { KeepAlive = false;//非継続型 } } var oneProxyHttp = new OneProxyHttp(Proxy, this, oneObj); //キャッシュの確認 oneProxyHttp.CacheConform(_cache); _ar.Add(oneProxyHttp); }
//サーバ(OneServer)の生成 private void AddServer(Conf conf, OnePlugin onePlugin) { var protocol = (ProtocolKind)conf.Get("protocolKind"); //ProtocolKind protocol = ProtocolKind.ValueOf((int) conf.Get("protocolKind")); BindAddr bindAddr = (BindAddr)conf.Get("bindAddress2"); if (bindAddr.BindStyle != BindStyle.V4Only) { var oneBind = new OneBind(bindAddr.IpV6, protocol); var o = onePlugin.CreateServer(kernel, conf, oneBind); if (o != null) { Ar.Add((OneServer)o); } } if (bindAddr.BindStyle != BindStyle.V6Only) { var oneBind = new OneBind(bindAddr.IpV4, protocol); var o = onePlugin.CreateServer(kernel, conf, oneBind); if (o != null) { Ar.Add((OneServer)o); } } }
public void AuthTest(string user, string pass, bool expected) { //setUp var dir = (String)_conf.Get("dir"); var datUser = (Dat)_conf.Get("user"); var sut = new MailBox(new Logger(), datUser, dir); //var expected = true; //exercise var actual = sut.Auth(user, pass); //verify Assert.That(actual, Is.EqualTo(expected)); }
//�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); } }
///////////////////////////////////////////////////////////// // Load data from configuration. Intersect deltas to the currently active excludes and // implement any changes upon notification. private void LoadConfiguration() { Config config = Conf.Get(Conf.Names.FilesQueryableConfig); List <string[]> values = config.GetListOptionValues(Conf.Names.ExcludeSubdirectory); if (values != null) { foreach (string[] value in values) { AddExcludeDir(GetExcludeDirectory(value [0])); } } values = config.GetListOptionValues(Conf.Names.ExcludePattern); if (values != null) { foreach (string[] exclude in values) { // RemoveQuotes from beginning and end AddExcludePattern(exclude [0]); } } exclude_regex = StringFu.GetPatternRegex(exclude_patterns); Conf.WatchForUpdates(); Conf.Subscribe(Conf.Names.FilesQueryableConfig, OnConfigurationChanged); }
static private void ReadBackendsFromConf() { if (!to_read_conf || done_reading_conf) { return; } // set flag here to stop Allow() from calling ReadBackendsFromConf() again done_reading_conf = true; Config config = Conf.Get(Conf.Names.DaemonConfig); // To allow static indexes, "static" should be in allowed_queryables if (config.GetOption(Conf.Names.AllowStaticBackend, false)) { Allow("static"); } List <string[]> values = config.GetListOptionValues(Conf.Names.DeniedBackends); if (values == null) { return; } foreach (string[] name in values) { denied_queryables.Add(name [0].ToLower()); } }
protected override bool OnStartServer() { //ルートキャッシュの初期化 _rootCache = null; var namedCaPath = string.Format("{0}\\{1}", _kernel.ProgDir(), Conf.Get("rootCache")); if (File.Exists(namedCaPath)) { try { //named.ca読み込み用コンストラクタ var expire = (int)Conf.Get("soaExpire"); //var expire = (uint)Conf.Get("soaExpire"); _rootCache = new RrDb(namedCaPath, (uint)expire); Logger.Set(LogKind.Detail, null, 6, namedCaPath); } catch (IOException) { Logger.Set(LogKind.Error, null, 2, string.Format("filename={0}", namedCaPath)); } } else { Logger.Set(LogKind.Error, null, 3, namedCaPath); } //設定したドメイン情報を初期化する if (_cacheList != null) { _cacheList.Clear(); } _cacheList = new List <RrDb>(); var op = _kernel.ListOption.Get("DnsDomain"); if (op != null) { var domainList = (Dat)op.GetValue("domainList"); if (domainList != null) { foreach (OneDat o in domainList) { if (o.Enable) { //ドメインごとのリソースの読込 var domainName = o.StrList[0]; //Ver6.1.0 var authority = bool.Parse(o.StrList[1]); var res = _kernel.ListOption.Get("Resource-" + domainName); if (res != null) { var resource = (Dat)res.GetValue("resourceList"); var rrDb = new RrDb(Logger, Conf, resource, domainName, authority); _cacheList.Add(rrDb); Logger.Set(LogKind.Detail, null, 21, "Resource-" + domainName); } } } } } return(true); }
//パスワード変更 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); }
//bool CheckAuthList(string requestUri) { // // 【注意 ショートファイル名でアクセスした場合の、認証の回避を考慮する必要がある】 // //AnsiString S = ExtractShortPathName(ShortNamePath); // var authList = (Dat)this.Conf.Get("authList"); // foreach (var o in authList) { // if (!o.Enable) // continue; // string uri = o.StrList[0]; // if (requestUri.IndexOf(uri) == 0) { // return false; // } // } // return true; //} void AutoDeny(bool success, Ip remoteIp) { if (_attackDb == null) { return; } //データベースへの登録 if (!_attackDb.IsInjustice(success, remoteIp)) { return; } //ブルートフォースアタック if (AclList.Append(remoteIp)) //ACL自動拒否設定(「許可する」に設定されている場合、機能しない) //追加に成功した場合、オプションを書き換える { var d = (Dat)Conf.Get("acl"); var name = string.Format("AutoDeny-{0}", DateTime.Now); var ipStr = remoteIp.ToString(); d.Add(true, string.Format("{0}\t{1}", name, ipStr)); Conf.Set("acl", d); Conf.Save(Kernel.IniDb); Logger.Set(LogKind.Secure, null, 9000055, string.Format("{0},{1}", name, ipStr)); } else { Logger.Set(LogKind.Secure, null, 9000056, remoteIp.ToString()); } }
void AutoDeny(bool success, Ip remoteIp) { if (_attackDb == null) { return; } //�f�[�^�x�[�X�ւ̓o�^ if (!_attackDb.IsInjustice(success, remoteIp)) { return; } //�u���[�g�t�H�[�X�A�^�b�N if (!AclList.Append(remoteIp)) { return; //ACL�������ېݒ�(�u������v�ɐݒ肳��Ă���ꍇ�A�@�\���Ȃ�) } //�lj��ɐ��������ꍇ�A�I�v�V��������������� var d = (Dat)Conf.Get("acl"); var name = string.Format("AutoDeny-{0}", DateTime.Now); var ipStr = remoteIp.ToString(); d.Add(true, string.Format("{0}\t{1}", name, ipStr)); Conf.Set("acl", d); Conf.Save(Kernel.IniDb); //OneOption.SetVal("acl", d); //OneOption.Save(OptionIni.GetInstance()); Logger.Set(LogKind.Secure, null, 9000055, string.Format("{0},{1}", name, ipStr)); }
public void Start() { if (!initialized) { throw new Exception("Server must be initialized before starting"); } if (Shutdown.ShutdownRequested) { return; } this.running = true; if (!indexhelper) { Config config = Conf.Get(Conf.Names.NetworkingConfig); webinterface = config.GetOption("WebInterface", false); Conf.WatchForUpdates(); Conf.Subscribe(Conf.Names.NetworkingConfig, ConfigUpdateHandler); if (enable_network_svc || webinterface) { ExceptionHandlingThread.Start(new ThreadStart(this.HttpRun)); } } ExceptionHandlingThread.Start(new ThreadStart(this.RunInThread)); }
/// <summary> /// Just showing how to override and populate any other sub-stitution /// values for the template. /// </summary> /// <param name="msg"></param> public override void Notify(IDictionary msg) { // Allow the base class to send the email. msg["application"] = Conf.Get <string>("Application", "name"); msg["subject"] = _result.Success ? "StockMarketApp Successful" : "StockMarketApp FAILED"; msg["body"] = _result.Success ? "Success" : _result.Message; base.Notify(msg); }
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")); }
void TcpTunnel(SockTcp tcpObj) { var client = tcpObj; SockTcp server = null; //*************************************************************** // �T�[�o�Ƃ̐ڑ� //*************************************************************** { var port = _targetPort; //var ipList = new List<Ip>{new Ip(_targetServer)}; //if (ipList[0].ToString() == "0.0.0.0") { // ipList = Kernel.DnsCache.Get(_targetServer); // if(ipList.Count==0){ // Logger.Set(LogKind.Normal,null,4,string.Format("{0}:{1}",_targetServer,_targetPort)); // goto end; // } //} var ipList = Kernel.GetIpList(_targetServer); if (ipList.Count == 0) { Logger.Set(LogKind.Normal, null, 4, string.Format("{0}:{1}", _targetServer, _targetPort)); goto end; } foreach (var ip in ipList) { server = Inet.Connect(Kernel, ip, port, Timeout, null); if (server != null) { break; } } if (server == null) { Logger.Set(LogKind.Normal, server, 5, string.Format("{0}:{1}", _targetServer, _targetPort)); goto end; } } Logger.Set(LogKind.Normal, server, 6, string.Format("TCP {0}:{1} - {2}:{3}", client.RemoteHostname, client.RemoteAddress.Port, _targetServer, _targetPort)); //*************************************************************** // �p�C�v //*************************************************************** var tunnel = new Tunnel(Logger, (int)Conf.Get("idleTime"), Timeout); tunnel.Pipe(server, client, this); end: if (client != null) { client.Close(); } if (server != null) { server.Close(); } }
/// <summary> /// Send an email notification. /// </summary> public virtual void Notify() { // Check for null. var msg = new Dictionary <string, string>(); msg["emailTo"] = Conf.Get <string>("EmailSettings", "emailTo"); msg["emailFrom"] = Conf.Get <string>("EmailSettings", "emailFrom"); msg["emailSubject"] = Conf.Get <string>("EmailSettings", "emailSubject"); Notify(msg); }
public HttpConnectionHandler(System.Guid guid, HttpListenerContext context, HttpItemHandler item_handler) { this.id = guid; this.context = context; this.item_handler = item_handler; Config config = Conf.Get(Conf.Names.NetworkingConfig); network_node = config.GetOption("ServiceName", String.Empty); }
bool _cacheRefresh;//�L���b�V�����| 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); } }
void AuthError(SockTcp sockTcp, string user, string pass) { Logger.Set(LogKind.Secure, sockTcp, 3, string.Format("user={0} pass={1}", user, pass)); // �F�̃G���[�͂����ɕԓ���Ԃ��Ȃ� var authTimeout = (int)Conf.Get("authTimeout"); for (int i = 0; i < (authTimeout * 10) && IsLife(); i++) { Thread.Sleep(100); } sockTcp.AsciiSend(string.Format("-ERR Password supplied for {0} is incorrect.", user)); }
readonly int _multiple; //同時接続数 //ステータス表示用 public override String ToString() { var stat = IsJp ? "+ サービス中 " : "+ In execution "; if (ThreadBaseKind != ThreadBaseKind.Running) { stat = IsJp ? "- 停止 " : "- Initialization failure "; } return(string.Format("{0}\t{1,20}\t[{2}\t:{3} {4}]\tThread {5}/{6}", stat, NameTag, _oneBind.Addr, _oneBind.Protocol.ToString().ToUpper(), (int)Conf.Get("port"), Count(), _multiple)); }
//******************************************************** // Host:ヘッダを見て、バーチャルホストの設定にヒットした場合は // オプション等を置き換える //******************************************************** void ReplaceVirtualHost(string host, IPAddress ip, int port) { //Ver5.0.0-b12 if (host == null) { return; } //Ver5.0.0-a6 仮想Webの検索をホスト名(アドレス)+ポート番号に修正 for (int n = 0; n < 2; n++) { if (n == 0) //1回目はホスト名で検索する //Ver5.0.0-a6 「ホスト名:ポート番号」の形式で検索する { if (host.IndexOf(':') < 0) { host = string.Format("{0}:{1}", host, port); } host = host.ToUpper(); //ホスト名は、大文字・小文字を区別しない } else //2回目はアドレスで検索する { host = string.Format("{0}:{1}", ip, port); } //バーチャルホスト指定の場合オプションを変更する foreach (var op in WebOptionList) { //先頭のWeb-を削除する string name = op.NameTag.Substring(4).ToUpper(); if (name == host) { if (op.NameTag != Conf.NameTag) { //Ver5.1.4 webDavDbを置き換える foreach (var db in _webDavDbList) { if (db.NameTag == op.NameTag) { _webDavDb = db; } } //オプション及びロガーを再初期化する //OneOption = op; Conf = new Conf(op); Logger = Kernel.CreateLogger(op.NameTag, (bool)Conf.Get("useDetailsLog"), this); } return; } } } }
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); //アクセス元プログラム制限 var allowProg = (Dat)Conf.Get("limitSrcProgAllow"); var denyProg = (Dat)Conf.Get("limitSrcProgDeny"); _limitSrcProg = new LimitSrcProg(this.Logger, allowProg, denyProg); //リクエストを通常ログで表示する _useRequestLog = (bool)Conf.Get("useRequestLog"); //コンテンツ制限 _limitString = new LimitString((Dat)Conf.Get("limitString")); if (_limitString.Length == 0) { _limitString = null; } _dataPort = DataPortMin; }
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"); }
// 拡張子から、Mimeタイプを取得する sendPath()で使用される public string Get(string fileName) { var ext = Path.GetExtension(fileName); //パラメータにドットから始まる拡張子が送られた場合、内部でドット無しに修正する if (ext != null) { if (ext.Length > 0 && ext[0] == '.') { ext = ext.Substring(1); } } var mimeList = (Dat)_conf.Get("mime"); //mimeListからextの情報を検索する string mimeType = null; if (ext != null) { foreach (var o in mimeList) { if (o.StrList[0].ToUpper() != ext.ToUpper()) { continue; } mimeType = o.StrList[1]; break; } } if (mimeType == null) { //拡張子でヒットしない場合は、「.」での設定を検索する //DOTO Dat2.Valの実装をやめたのので動作確認が必要 //mimeType = (string)mimeList.Val(0,".",1); //mimeType = null; foreach (var o in mimeList.Where(o => o.StrList[0] == ".")) { mimeType = o.StrList[1]; break; } if (mimeType == null) { mimeType = "application/octet-stream";//なにもヒットしなかった場合 } } return(mimeType); }
override protected void OnRunThread() { //[C#] ThreadBaseKind = ThreadBaseKind.Running; var hour = (int)_conf.Get("testTime"); SetTimer(hour);//�^�C�}�[�ݒ� long lastSize = 0; while (IsLife()) { if (_cacheRefresh) { logger.Set(LogKind.Normal, null, 23, string.Format("Interval={0}h", hour)); _cacheRefresh = false; var infoList = new List <CacheInfo>(); try { long size = _diskCache.GetInfo(ref infoList, 1, this); if (size != lastSize) { infoList.Sort((x, y) => x != null ? x.LastAccess.CompareTo(y.LastAccess) : 0); for (int i = 0; IsLife() && _diskSize * 1024 < size; i++) { size -= infoList[i].Size; if (!Remove(CacheKind.Disk, infoList[i].HostName, infoList[i].Port, infoList[i].Uri)) { break; } } lastSize = size; } } catch (Exception ex) { logger.Set(LogKind.Error, null, 27, ex.Message); } SetTimer(hour);//�^�C�}�[�ݒ� logger.Set(LogKind.Normal, null, 24, string.Format("Interval={0}h", hour)); } else { Thread.Sleep(300); } } _timer.Dispose(); }
readonly string _wpadUrl; //WPAD //�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(); }
public void Start() { try { GMime.Global.Init(); } catch (Exception e) { Log.Error(e, "Unable to initialize GMime"); return; } Config config = Conf.Get("GoogleBackends"); ReadConf(config); Conf.WatchForUpdates(); Conf.Subscribe("GoogleBackends", delegate(Config new_config) { ReadConf(new_config); }); }
//�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; }
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; }
override protected bool OnStartServer() { if (_agent != null) { _agent.Start(); } //Ver5.9.8 if (Kernel.MailBox == null || !Kernel.MailBox.Status) { return(false); } //fetchList = (Dat) conf.Get("fetchList"); //_timeout = (int) conf.Get("timeOut"); //_sizeLimit = (int) conf.Get("sizeLimit"); _fetch = new Fetch(Kernel, _mailSave, DomainList[0], (Dat)Conf.Get("fetchList"), (int)Conf.Get("timeOut"), (int)Conf.Get("sizeLimit")); _fetch.Start(); return(true); }