public ActionResult Edit(Ip ip) { if (ModelState.IsValid) { ipRepository.UpdateIp(ip); ipRepository.Save(); return RedirectToAction("Index"); } ViewBag.SubnetId = new SelectList(subnetRepository.GetSubnets(), "SubnetId", "Network", ip.SubnetId); return View(ip); }
public TestInfo(Ip addr, int port = 443) { IP = addr; Port = port; HttpOk = PortOk = false; PortTime = 0; PortMsg = HttpMsg = "n/a"; PassCount = 0; Bandwidth = "n/a"; CName = "n/a"; }
public TestMail(string from, string to, string bodyStr) { this.Mail = new Mail(null); Mail.Init(Encoding.ASCII.GetBytes("\r\n"));//区切り行(ヘッダ終了) var body = Encoding.ASCII.GetBytes(bodyStr); Mail.Init(body); Mail.AddHeader("from", from); Mail.AddHeader("to", to); var host = "TEST"; var addr = new Ip("10.0.0.1"); MlEnvelope = new MlEnvelope(CreateMailAddress(from), CreateMailAddress(to), host, addr); }
public async Task GetPublicIp_should_usually_return_a_valid_ip() { var myIp = await Ip.GetPublicIpAsync(); myIp.Should().NotBe(default(IPAddress)); }
public Job(Rid rid, Ip ip, int time) { this.rid = rid; this.ip = ip; this.time = time; }
//*************************************************************** // パイプ(FTP) //*************************************************************** int PipeFtp(Dictionary<CS, TcpObj> sock, Request request,int dataPort) { DataThread dataThread = null; //ユーザ名及びパスワード string user = "******"; string pass = this.OpBase.ValString("anonymousAddress"); //Ver5.0.0-a23 URLで指定されたユーザ名およびパスワードを使用する if(request.User != null) user = request.User; if(request.Pass != null) pass = request.Pass; //wait 220 welcome if(!WaitLine(sock,"220")) goto end; sock[CS.SERVER].AsciiSend(string.Format("USER {0}",user),OPERATE_CRLF.YES); if(!WaitLine(sock,"331")) goto end; sock[CS.SERVER].AsciiSend(string.Format("PASS {0}",pass),OPERATE_CRLF.YES); if(!WaitLine(sock,"230")) goto end; //URIをパスとファイル名に分解する string path = request.Uri; string file = ""; int index = request.Uri.LastIndexOf('/'); if (index < request.Uri.Length - 1) { path = request.Uri.Substring(0, index); file = request.Uri.Substring(index + 1); } //リクエスト if (path != "") { sock[CS.SERVER].AsciiSend(string.Format("CWD {0}",path),OPERATE_CRLF.YES); if (!WaitLine(sock, "250")) goto end; } if (file == "") { sock[CS.SERVER].AsciiSend("TYPE A",OPERATE_CRLF.YES); } else { sock[CS.SERVER].AsciiSend("TYPE I",OPERATE_CRLF.YES); } if(!WaitLine(sock,"200")) goto end; //PORTコマンド送信 Ip bindAddr = new Ip(sock[CS.SERVER].LocalEndPoint.Address.ToString()); // 利用可能なデータポートの選定 int listenMax = 1; SSL ssl = null; TcpObj listenObj=null; while(life){ listenObj = new TcpObj(kanel, this.Logger,bindAddr, dataPort++, listenMax, ssl); if (listenObj.State != SOCKET_OBJ_STATE.ERROR) break; } if(listenObj==null) goto end; //データスレッドの生成 dataThread = new DataThread(this.Logger, listenObj); // サーバ側に送るPORTコマンドを生成する string str = string.Format("PORT {0},{1},{2},{3},{4},{5}",bindAddr.IpV4[0],bindAddr.IpV4[1],bindAddr.IpV4[2],bindAddr.IpV4[3],(listenObj.LocalEndPoint.Port) / 256,(listenObj.LocalEndPoint.Port) % 256); sock[CS.SERVER].AsciiSend(str,OPERATE_CRLF.YES); if(!WaitLine(sock,"200")) goto end; if(file==""){ sock[CS.SERVER].AsciiSend("LIST",OPERATE_CRLF.YES); if(!WaitLine(sock,"150")) goto end; }else{ sock[CS.SERVER].AsciiSend("RETR " + file,OPERATE_CRLF.YES); if(!WaitLine(sock,"150")) goto end; } if(!WaitLine(sock,"226")) goto end; byte[] doc = new byte[0]; if (file == "") { //受信結果をデータスレッドから取得する List<string> lines = Inet.GetLines(dataThread.ToString()); //FTPサーバから取得したLISTの情報をHTMLにコンバートする doc = ConvFtpList(lines, path); } else { doc = dataThread.ToBytes(); } //クライアントへリプライ及びヘッダを送信する Header header = new Header(); header.Replace("Server",Util.SwapStr("$v",kanel.Ver.Version(),this.OpBase.ValString("serverHeader"))); header.Replace("MIME-Version","1.0"); if (file == "") { header.Replace("Date",Util.UtcTime2Str(DateTime.UtcNow)); header.Replace("Content-Type","text/html"); } else { header.Replace("Content-Type","none/none"); } header.Replace("Content-Length",doc.Length.ToString()); sock[CS.CLIENT].AsciiSend("HTTP/1.0 200 OK",OPERATE_CRLF.YES);//リプライ送信 sock[CS.CLIENT].Send(header.GetBytes());//ヘッダ送信 sock[CS.CLIENT].Send(doc);//ボディ送信 end: if (dataThread != null) dataThread.Dispose(); return dataPort; }
/// <summary> /// Allows you to pass an array of strings that contain the IP Addresses /// to block. /// /// Wildcard IPs should use .* or .0 to indicate blocks. /// /// Note this string list should contain ALL IP addresses to block /// not just new and added ones (ie. use GetList first and then /// add to the list. /// </summary> /// <param name="IPStrings"></param> public void SetIpList(string[] IPStrings) { this.Open(); object IPSecurity = IIS.Properties["IPSecurity"].Value; // *** IMPORTANT: This list MUST be object or COM call will fail! List <object> newIpList = new List <object>(); foreach (string Ip in IPStrings) { string newIp; if (Ip.EndsWith(".*.*.*") || Ip.EndsWith(".0.0.0")) { newIp = Ip.Replace(".*", ".0") + ",255.0.0.0"; } else if (Ip.EndsWith(".*.*") || Ip.EndsWith(".0.0")) { newIp = Ip.Replace(".*", ".0") + ",255.255.0.0"; } else if (Ip.EndsWith(".*") || Ip.EndsWith(".0")) { // *** Wildcard requires different IP Mask newIp = Ip.Replace(".*", ".0") + ",255.255.255.0"; } else { newIp = Ip + ", 255.255.255.255"; } // *** Check for dupes - nasty but required because // *** object -> string comparison can't do BinarySearch bool found = false; foreach (string tempIp in newIpList) { if (newIp == tempIp) { found = true; break; } } if (!found) { newIpList.Add(newIp); } } //wwUtils.SetPropertyCom(this.IPSecurity, "GrantByDefault", true); IPSecurity.GetType().InvokeMember("GrantByDefault", BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty, null, IPSecurity, new object[] { true }); object[] ipList = newIpList.ToArray(); // *** Apply the new list //wwUtils.SetPropertyCom(this.IPSecurity, "IPDeny",ipList); IPSecurity.GetType().InvokeMember("IPDeny", BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty, null, IPSecurity, new object[] { ipList }); IIS.Properties["IPSecurity"].Value = IPSecurity; IIS.CommitChanges(); IIS.RefreshCache(); this.Close(); }
public abstract bool IsHit(Ip ip);
readonly uint _soaExpire;//終了時間(オプションで指定された有効時間) //named.caで初期化する場合 //public DnsCache(Logger logger, OneOption oneOption, string fileName) { public DnsCache(OneOption oneOption, string fileName) { uint ttl = 0;//rootCacheは有効期限なし //オプションを読み込んで、ローカルデータを初期化する //this.oneOption = oneOption; _soaExpire = (uint)(int)oneOption.GetValue("soaExpire"); DomainName = "."; //this.defaultExpire = defaultExpire; if (File.Exists(fileName)) { using (var sr = new StreamReader(fileName, Encoding.GetEncoding("Shift_JIS"))) { var tmpName = "";//全行のNAMEを保持する NAMEは前行と同じ場合省略が可能 while (true) { var name = ""; //string Class = "IN"; var dnsType = DnsType.Unknown; var str = sr.ReadLine(); if (str == null) { break; } //;以降はコメントとして削除する var i = str.IndexOf(';'); if (i != -1) { str = str.Substring(0, i); } //空の行は処理しない if (str.Length == 0) { continue; } //空白・タブを削除して、パラメータをtmp2へ取得する var tmp = str.Split(new[] { ' ', '\t' }); var tmp2 = tmp.Where(s => s != "").ToList(); //************************************************ //タイプだけは省略することができないので、それを基準にサーチする //************************************************ var typeCol = 0; for (; typeCol < tmp2.Count; typeCol++) { foreach (DnsType t in Enum.GetValues(typeof(DnsType))) { if (tmp2[typeCol] != t.ToString().ToUpper()) { continue; } dnsType = t; break; } if (dnsType != DnsType.Unknown) { break; } } if (dnsType == DnsType.Unknown) { goto err;//タイプが見つからない場合は、無効行とする } //タイプの次がDATAとなる if (typeCol + 1 >= tmp2.Count) { goto err; //タイプの次にカラム(DATA)が存在しない } string dataStr = tmp2[typeCol + 1]; //************************************************ //クラス(IN)が含まれているかどうかをサーチする //************************************************ var classCol = 0; for (; classCol < tmp2.Count; classCol++) { if (tmp2[classCol] != "IN") { continue; } goto find; } classCol = -1; find: //クラスが含まれた場合、そのカラムはclassColに保存されている //含まれていない場合 classCol=-1 if (typeCol == 1) { if (classCol == -1) //INが無い場合 //0番目はNAME若しくはTTLとなる { if (str.Substring(0, 1) == " " || str.Substring(0, 1) == "\t") { //名前は省略されているので ttl = Convert.ToUInt32(tmp2[0]); ttl = Util.htonl(ttl); } else { name = tmp2[0]; } } else //INが有る場合 { if (classCol != 0) { goto err;//位置がおかしい } //0番目はINであるので、名前もTTLも省略されている } } else if (typeCol == 2) { if (classCol == -1) //INが無い場合 //0番目はNAME、1番目はTTLとなる { name = tmp2[0]; ttl = Convert.ToUInt32(tmp2[1]); ttl = Util.htonl(ttl); } else //INが有る場合 { if (classCol != 1) { goto err;//位置がおかしい } //0番目はNAME若しくはTTLとなる if (str.Substring(0, 1) == " " || str.Substring(0, 1) == "\t") { //名前は省略されているので ttl = Convert.ToUInt32(tmp2[0]); ttl = Util.htonl(ttl); } else { name = tmp2[0]; } } } else if (typeCol == 3) { if (classCol == -1) //INが無い場合 //カラム不足 { goto err; } //INが有る場合 if (classCol != 2) { goto err;//位置がおかしい } //0番目はNAME、1番目はTTLとなる name = tmp2[0]; ttl = Convert.ToUInt32(tmp2[1]); ttl = Util.htonl(ttl); } //********************************************* //nameの補完 //********************************************* if (name == "@") //@の場合 { name = DomainName; } else if (name.LastIndexOf('.') != name.Length - 1) //最後に.がついていない場合、ドメイン名を追加する { name = name + "." + DomainName + "."; } else if (name == "") { name = tmpName; //前行と同じ } tmpName = name; //前行分として記憶する //********************************************* //string sataStr を変換してデータベースに追加 //********************************************* if (dnsType == DnsType.A) { var ipV4 = new Ip(dataStr); Add(new OneRR(name, dnsType, ttl, ipV4.NetBytes())); } else if (dnsType == DnsType.Ns) { Add(new OneRR(name, dnsType, ttl, DnsUtil.Str2DnsName(dataStr))); } else if (dnsType == DnsType.Aaaa) { var ipV6 = new Ip(dataStr); Add(new OneRR(name, dnsType, ttl, ipV6.NetBytes())); } else { Msg.Show(MsgKind.Error, "name.caには、タイプA,AAAA及びNS以外は使用できません。"); goto err; } continue; err: //行に矛盾が有る Msg.Show(MsgKind.Error, string.Format("ServerDnsCache() レコード読み込みエラー 矛盾があります。[ {0} {1} ]", fileName, str)); } sr.Close(); } } //locaohostレコードの追加 { var ip = new Ip("127.0.0.1"); Add(new OneRR("localhost.", DnsType.A, ttl, ip.NetBytes())); Add(new OneRR("1.0.0.127.in-addr.arpa.", DnsType.Ptr, ttl, DnsUtil.Str2DnsName("localhost"))); ip = new Ip("::1"); Add(new OneRR("localhost.", DnsType.Aaaa, ttl, ip.NetBytes())); Add(new OneRR("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.ARPA.", DnsType.Ptr, ttl, DnsUtil.Str2DnsName("localhost"))); } }
public void StartClipboardCheck() { while (true) { string s = Clipboard.GetText(); if (s != oldclip && s.Length > 0) { oldclip = s; MatchCollection _Matches = Regex.Matches(s, @"\b((?:[0-9]{1,3}\.){3}[0-9]{1,3})\b[\s:]+(\d+)"); Trace.WriteLine("<<<<<<ClipBoard Received>>>>>>>>" + _Matches.Count + " Matches"); foreach (Match _Match in _Matches) { Ip _Ip = new Ip(); _Ip.ip = _Match.Groups[1].Value; _Ip.port = int.Parse(_Match.Groups[2].Value); if((from ip in _Ips where ip.ip == _Ip.ip && ip.port == _Ip.port select ip).FirstOrDefault()==null && (from ip in _List where ip.ip == _Ip.ip && ip.port == _Ip.port select ip).FirstOrDefault() == null) _Ips.Push(_Ip); } } Thread.Sleep(100); } }
//コンストラクタ public AclV6(string name, string ipStr) : base(name) { //「*」によるALL指定 if (ipStr == "*" || ipStr == "*:*:*:*:*:*:*:*") { Start = new Ip(IpKind.V6_0); End = new Ip(IpKind.V6_FF); Status = true; return;//初期化成功 } string[] tmp; if (ipStr.IndexOf('-') != -1) { //************************************************************ // 「-」による範囲指定 //************************************************************ tmp = ipStr.Split('-'); if (tmp.Length != 2) { ThrowException(ipStr); //初期化失敗 } try{ Start = new Ip(tmp[0]); End = new Ip(tmp[1]); }catch (ValidObjException) { ThrowException(ipStr); //初期化失敗 } //開始アドレスが終了アドレスより大きい場合、入れ替える if (Start.AddrV6H == End.AddrV6H) { if (Start.AddrV6L > End.AddrV6L) { Swap(); // startとendの入れ替え } } else { if (Start.AddrV6H > End.AddrV6H) { Swap(); // startとendの入れ替え } } } else if (ipStr.IndexOf('/') != -1) { //************************************************************ // 「/」によるマスク指定 //************************************************************ tmp = ipStr.Split('/'); if (tmp.Length != 2) { ThrowException(ipStr); //初期化失敗 } var strIp = tmp[0]; var strMask = tmp[1]; UInt64 maskH = 0; UInt64 maskL = 0; UInt64 xorH = 0; UInt64 xorL = 0; try { UInt64 m = Convert.ToUInt64(strMask); if (128 < m) { //マスクは128ビットが最大 ThrowException(ipStr); //初期化失敗 } for (UInt64 i = 0; i < 64; i++) { if (i != 0) { maskH = maskH << 1; } if (i < m) { maskH = (maskH | 1); } } xorH = (0xffffffffffffffff ^ maskH); for (UInt64 i = 64; i < 128; i++) { if (i != 0) { maskL = maskL << 1; } if (i < m) { maskL = (maskL | 1); } } xorL = (0xffffffffffffffff ^ maskL); } catch { ThrowException(ipStr); //初期化失敗 } try{ var ip = new Ip(strIp); Start = new Ip(ip.AddrV6H & maskH, ip.AddrV6L & maskL); End = new Ip(ip.AddrV6H | xorH, ip.AddrV6L | xorL); } catch (ValidObjException) { ThrowException(ipStr); //初期化失敗 } } else { //************************************************************ // 通常指定 //************************************************************ try { Start = new Ip(ipStr); End = new Ip(ipStr); } catch (ValidObjException) { ThrowException(ipStr); //初期化失敗 } } if (Start.InetKind != InetKind.V6) { ThrowException(ipStr); //初期化失敗 } if (End.InetKind != InetKind.V6) { ThrowException(ipStr); //初期化失敗 } Status = true; //初期化成功 }
protected override void Init() { Start = new Ip(IpKind.V6_0); End = new Ip(IpKind.V6_FF); }
public string BankCardActivate(int cid = 0, int UserId = 0, int BankID = 0, int ChannelType = 0) { userEventDao.BankCardActivate(cid, UserId, Ip.GetClientIp(), 0, TQuery.GetString("version"), BankID, ChannelType); Logic.ChannelType ct = (Logic.ChannelType)ChannelType; var ubk = userBankCardDao.Single(BankID); //Thread.Sleep(3000); //return ApiReturnStr.getError(0, "验证码发送成功"); if (ubk == null) { return(ApiReturnStr.getError(-100, "银行卡不存在")); } if (ubk.UserId != UserId) { return(ApiReturnStr.getError(-100, "此卡不属于该用户")); } switch (ct) { case Logic.ChannelType.易宝: return(ApiReturnStr.getError(-100, "易宝通道无需激活")); case Logic.ChannelType.荣邦科技积分: case Logic.ChannelType.荣邦科技无积分: case Logic.ChannelType.荣邦3: //进件 if (!masgetUserDao.QueryIsExist(UserId, ChannelType)) { var resultSubcompany = MasgetDepository.SubcompanyAdd(UserId, cid, ct); if (resultSubcompany.backState != 0) { return(ApiReturnStr.getError(-100, $"开户失败({resultSubcompany.message},ct={ChannelType})")); } } //入驻 if (!masgetUserDao.QueryIsOpen(UserId, ChannelType)) { var resultSamenameOpen = MasgetDepository.SamenameOpen(UserId, cid, ct); if (resultSamenameOpen.backState != 0) { return(ApiReturnStr.getError(-100, $"入驻失败({resultSamenameOpen.message},ct={ChannelType})")); } } if (bankTreatyApplyDao.QueryTreatycodeIsOpen(BankID, ChannelType)) { return(ApiReturnStr.getError(-100, "此通道已开通快捷协议")); } //发送验证码 var resultTreatyApply = MasgetDepository.TreatyApply(BankID, cid, ct); if (resultTreatyApply.backState != 0) { return(ApiReturnStr.getError(-100, $"申请开通快捷协议失败({resultTreatyApply.message})")); } else { return(ApiReturnStr.getError(0, "验证码发送成功")); } default: break; } return(ApiReturnStr.getError(-100, "参数错误")); }
readonly uint _soaExpire; //終了時間(オプションで指定された有効時間) #endregion Fields #region Constructors //named.caで初期化する場合 //public DnsCache(Logger logger, OneOption oneOption, string fileName) { public DnsCache(OneOption oneOption, string fileName) { uint ttl = 0;//rootCacheは有効期限なし //オプションを読み込んで、ローカルデータを初期化する //this.oneOption = oneOption; _soaExpire = (uint)(int)oneOption.GetValue("soaExpire"); DomainName = "."; //this.defaultExpire = defaultExpire; if (File.Exists(fileName)) { using (var sr = new StreamReader(fileName, Encoding.GetEncoding("Shift_JIS"))) { var tmpName = "";//全行のNAMEを保持する NAMEは前行と同じ場合省略が可能 while (true) { var name = ""; //string Class = "IN"; var dnsType = DnsType.Unknown; var str = sr.ReadLine(); if (str == null) break; //;以降はコメントとして削除する var i = str.IndexOf(';'); if (i != -1) str = str.Substring(0, i); //空の行は処理しない if (str.Length == 0) continue; //空白・タブを削除して、パラメータをtmp2へ取得する var tmp = str.Split(new[] { ' ', '\t' }); var tmp2 = tmp.Where(s => s != "").ToList(); //************************************************ //タイプだけは省略することができないので、それを基準にサーチする //************************************************ var typeCol = 0; for (; typeCol < tmp2.Count; typeCol++) { foreach (DnsType t in Enum.GetValues(typeof(DnsType))) { if (tmp2[typeCol] != t.ToString().ToUpper()) continue; dnsType = t; break; } if (dnsType != DnsType.Unknown) break; } if (dnsType == DnsType.Unknown) goto err;//タイプが見つからない場合は、無効行とする //タイプの次がDATAとなる if (typeCol + 1 >= tmp2.Count) goto err; //タイプの次にカラム(DATA)が存在しない string dataStr = tmp2[typeCol + 1]; //************************************************ //クラス(IN)が含まれているかどうかをサーチする //************************************************ var classCol = 0; for (; classCol < tmp2.Count; classCol++){ if (tmp2[classCol] != "IN") continue; goto find; } classCol = -1; find: //クラスが含まれた場合、そのカラムはclassColに保存されている //含まれていない場合 classCol=-1 if (typeCol == 1) { if (classCol == -1) { //INが無い場合 //0番目はNAME若しくはTTLとなる if (str.Substring(0, 1) == " " || str.Substring(0, 1) == "\t") { //名前は省略されているので ttl = Convert.ToUInt32(tmp2[0]); ttl = Util.htonl(ttl); } else { name = tmp2[0]; } } else { //INが有る場合 if (classCol != 0) goto err;//位置がおかしい //0番目はINであるので、名前もTTLも省略されている } } else if (typeCol == 2) { if (classCol == -1) { //INが無い場合 //0番目はNAME、1番目はTTLとなる name = tmp2[0]; ttl = Convert.ToUInt32(tmp2[1]); ttl = Util.htonl(ttl); } else { //INが有る場合 if (classCol != 1) goto err;//位置がおかしい //0番目はNAME若しくはTTLとなる if (str.Substring(0, 1) == " " || str.Substring(0, 1) == "\t") { //名前は省略されているので ttl = Convert.ToUInt32(tmp2[0]); ttl = Util.htonl(ttl); } else { name = tmp2[0]; } } } else if (typeCol == 3) { if (classCol == -1) { //INが無い場合 //カラム不足 goto err; } //INが有る場合 if (classCol != 2) goto err;//位置がおかしい //0番目はNAME、1番目はTTLとなる name = tmp2[0]; ttl = Convert.ToUInt32(tmp2[1]); ttl = Util.htonl(ttl); } //********************************************* //nameの補完 //********************************************* if (name == "@") { //@の場合 name = DomainName; } else if (name.LastIndexOf('.') != name.Length - 1) { //最後に.がついていない場合、ドメイン名を追加する name = name + "." + DomainName + "."; } else if (name == "") { name = tmpName;//前行と同じ } tmpName = name;//前行分として記憶する //********************************************* //string sataStr を変換してデータベースに追加 //********************************************* if (dnsType == DnsType.A) { var ipV4 = new Ip(dataStr); Add(new OneRR(name, dnsType, ttl, ipV4.NetBytes())); } else if (dnsType == DnsType.Ns) { Add(new OneRR(name, dnsType, ttl, DnsUtil.Str2DnsName(dataStr))); } else if (dnsType == DnsType.Aaaa) { var ipV6 = new Ip(dataStr); Add(new OneRR(name, dnsType, ttl, ipV6.NetBytes())); } else { Msg.Show(MsgKind.Error, "name.caには、タイプA,AAAA及びNS以外は使用できません。"); goto err; } continue; err://行に矛盾が有る Msg.Show(MsgKind.Error, string.Format("ServerDnsCache() レコード読み込みエラー 矛盾があります。[ {0} {1} ]", fileName, str)); } sr.Close(); } } //locaohostレコードの追加 { var ip = new Ip("127.0.0.1"); Add(new OneRR("localhost.", DnsType.A, ttl, ip.NetBytes())); Add(new OneRR("1.0.0.127.in-addr.arpa.", DnsType.Ptr, ttl, DnsUtil.Str2DnsName("localhost"))); ip = new Ip("::1"); Add(new OneRR("localhost.", DnsType.Aaaa, ttl, ip.NetBytes())); Add(new OneRR("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.ARPA.", DnsType.Ptr, ttl, DnsUtil.Str2DnsName("localhost"))); } }
public string BankBind(int cid = 0, int UserId = 0, string mobile = "", string bankcard = "", string bankcode = "", int typeid = 0, string cvn2 = "", string expiresYear = "", string expiresMouth = "", string OpeningBank = "", string OpeningSerialBank = "", int BankID = 0) { Logs.WriteLog($"Action:User,Cmd:BankBind,UserId:{UserId},mobile:{mobile},bankcard:{bankcard},bankcode:{bankcode},typeid:{typeid},cvn2:{cvn2},expiresYear:{expiresYear},expiresMouth:{expiresMouth},OpeningBank:{OpeningBank},OpeningSerialBank:{OpeningSerialBank}", "d:\\Log\\ITOrm", "BankBind"); userEventDao.UserBankBind(cid, UserId, Ip.GetClientIp(), mobile, bankcard, bankcode, typeid, cvn2, expiresYear, expiresMouth, OpeningBank, OpeningSerialBank, BankID); var version = TQuery.GetString("version"); if (cid == 3 && version == "1.0.0") { string temp = expiresYear; expiresYear = expiresMouth; expiresMouth = temp; } #region 验证 if (!TypeParse.IsMobile(mobile)) { return(ApiReturnStr.getError(-100, "预留手机号格式验证失败")); } if (!(bankcard.Length > 13 && bankcard.Length < 21)) { return(ApiReturnStr.getError(-100, "银行卡参数错误")); } if (string.IsNullOrEmpty(bankcode)) { return(ApiReturnStr.getError(-100, "银行编号不能为空")); } Users user = userDao.Single(UserId); if (user == null || user.UserId <= 0) { return(ApiReturnStr.getError(-100, "用户不存在")); } if (user.IsRealState != 1) { return(ApiReturnStr.getError(-100, "用户未实名认证,无法绑卡")); } if (typeid == 1)//如果是结算卡 { if (string.IsNullOrEmpty(cvn2) || string.IsNullOrEmpty(expiresYear) || string.IsNullOrEmpty(expiresMouth)) { return(ApiReturnStr.getError(-100, "支付卡参数有误")); } if (BankID == 0) { UserBankCard ubc = userBankCardDao.Single(" UserId=@UserId and BankCard=@bankcard and TypeId=1 ", new { UserId, bankcard }); if (ubc != null && ubc.ID > 0) { return(ApiReturnStr.getError(-100, "该支付卡已经绑定过,不能重复绑定")); } } } else { UserBankCard ubc = userBankCardDao.Single(" UserId=@UserId and TypeId=0 and State=1 ", new { UserId }); if (ubc != null && ubc.ID > 0) { return(ApiReturnStr.getApiData(-100, "结算卡只能绑定一张")); } } UserBankCard model = null; if (BankID > 0) { model = userBankCardDao.Single(BankID); if (model == null) { return(ApiReturnStr.getApiData(-100, "BankID记录不存在")); } if (model.State == 1) { return(ApiReturnStr.getApiData(-100, "该银行卡已通过验证,不可修改信息")); } } else { model = new UserBankCard(); } #endregion #region 绑卡 var result = BankCardBindHelper.Bind(typeid, user.RealName, user.IdCard, bankcard, mobile, cvn2, expiresYear, expiresMouth); model.BankCard = result.bankCard; model.BankCode = bankcode; model.BankName = bankDao.QueryBankName(bankcode); model.CVN2 = cvn2; model.ExpiresYear = expiresYear; model.ExpiresMouth = expiresMouth; model.UTime = DateTime.Now; model.Mobile = mobile; model.TypeId = typeid; model.OpeningBank = OpeningBank; model.OpeningSerialBank = OpeningSerialBank; model.State = 0;// result.backState ? 1 : 0;//默认为0 model.RelationId = ",0,"; bool flag = false; if (BankID == 0) { model.UserId = UserId; model.IP = Ip.GetClientIp(); model.CTime = DateTime.Now; model.Platform = cid; int num = userBankCardDao.Insert(model); flag = num > 0; return(ApiReturnStr.getError(flag ? 0 : -100, flag ? "绑定成功" : "绑定失败")); } else { var list = bankTreatyApplyDao.GetQuery(" State=2 And UbkID=@BankID", new { BankID }); if (list != null && list.Count > 0) { foreach (var item in list) { MasgetDepository.TreatyModify(BankID, cvn2, expiresYear, expiresMouth, cid, (Logic.ChannelType)item.ChannelType); } } flag = userBankCardDao.Update(model); return(ApiReturnStr.getError(flag ? 0 : -100, flag ? "修改成功" : "修改失败")); } #endregion }
public override int GetHashCode() { return(Ip.GetHashCode() ^ Port.GetHashCode() ^ Application.GetHashCode()); }
public bool IsHit(Ip ip) { return(ip.InetKind == InetKind.V4 ? _arV4.Any(p => p.IsHit(ip)) : _arV6.Any(p => p.IsHit(ip))); }
private Network.Network ExampleNetwork() { // Simple network: [R1] --i1--i2-- [R2] --i3--i4-- [R3] // setup interfaces Interface i1 = new Interface(); i1.Name = "i1"; i1.GreTunnel = (Ip.Parse("1.2.3.4"), Ip.Parse("5.6.7.8")); i1.PortNumber = 1; Interface i2 = new Interface(); i2.Name = "i2"; i2.PortNumber = 1; Interface i3 = new Interface(); i3.Name = "i3"; i3.PortNumber = 2; Interface i4 = new Interface(); i4.Name = "i4"; i4.GreTunnel = (Ip.Parse("5.6.7.8"), Ip.Parse("1.2.3.4")); i4.PortNumber = 1; i4.InboundAcl = new Acl { Lines = new AclLine[] { new AclLine { DstIp = new Prefix { Address = Ip.Parse("172.0.0.0").Value, Length = 24 }, SrcIp = new Prefix { Address = Ip.Parse("63.1.0.0").Value, Length = 16 }, Permitted = true, DstPortLow = 53, DstPortHigh = 53, }, }, }; // attach neighbors i1.Neighbor = i2; i2.Neighbor = i1; i3.Neighbor = i4; i4.Neighbor = i3; // setup devices Device d1 = new Device(); d1.Name = "R1"; d1.Interfaces = new Interface[] { i1 }; Device d2 = new Device(); d2.Name = "R2"; d2.Interfaces = new Interface[] { i2, i3 }; Device d3 = new Device(); d3.Name = "R3"; d3.Interfaces = new Interface[] { i4 }; // associate owners i1.Owner = d1; i2.Owner = d2; i3.Owner = d2; i4.Owner = d3; // create and associate forwarding tables var table1 = new ForwardingTable { Rules = new ForwardingRule[] { new ForwardingRule { DstIpLow = Ip.Parse("5.0.0.0"), DstIpHigh = Ip.Parse("6.0.0.0"), Interface = i1, }, }, }; var table2 = new ForwardingTable { Rules = new ForwardingRule[] { new ForwardingRule { DstIpLow = Ip.Parse("5.0.0.0"), DstIpHigh = Ip.Parse("6.0.0.0"), Interface = i3, }, new ForwardingRule { DstIpLow = Ip.Parse("1.0.0.0"), DstIpHigh = Ip.Parse("2.0.0.0"), Interface = i2, }, }, }; var table3 = new ForwardingTable { Rules = new ForwardingRule[] { new ForwardingRule { DstIpLow = Ip.Parse("1.0.0.0"), DstIpHigh = Ip.Parse("2.0.0.0"), Interface = i4, }, }, }; d1.Table = table1; d2.Table = table2; d3.Table = table3; // create the network var network = new Network.Network { Devices = new Dictionary <string, Device>() }; network.Devices["R1"] = d1; network.Devices["R2"] = d2; network.Devices["R3"] = d3; return(network); }
/// <summary> /// TODO: description /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { XboxConnectionInformation info = obj as XboxConnectionInformation; return(info != null && (Name.Equals(info.Name) && Ip.Equals(info.Ip))); }
private void RemoveIp(Ip addr) { var row = SelectByIp(addr); if (row.Length > 0) { IpTable.Rows.Remove(row[0]); } }
} //0.0.0.0を指定すると、何処からでもREGISTERを受け付ける(DHCPクライアントの用) public OneUser(string userName, string password, Ip ip) { UserName = userName; Password = password; Ip = ip; }
public void UpdateIp(Ip Ip) { context.Entry(Ip).State = EntityState.Modified; }
//ACLリストにヒットするかどうかのチェック //範囲にヒットしたものが有効/無効のフラグ(enable)も内部で評価されている public AclKind Check(Ip ip) { //ユーザリストの照合 Acl acl = null; var hostName = ""; //Ver6.0.2 //Ver6.0.2 最初にFQDNでのヒットを確認する if (_arFqdnAcls.Count != 0) { var hostInfo = Dns.GetHostEntry(ip.IPAddress); hostName = hostInfo.HostName; foreach (FqdnAcl p in _arFqdnAcls) { if (p.IsHit(ip, hostName)) { acl = p; break; } } } if (ip.InetKind == InetKind.V4) { foreach (Acl p in _arV4) { if (p.IsHit(ip)) { acl = p; break; } } } else { foreach (Acl p in _arV6) { if (p.IsHit(ip)) { acl = p; break; } } } if (!_enable && acl == null) { if (hostName != "") { _logger.Set(LogKind.Secure, null, 9000017, string.Format("address:{0} hostname:{1}", ip, hostName)); //このアドレスからのリクエストは許可されていません } else { _logger.Set(LogKind.Secure, null, 9000017, string.Format("address:{0}", ip)); //このアドレスからのリクエストは許可されていません } return(AclKind.Deny); } if (_enable && acl != null) { if (hostName != "") { _logger.Set(LogKind.Secure, null, 9000018, string.Format("aclName:{0} address:{1} hostName:{2}", acl.Name, ip, hostName)); //この利用者のアクセスは許可されていません } else { _logger.Set(LogKind.Secure, null, 9000018, string.Format("aclName:{0} address:{1}", acl.Name, ip)); //この利用者のアクセスは許可されていません } return(AclKind.Deny); } return(AclKind.Allow); }
public void Load() { Logger.Log("Loading " + Username + " from the database", LogType.Debug); DataTable playerdb = Database.fillData("SELECT * FROM _players WHERE Name='" + Username.SqlEscape() + "'"); if (playerdb.Rows.Count == 0) { FirstLogin = DateTime.Now; LastLogin = DateTime.Now; Money = 0; Database.executeQuery("INSERT INTO _players (Name, IP, firstlogin, lastlogin, money, color) VALUES ('" + Username.SqlEscape() + "', '" + Ip.SqlEscape() + "', '" + FirstLogin.ToString("yyyy-MM-dd HH:mm:ss").SqlEscape() + "', '" + LastLogin.ToString("yyyy-MM-dd HH:mm:ss").SqlEscape() + "', 0, '" + Color.SqlEscape() + "')"); DataTable temp = Database.fillData("SELECT * FROM _players WHERE Name='" + Username.SqlEscape() + "'"); if (temp.Rows.Count != 0) { UID = int.Parse(temp.Rows[0]["UID"].ToString()); } temp.Dispose(); } else { UID = int.Parse(playerdb.Rows[0]["UID"].ToString()); FirstLogin = DateTime.Parse(playerdb.Rows[0]["firstlogin"].ToString()); LastLogin = DateTime.Now; Money = int.Parse(playerdb.Rows[0]["money"].ToString()); Color = playerdb.Rows[0]["color"].ToString(); //TODO Add total login and total Blocks } playerdb.Dispose(); LoadExtra(); //Because milk this.OnPlayerDisconnect.Important += delegate { Save(); }; }
override public bool Save(MailAddress from, MailAddress to, Mail mail, string host, Ip addr) { Ar.Add(new RetMail(from, to, mail)); return(true); }
//リソース定義(Dat)で初期化する場合 public DnsCache(Logger logger, OneOption oneOption, Dat dat, string dName) { const uint ttl = 0; //有効期限なし var ns = ""; //SOA追加時に使用するため、NSレコードを見つけたときにサーバ名を保存しておく //オプションを読み込んで、ローカルデータを初期化する //this.oneOption = oneOption; _soaExpire = (uint)(int)oneOption.GetValue("soaExpire"); DomainName = dName; foreach (var o in dat) { if (o.Enable) { var type = Convert.ToInt32(o.StrList[0]); var name = o.StrList[1]; var alias = o.StrList[2]; var ip = new Ip(o.StrList[3]); var n = Convert.ToInt32(o.StrList[4]); var dnsType = DnsType.A; if (type == 1) { dnsType = DnsType.Ns; } else if (type == 2) { dnsType = DnsType.Mx; } else if (type == 3) { dnsType = DnsType.Cname; } else if (type == 4) { dnsType = DnsType.Aaaa; } var priority = (ushort)n; //uint addr = ip.AddrV4; //class Ip -> uint; //最後に.がついていない場合、ドメイン名を追加する if (name.LastIndexOf('.') != name.Length - 1) { name = name + "." + DomainName; } if (alias.LastIndexOf('.') != alias.Length - 1) { alias = alias + "." + DomainName; } //CNAME以外は、PTRレコードを自動的に生成する if (dnsType != DnsType.Cname) { //PTR名を作成 [例] 192.168.0.1 -> 1.0.168.192.in-addr.arpa; if (ip.InetKind == InetKind.V4) //IPv4 { string ptrName = string.Format("{0}.{1}.{2}.{3}.in-addr.arpa.", ip.IpV4[3], ip.IpV4[2], ip.IpV4[1], ip.IpV4[0]); Add(new OneRR(ptrName, DnsType.Ptr, ttl, DnsUtil.Str2DnsName(name))); } else //IPv6 { var sb = new StringBuilder(); foreach (var a in ip.IpV6) { sb.Append(string.Format("{0:x4}", a)); } string ipStr = sb.ToString(); if (ipStr.Length == 32) { sb = new StringBuilder(); for (int e = 31; e >= 0; e--) { sb.Append(ipStr[e]); sb.Append('.'); } Add(new OneRR(sb + "ip6.arpa.", DnsType.Ptr, ttl, DnsUtil.Str2DnsName(name))); } } } //データベースへの追加 if (dnsType == DnsType.A) { if (ip.InetKind == InetKind.V4) { //ネットワークバイト配列の取得 Add(new OneRR(name, DnsType.A, ttl, ip.NetBytes())); } else { logger.Set(LogKind.Error, null, 19, string.Format("address {0}", ip)); } } else if (dnsType == DnsType.Aaaa) { if (ip.InetKind == InetKind.V6) { Add(new OneRR(name, DnsType.Aaaa, ttl, ip.NetBytes())); } else { logger.Set(LogKind.Error, null, 20, string.Format("address {0}", ip)); } } else if (dnsType == DnsType.Ns) { ns = name;//SOA追加時に使用するため、ネームサーバの名前を保存する // A or AAAAレコードも追加 Add(new OneRR(name, (ip.InetKind == InetKind.V4) ? DnsType.A : DnsType.Aaaa, ttl, ip.NetBytes())); Add(new OneRR(DomainName, DnsType.Ns, ttl, DnsUtil.Str2DnsName(name))); } else if (dnsType == DnsType.Mx) { // A or AAAAレコードも追加 Add(new OneRR(name, DnsType.A, ttl, ip.NetBytes())); //プライオリィ byte[] dataName = DnsUtil.Str2DnsName(name);//DNS名前形式に変換 byte[] data = Bytes.Create(Util.htons(priority), dataName); Add(new OneRR(DomainName, DnsType.Mx, ttl, data)); } else if (dnsType == DnsType.Cname) { Add(new OneRR(alias, DnsType.Cname, ttl, DnsUtil.Str2DnsName(name))); } } //SOAレコードの追加 if (ns != "") //NSサーバ名が必須 { var soaMail = (string)oneOption.GetValue("soaMail"); soaMail.Replace('@', '.'); //@を.に置き換える soaMail = soaMail + "."; //最後に.を追加する var soaSerial = (uint)(int)oneOption.GetValue("soaSerial"); var soaRefresh = (uint)(int)oneOption.GetValue("soaRefresh"); var soaRetry = (uint)(int)oneOption.GetValue("soaRetry"); var soaExpire = (uint)(int)oneOption.GetValue("soaExpire"); var soaMinimum = (uint)(int)oneOption.GetValue("soaMinimum"); byte[] data = Bytes.Create( DnsUtil.Str2DnsName(ns), DnsUtil.Str2DnsName(soaMail), Util.htonl(soaSerial), Util.htonl(soaRefresh), Util.htonl(soaRetry), Util.htonl(soaExpire), Util.htonl(soaMinimum)); Add(new OneRR(DomainName, DnsType.Soa, ttl, data)); } } }
// Get Client Ip public string GetClientIp(Dictionary <string, string> headers, IOwinRequest request) { try { string Ip; if (headers.ContainsKey("X-Client-Ip") && IsValidIP(headers["X-Client-Ip"])) { return(headers["X-Client-Ip"]); } if (headers.ContainsKey("X-Forwarded-For")) { List <string> ForwardedIps = new List <string>(); foreach (string forwardedIp in headers["X-Forwarded-For"].Split(',')) { Ip = forwardedIp.Trim(); if (Ip.Contains(":")) { ForwardedIps.Add(Ip.Split(':')[0]); } ForwardedIps.Add(Ip); } return(ForwardedIps.FirstOrDefault(validIp => IsValidIP(validIp))); } if (headers.ContainsKey("Cf-Connecting-Ip") && IsValidIP(headers["Cf-Connecting-Ip"])) { return(headers["Cf-Connecting-Ip"]); } if (headers.ContainsKey("True-Client-Ip") && IsValidIP(headers["True-Client-Ip"])) { return(headers["True-Client-Ip"]); } if (headers.ContainsKey("X-Real-Ip") && IsValidIP(headers["X-Real-Ip"])) { return(headers["X-Real-Ip"]); } if (headers.ContainsKey("X-Cluster-Client-Ip") && IsValidIP(headers["X-Cluster-Client-Ip"])) { return(headers["X-Cluster-Client-Ip"]); } if (headers.ContainsKey("X-Forwarded") && IsValidIP(headers["X-Forwarded"])) { return(headers["X-Forwarded"]); } if (headers.ContainsKey("Forwarded-For") && IsValidIP(headers["Forwarded-For"])) { return(headers["Forwarded-For"]); } if (headers.ContainsKey("Forwarded") && IsValidIP(headers["Forwarded"])) { return(headers["Forwarded"]); } //return request.HttpContext.Connection.RemoteIpAddress.ToString(); return(request.RemoteIpAddress.ToString()); } catch (Exception e) { //return request.HttpContext.Connection.RemoteIpAddress.ToString(); return(request.RemoteIpAddress.ToString()); } }
private static void PingSuccess(Ip _Ip) { lock ("ping") _List.Add(_Ip); Trace.WriteLine("Pong" +_Ip); }
//*************************************************************** // パイプ(FTP) //*************************************************************** int PipeFtp(Dictionary <CS, TcpObj> sock, Request request, int dataPort) { DataThread dataThread = null; //ユーザ名及びパスワード string user = "******"; string pass = this.OpBase.ValString("anonymousAddress"); //Ver5.0.0-a23 URLで指定されたユーザ名およびパスワードを使用する if (request.User != null) { user = request.User; } if (request.Pass != null) { pass = request.Pass; } //wait 220 welcome if (!WaitLine(sock, "220")) { goto end; } sock[CS.SERVER].AsciiSend(string.Format("USER {0}", user), OPERATE_CRLF.YES); if (!WaitLine(sock, "331")) { goto end; } sock[CS.SERVER].AsciiSend(string.Format("PASS {0}", pass), OPERATE_CRLF.YES); if (!WaitLine(sock, "230")) { goto end; } //URIをパスとファイル名に分解する string path = request.Uri; string file = ""; int index = request.Uri.LastIndexOf('/'); if (index < request.Uri.Length - 1) { path = request.Uri.Substring(0, index); file = request.Uri.Substring(index + 1); } //リクエスト if (path != "") { sock[CS.SERVER].AsciiSend(string.Format("CWD {0}", path), OPERATE_CRLF.YES); if (!WaitLine(sock, "250")) { goto end; } } if (file == "") { sock[CS.SERVER].AsciiSend("TYPE A", OPERATE_CRLF.YES); } else { sock[CS.SERVER].AsciiSend("TYPE I", OPERATE_CRLF.YES); } if (!WaitLine(sock, "200")) { goto end; } //PORTコマンド送信 Ip bindAddr = new Ip(sock[CS.SERVER].LocalEndPoint.Address.ToString()); // 利用可能なデータポートの選定 int listenMax = 1; SSL ssl = null; TcpObj listenObj = null; while (life) { listenObj = new TcpObj(kanel, this.Logger, bindAddr, dataPort++, listenMax, ssl); if (listenObj.State != SOCKET_OBJ_STATE.ERROR) { break; } } if (listenObj == null) { goto end; } //データスレッドの生成 dataThread = new DataThread(this.Logger, listenObj); // サーバ側に送るPORTコマンドを生成する string str = string.Format("PORT {0},{1},{2},{3},{4},{5}", bindAddr.IpV4[0], bindAddr.IpV4[1], bindAddr.IpV4[2], bindAddr.IpV4[3], (listenObj.LocalEndPoint.Port) / 256, (listenObj.LocalEndPoint.Port) % 256); sock[CS.SERVER].AsciiSend(str, OPERATE_CRLF.YES); if (!WaitLine(sock, "200")) { goto end; } if (file == "") { sock[CS.SERVER].AsciiSend("LIST", OPERATE_CRLF.YES); if (!WaitLine(sock, "150")) { goto end; } } else { sock[CS.SERVER].AsciiSend("RETR " + file, OPERATE_CRLF.YES); if (!WaitLine(sock, "150")) { goto end; } } if (!WaitLine(sock, "226")) { goto end; } byte[] doc = new byte[0]; if (file == "") { //受信結果をデータスレッドから取得する List <string> lines = Inet.GetLines(dataThread.ToString()); //FTPサーバから取得したLISTの情報をHTMLにコンバートする doc = ConvFtpList(lines, path); } else { doc = dataThread.ToBytes(); } //クライアントへリプライ及びヘッダを送信する Header header = new Header(); header.Replace("Server", Util.SwapStr("$v", kanel.Ver.Version(), this.OpBase.ValString("serverHeader"))); header.Replace("MIME-Version", "1.0"); if (file == "") { header.Replace("Date", Util.UtcTime2Str(DateTime.UtcNow)); header.Replace("Content-Type", "text/html"); } else { header.Replace("Content-Type", "none/none"); } header.Replace("Content-Length", doc.Length.ToString()); sock[CS.CLIENT].AsciiSend("HTTP/1.0 200 OK", OPERATE_CRLF.YES); //リプライ送信 sock[CS.CLIENT].Send(header.GetBytes()); //ヘッダ送信 sock[CS.CLIENT].Send(doc); //ボディ送信 end: if (dataThread != null) { dataThread.Dispose(); } return(dataPort); }
private static int NumberIpInListIp(Ip.Ip ip, IEnumerable<Ip.Ip> listIp) { return listIp.Count(ip1 => ip == ip1); }
private long SerializeHostEnt(ServiceCtx Context, IPHostEntry HostEntry, List <IPAddress> Addresses = null) { long OriginalBufferPosition = Context.Request.ReceiveBuff[0].Position; long BufferPosition = OriginalBufferPosition; long BufferSize = Context.Request.ReceiveBuff[0].Size; string HostName = HostEntry.HostName + '\0'; // h_name Context.Memory.WriteBytes(BufferPosition, Encoding.ASCII.GetBytes(HostName)); BufferPosition += HostName.Length; // h_aliases list size Context.Memory.WriteInt32(BufferPosition, IPAddress.HostToNetworkOrder(HostEntry.Aliases.Length)); BufferPosition += 4; // Actual aliases foreach (string Alias in HostEntry.Aliases) { Context.Memory.WriteBytes(BufferPosition, Encoding.ASCII.GetBytes(Alias + '\0')); BufferPosition += Alias.Length + 1; } // h_addrtype but it's a short (also only support IPv4) Context.Memory.WriteInt16(BufferPosition, IPAddress.HostToNetworkOrder((short)2)); BufferPosition += 2; // h_length but it's a short Context.Memory.WriteInt16(BufferPosition, IPAddress.HostToNetworkOrder((short)4)); BufferPosition += 2; // Ip address count, we can only support ipv4 (blame Nintendo) Context.Memory.WriteInt32(BufferPosition, Addresses != null ? IPAddress.HostToNetworkOrder(Addresses.Count) : 0); BufferPosition += 4; if (Addresses != null) { foreach (IPAddress Ip in Addresses) { Context.Memory.WriteInt32(BufferPosition, IPAddress.HostToNetworkOrder(BitConverter.ToInt32(Ip.GetAddressBytes(), 0))); BufferPosition += 4; } } return(BufferPosition - OriginalBufferPosition); }
public override int GetHashCode() { return(Ip.GetHashCode()); }
public override bool Save(MailAddress from, MailAddress to, Mail mail, string host, Ip addr) { Ar.Add(new RetMail(from, to, mail)); return true; }
public string UpImg() { int cid = 0; int UserId = 0; string dic = ""; try { HttpRequestBase request = HttpContext.Request; Stream stream = request.InputStream; string json = string.Empty; string responseJson = string.Empty; if (stream.Length != 0) { StreamReader streamReader = new StreamReader(stream); json = streamReader.ReadToEnd(); } JObject obj = JObject.Parse(json); string base64 = obj["base64"].ToString(); cid = obj["cid"].ToInt(); UserId = obj["UserId"].ToInt(); dic = obj["dic"].ToString(); //base64 = "/9j/4AAQSkZJRgABAQEAYABgAAD/4QA6RXhpZgAATU0AKgAAAAgAA1EQAAEAAAABAQAAAFERAAQAAAABAAAAAFESAAQAAAABAAAAAAAAAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAAZACMDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDuKKWkr6A+JCilpKBiYoo4ooAfSU6kpAJS4opT0oGhtFLRQB//2Q=="; if (base64.Length < 100) { return(ApiReturnStr.getError(-100, "图片太小,不能作为照片上传。")); } var fileLength = Convert.ToInt32(base64.Length - (base64.Length / 8) * 2);//文件字节 if (fileLength >= 1024 * 1024 * 2) { return(ApiReturnStr.getError(-100, "上传图片大小不能超过2M。")); } string path = "upload/" + dic + "/" + DateTime.Now.ToString("yyyyMMdd") + "/"; string dicPath = Server.MapPath("~/" + path); if (!Directory.Exists(dicPath))//如果没有文件夹则创建 { System.IO.Directory.CreateDirectory(dicPath); } string file_ex = ".jpg"; string url2 = Constant.StaticHost + path; //文件名 string fileName = DateTime.Now.ToString("HHmmssfff"); byte[] bmpBytes = Convert.FromBase64String(base64); //完整地址 string aUrl = url2 + fileName + file_ex; if (aUrl.Length > 10) { MemoryStream ms = new MemoryStream(bmpBytes); Bitmap bmp = new Bitmap(ms); bmp.Save(dicPath + fileName + file_ex, System.Drawing.Imaging.ImageFormat.Jpeg); } JObject data = new JObject(); data["ImgUrl"] = aUrl; data["fileLength"] = fileLength; data["filename"] = fileName + file_ex; data["Url"] = path + fileName + file_ex; return(ApiReturnStr.getApiData(0, "上传成功", data)); } catch (Exception ex) { Logs.WriteLog(string.Format("static=UpImg,cid:{0},UserId:{1},ip:{2},ex:{3}", cid, UserId, Ip.GetClientIp(), ex.Message), "d:\\Log\\Upload", "UpImg"); return(ApiReturnStr.getError(-100, "上传图片失败,请稍后再试。")); } }
public override String GetAddress(IPAddress addr) => Ip.GetAddress(addr);
//サーバ側若しくはクライアント側どちらかのSockTcpは、Listen状態で生成が終わっている //そして、その接続の待ち受け開始は、このクラスの中で行われる //接続が完了した後、反対側のサーバ(Ip,port)へ、コネクトする public DataThread(Kernel kernel, Logger logger, int clientPort, int serverPort, Ip bindAddr, Ip ip, int port, int timeout) { _kernel = kernel; _logger = logger; _timeout = timeout; _ip = ip; _port = port; _sock[CS.Client] = null; _sock[CS.Server] = null; if (serverPort != 0) //サーバ側がListen状態の場合 PASV { _sock[CS.Server] = SockServer.CreateConnection(kernel, bindAddr, serverPort, null, this); if (_sock[CS.Server] == null) { return; } } else if (clientPort != 0) //クライアント側がListen状態の場合 PORT { _sock[CS.Client] = SockServer.CreateConnection(kernel, bindAddr, clientPort, null, this); if (_sock[CS.Client] == null) { return; } } //パイプスレッドの生成 _t = new Thread(Pipe) { IsBackground = true }; _t.Start(); }
/// <summary> /// Loads several conf files that are generally required, /// like log, database, etc. /// </summary> protected void LoadDefault() { Ip.Load(); Log.Load(); Database.Load(); }
//リソース定義(Dat)で初期化する場合 public DnsCache(Logger logger, OneOption oneOption, Dat dat, string dName) { const uint ttl = 0; //有効期限なし var ns = "";//SOA追加時に使用するため、NSレコードを見つけたときにサーバ名を保存しておく //オプションを読み込んで、ローカルデータを初期化する //this.oneOption = oneOption; _soaExpire = (uint)(int)oneOption.GetValue("soaExpire"); DomainName = dName; foreach (var o in dat) { if (o.Enable) { var type = Convert.ToInt32(o.StrList[0]); var name = o.StrList[1]; var alias = o.StrList[2]; var ip = new Ip(o.StrList[3]); var n = Convert.ToInt32(o.StrList[4]); var dnsType = DnsType.A; if (type == 1) { dnsType = DnsType.Ns; } else if (type == 2) { dnsType = DnsType.Mx; } else if (type == 3) { dnsType = DnsType.Cname; } else if (type == 4) { dnsType = DnsType.Aaaa; } var priority = (ushort)n; //uint addr = ip.AddrV4; //class Ip -> uint; //最後に.がついていない場合、ドメイン名を追加する if (name.LastIndexOf('.') != name.Length - 1) { name = name + "." + DomainName; } if (alias.LastIndexOf('.') != alias.Length - 1) { alias = alias + "." + DomainName; } //CNAME以外は、PTRレコードを自動的に生成する if (dnsType != DnsType.Cname) { //PTR名を作成 [例] 192.168.0.1 -> 1.0.168.192.in-addr.arpa; if (ip.InetKind == InetKind.V4) { //IPv4 string ptrName = string.Format("{0}.{1}.{2}.{3}.in-addr.arpa.", ip.IpV4[3], ip.IpV4[2], ip.IpV4[1], ip.IpV4[0]); Add(new OneRR(ptrName, DnsType.Ptr, ttl, DnsUtil.Str2DnsName(name))); } else { //IPv6 var sb = new StringBuilder(); foreach (var a in ip.IpV6) { sb.Append(string.Format("{0:x4}", a)); } string ipStr = sb.ToString(); if (ipStr.Length == 32) { sb = new StringBuilder(); for (int e = 31; e >= 0; e--) { sb.Append(ipStr[e]); sb.Append('.'); } Add(new OneRR(sb + "ip6.arpa.", DnsType.Ptr, ttl, DnsUtil.Str2DnsName(name))); } } } //データベースへの追加 if (dnsType == DnsType.A) { if (ip.InetKind == InetKind.V4) { //ネットワークバイト配列の取得 Add(new OneRR(name, DnsType.A, ttl, ip.NetBytes())); } else { logger.Set(LogKind.Error, null, 19, string.Format("address {0}", ip)); } } else if (dnsType == DnsType.Aaaa) { if (ip.InetKind == InetKind.V6) { Add(new OneRR(name, DnsType.Aaaa, ttl, ip.NetBytes())); } else { logger.Set(LogKind.Error, null, 20, string.Format("address {0}", ip)); } } else if (dnsType == DnsType.Ns) { ns = name;//SOA追加時に使用するため、ネームサーバの名前を保存する // A or AAAAレコードも追加 Add(new OneRR(name, (ip.InetKind == InetKind.V4) ? DnsType.A : DnsType.Aaaa, ttl, ip.NetBytes())); Add(new OneRR(DomainName, DnsType.Ns, ttl, DnsUtil.Str2DnsName(name))); } else if (dnsType == DnsType.Mx) { // A or AAAAレコードも追加 Add(new OneRR(name, DnsType.A, ttl, ip.NetBytes())); //プライオリィ byte[] dataName = DnsUtil.Str2DnsName(name);//DNS名前形式に変換 byte[] data = Bytes.Create(Util.htons(priority), dataName); Add(new OneRR(DomainName, DnsType.Mx, ttl, data)); } else if (dnsType == DnsType.Cname) { Add(new OneRR(alias, DnsType.Cname, ttl, DnsUtil.Str2DnsName(name))); } } //SOAレコードの追加 if (ns != "") { //NSサーバ名が必須 var soaMail = (string)oneOption.GetValue("soaMail"); soaMail.Replace('@', '.');//@を.に置き換える soaMail = soaMail + ".";//最後に.を追加する var soaSerial = (uint)(int)oneOption.GetValue("soaSerial"); var soaRefresh = (uint)(int)oneOption.GetValue("soaRefresh"); var soaRetry = (uint)(int)oneOption.GetValue("soaRetry"); var soaExpire = (uint)(int)oneOption.GetValue("soaExpire"); var soaMinimum = (uint)(int)oneOption.GetValue("soaMinimum"); byte[] data = Bytes.Create( DnsUtil.Str2DnsName(ns), DnsUtil.Str2DnsName(soaMail), Util.htonl(soaSerial), Util.htonl(soaRefresh), Util.htonl(soaRetry), Util.htonl(soaExpire), Util.htonl(soaMinimum)); Add(new OneRR(DomainName, DnsType.Soa, ttl, data)); } } }
//=====================================================================================================================/ //====================================================================================================================/ //=====================BTNSTART============================================================================= private async void btnSart_ClickAsync(object sender, EventArgs e) { lblPatience.Visible = true; var sIpDestinataire = tbxIP1.Text + "." + tbxIP2.Text + "." + tbxIP3.Text + "." + tbxIP4.Text; if (sIpDestinataire == lblIPPersonnel.Text) { tbxIP4.BackColor = Color.Red; } if (tbxIP1.BackColor != Color.Red) { if (tbxIP2.BackColor != Color.Red) { if (tbxIP3.BackColor != Color.Red) { if (tbxIP4.BackColor != Color.Red) { if (tbxIP4.BackColor != Color.PaleGreen) { lblPatience.Visible = true; lblEtatPing.Visible = false; lblNomPCDest.Visible = false; lblEtatPing.Visible = true; var sNameDestinataire = Ip.GetHostName(sIpDestinataire); var bResultPing = await Task.Run(() => Ip.PingDest(sIpDestinataire)); if (bResultPing) { lblEtatPing.Text = @"Ping : OK"; lblEtatPing.ForeColor = Color.Green; if (btnSart.Text == @"Check IP") { if (sNameDestinataire == "") { lblNomPCDest.Text = "Name :" + "\r\n" + "Not found"; lblNomPCDest.ForeColor = Color.Red; lblNomPCDest.Visible = true; tbxIP4.BackColor = Color.Red; } else { btnSart.Text = "Start"; lblNomPCDest.Visible = true; lblNomPCDest.Text = "Name :" + "\r\n" + sNameDestinataire; lblNomPCDest.ForeColor = Color.Black; } } else { //___________MinimiserLaFenetre________________ this.Width = 620; lblDescription.Visible = false; btnSart.Visible = false; lblDescription2.Visible = true; lblIPDESTINATAIRE.Visible = false; pbxLogo1.Visible = false; pbxLogoPetit.Visible = true; lblIPPersonnel.Visible = false; lblFixeCePC.Visible = false; NomDestinataireToolStripMenuItem.Visible = true; tbxIP1.Visible = false; tbxIP2.Visible = false; tbxIP3.Visible = false; tbxIP4.Visible = false; NomDestinataireToolStripMenuItem.Text = "Recipient : " + sNameDestinataire; lblNomPCDest.Visible = false; iPPersonnelToolStripMenuItem.Text = "My IP : " + lblIPPersonnel.Text; iPPersonnelToolStripMenuItem.Visible = true; //______________________________________________ //FichierConfig--------------------------------- if (XmlManipulation.GetValue("EnableLastIpConnexion") == "ON") { XmlManipulation.ModifyElementXml("LastIpConnexion", sIpDestinataire); } else { XmlManipulation.ModifyElementXml("LastIpConnexion", ""); } _recipientIp = sIpDestinataire; try { _epLocal = new IPEndPoint(IPAddress.Parse(lblIPPersonnel.Text), 3056);//Use 3056 port _sck.Bind(_epLocal); _epRemote = new IPEndPoint(IPAddress.Parse(sIpDestinataire), 3056); _sck.Connect(_epRemote); var buffer = new byte[1500]; _sck.BeginReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None, ref _epRemote, MessageReceived, buffer); btnSart.Text = @"Connected"; btnSart.Enabled = false; btnEnvoi.Enabled = true; tbxMessageEnvoit.Focus(); EnvoiDuMessage("tuiFZCz56786casdcssdcvuivgboRTSDetre67Rz7463178", KMessage.Type.Init()); if (XmlManipulation.GetValue("SaveDiscussion") == "ON") { var temp = ChatData.Import(_recipientIp); if (temp.Count() != 0) { foreach (var element in temp) { lbxTchat.Items.Add(element); } } } } catch { MessageBox.Show("An error occured. \r\nPlease restart Kubeah Chat" + "\r\n" + "\r\n", "An error occurred"); Application.Exit(); } //Send the key to the other client to connect } } else { lblEtatPing.Text = "Ping : Fail"; lblEtatPing.ForeColor = Color.Red; lblNomPCDest.Visible = false; tbxIP4.BackColor = Color.Red; } } } } } } lblPatience.Visible = false; }
private void ImportIp(Ip addr) { if (InvokeRequired) { Invoke(new MethodInvoker(() => ImportIp(addr))); } else { try { var row = IpTable.NewRow(); row[0] = addr; row[1] = "n/a"; row[2] = "n/a"; row[3] = "n/a"; row[4] = "n/a"; IpTable.Rows.Add(row); } catch (Exception) { } } }
private void UpdateLobbyData(LobbyData data) { for (int i = 0; i < data.Players.Count; ++i) { if (data.Players[i] != null && data.Players[i].PlayerIndex != 0u && data.Players[i].Identification == Ip.ToString()) { PlayerIndex = (uint)i; break; } } LobbyData = data; LobbyDataUpdated?.Invoke(this, EventArgs.Empty); }
private DataRow[] SelectByIp(Ip addr) { if (InvokeRequired) return (DataRow[])Invoke(new MethodInvoker(() => SelectByIp(addr))); else return IpTable.Select(string.Format("addr = '{0}'", addr)); }
public void Init(string ip_remote) { this.ips = new Ip(); ips.Remote = ip_remote; ips.Local = this.getLocalIp(); }
public void InsertIp(Ip Ip) { context.Ips.Add(Ip); }
//出力ファイル(Option.ini)からの入力用<br> //不正な文字列があった場合は、無効行として無視される<br> public bool FromReg(String str) { if (str == null) { Value = null; return(false); } switch (OneCtrl.GetCtrlType()) { case CtrlType.Dat: CtrlDat ctrlDat = (CtrlDat)OneCtrl; Dat dat = new Dat(ctrlDat.CtrlTypeList); if (!dat.FromReg(str)) { Value = null; return(false); } //Ver5.8.7 Java fix Datの中にComboBoxが存在する場合の旧バージョンの変換 foreach (var d in dat) { for (int i = 0; i < ctrlDat.ListVal.Count; i++) { if (ctrlDat.ListVal[i].OneCtrl.GetCtrlType() == CtrlType.ComboBox) { int val; if (!int.TryParse(d.StrList[i], out val)) { //Ver5.7.x以前のデータ OneVal dmy = new OneVal("dmy", null, Crlf.Nextline, ctrlDat.ListVal[i].OneCtrl); if (dmy.FromRegConv(d.StrList[i])) { d.StrList[i] = dmy.ToReg(false); } } } } } Value = dat; break; case CtrlType.CheckBox: try { Value = Boolean.Parse(str); } catch { Value = false; return(false); } break; case CtrlType.Font: Value = null; var tmp = str.Split(','); if (tmp.Length == 3) { try{ var family = new FontFamily(tmp[0]); var size = (float)Convert.ToDouble(tmp[1]); var style = (FontStyle)Enum.Parse(typeof(FontStyle), tmp[2]); Value = new Font(family, size, style); }catch (Exception) { Value = null; } } if (Value == null) { return(false); } break; case CtrlType.Memo: Value = Util.SwapStr("\t", "\r\n", str); break; case CtrlType.File: case CtrlType.Folder: case CtrlType.TextBox: Value = str; break; case CtrlType.Hidden: try{ Value = Crypt.Decrypt(str); } catch (Exception) { Value = ""; return(false); } break; case CtrlType.Radio: try{ Value = Int32.Parse(str); }catch (Exception) { Value = 0; return(false); } if ((int)Value < 0) { Value = 0; return(false); } break; case CtrlType.ComboBox: int max = ((CtrlComboBox)OneCtrl).Max; try { var n = Int32.Parse(str); if (n < 0 || max <= n) { Value = 0; return(false); } Value = n; } catch { Value = 0; //Ver5.9.2 Ver5.7.x以前のデータのコンバート OneVal dmy = new OneVal("dmy", null, Crlf.Nextline, OneCtrl); if (dmy.FromRegConv(str)) { int n; Int32.TryParse(dmy.ToReg(false), out n); if (n < 0 || max <= n) { Value = 0; return(false); } Value = n; } return(false); } break; case CtrlType.Int: try { Value = Int32.Parse(str); } catch { Value = 0; return(false); } break; case CtrlType.BindAddr: try{ Value = new BindAddr(str); } catch (ValidObjException) { Value = 0; return(false); } break; case CtrlType.AddressV4: try{ Value = new Ip(str); } catch (ValidObjException) { Value = null; return(false); } break; case CtrlType.TabPage: case CtrlType.Group: break; default: Value = 0; return(false); // "実装されていないCtrlTypeが指定されました OneVal.fromReg()" } return(true); }
public OneDnsCache(string name, Ip[] ipList) { IpList = ipList; Name = name; }
public OneBind(Ip addr,ProtocolKind protocol) { Addr = addr; Protocol = protocol; }