protected override void ParseToEvent(Reply reply) { base.ParseToEvent(reply); int index = 0; string[] split = EventLine.Split(' '); Severity = Utility.ParseEnum<StatusSeverity>(split[index]); index++; Action = split[index]; index++; Arguments = new Dictionary<string, string>(); for (int i = index; i < split.Length; i++) { if (split[i].Contains("=")) { string key = split[i].Split('=')[0]; string value = split[i].Split('=')[1].Replace("\"", ""); Arguments.Add(key, value); } } }
protected override void ParseToEvent(Reply reply) { base.ParseToEvent(reply); int index = 0; string[] split = EventLine.Split(' '); Target = split[index]; index++; Status = Utility.ParseEnum<OrConnStatus>(split[index]); index++; for (int i = index; i < split.Length; i++) { if (split[i].Contains("=")) { string key = split[i].Split('=')[0]; string value = split[i].Split('=')[1]; switch (key.ToUpper()) { case "REASON": Reason = Utility.ParseEnum<OrConnReasons>(value); break; case "NCIRCS": CircuitsCount = int.Parse(value); break; case "ID": ID = value; break; } } } }
protected override void ParseToEvent(Reply reply) { base.ParseToEvent(reply); ServerIDs = new List<string>(); ServerIDs.AddRange(EventLine.Split(' ')); }
internal GetInfoReply(Reply reply) : base(reply) { _isvalid = (this.Code == ReplyCodes.OK) && this.ReplyLine.Contains("="); if (_isvalid) { _name = this.ReplyLine.Substring(0, this.ReplyLine.IndexOf("=")); _value = this.ReplyLine.Substring(this.ReplyLine.IndexOf("=") + 1); } }
protected override void ParseToEvent(Reply reply) { base.ParseToEvent(reply); string[] split = EventLine.Split(' '); TimeStarted = split[0].Replace("\"", ""); CountrySummary = split[1].Split(','); IPVersions = split[2].Split(','); }
protected override void ParseToEvent(Reply reply) { base.ParseToEvent(reply); string[] split = EventLine.Split(' '); Type = split[0]; Name = split[1]; Status = split[2]; }
protected override void ParseToEvent(Reply reply) { base.ParseToEvent(reply); var split = EventLine.Split(' '); ID = split[0]; int br = 0; int.TryParse(split[1], out br); BytesRead = br; int bw = 0; int.TryParse(split[2], out bw); BytesWritten = bw; }
public static TorEvent Parse(Reply reply) { string eventName = reply.ReplyLine.Substring(0, reply.ReplyLine.IndexOf(" ")); TorEvents eventEnum = (TorEvents)Enum.Parse(typeof(TorEvents), eventName, true); Type eventType = eventEnum.GetTypeValue(); if (eventType == null) { throw new NullReferenceException(); } TorEvent asyncEvent = (TorEvent)Activator.CreateInstance(eventType); asyncEvent.ParseToEvent(reply); return asyncEvent; }
protected override void ParseToEvent(Reply reply) { base.ParseToEvent(reply); var split = EventLine.Split(' '); if (split.Length > 1) { int br = 0; int.TryParse(split[0], out br); BytesRead = br; int bw = 0; int.TryParse(split[1], out bw); BytesWritten = bw; } if (split.Length > 2) { //TODO: Implement parsing of additional parameters } }
protected override void ParseToEvent(Reply reply) { base.ParseToEvent(reply); int index = 0; string[] split = EventLine.Split(' '); Address = split[index]; index++; NewAddress = split[index]; index++; Expiry = split[index].Replace("\"", ""); index++; for (int i = index; i < split.Length; i++) { if (split[i].Contains("=")) { string key = split[i].Split('=')[0]; string value = split[i].Split('=')[1]; switch (key.ToUpper()) { case "ERROR": Error = value; break; case "EXPIRES": Expires = value.Replace("\"", ""); break; case "CACHED": Cached = value.ToUpper().Contains("YES") ? true : false; break; } } } }
protected override void ParseToEvent(Reply reply) { base.ParseToEvent(reply); int index = 0; string[] split = EventLine.Split(' '); StreamID = split[index]; index++; Status = Utility.ParseEnum<StreamStatus>(split[index]); index++; CircuitID = split[index]; index++; Target = split[index]; index++; for (int i = index; i < split.Length; i++) { if (split[i].Contains("=")) { string key = split[i].Split('=')[0]; string value = split[i].Split('=')[1]; switch (key.ToUpper()) { case "PURPOSE": Purpose = Utility.ParseEnum<StreamPurpose>(value); break; case "SOURCE_ADDR": SourceAddr = value; break; case "SOURCE": Source = value; break; case "REMOTE_REASON": RemoteReason = Utility.ParseEnum<StreamReason>(value); break; case "REASON": Reason = Utility.ParseEnum<StreamReason>(value); break; } } } }
protected override void ParseToEvent(Reply reply) { base.ParseToEvent(reply); }
protected override void ParseToEvent(Reply reply) { base.ParseToEvent(reply); int index = 0; string[] split = EventLine.Split(' '); ID = split[index]; index++; Status = Utility.ParseEnum<CircStatus>(split[index]); index++; if (!split[index].Contains("=")) { Path = split[index]; index++; } else { Path = ""; } for (int i = index; i < split.Length; i++) { if (split[i].Contains("=")) { string key = split[i].Split('=')[0]; string value = split[i].Split('=')[1]; switch (key.ToUpper()) { case "BUILD_FLAGS": List<CircBuildFlags> flags = new List<CircBuildFlags>(); foreach (var stringFlag in value.Split(',')) { flags.Add(Utility.ParseEnum<CircBuildFlags>(stringFlag)); } BuildFlags = flags; break; case "PURPOSE": Purpose = Utility.ParseEnum<CircPurpose>(value); break; case "HS_STATE": HsState = Utility.ParseEnum<CircHsState>(value); break; case "OLD_PURPOSE": OldPurpose = Utility.ParseEnum<CircPurpose>(value); break; case "OLD_HS_STATE": OldHsState = Utility.ParseEnum<CircHsState>(value); break; case "REND_QUERY": RendQuery = value; break; case "TIME_CREATED": TimeCreated = value; break; } } } }
/// <summary> /// Handle a single line which was received by the ControlSocket. /// </summary> /// <param name="line">Received line (ending with CRLF)</param> private void ControlSocket_OnLineReceived(string line) { if(_receiveData) { if (line.Length > 0) { if (line[0] == '.') { if (line == ".\r\n") { // terminating sequence received // RFC2821: If the line is composed of a single period, it is // treated as the end of mail indicator. _receiveData = false; HandleFinishedReply(); return; } else { // escaped line received // RFC2821: If the first character is a period and there are // other characters on the line, the first character // is deleted line = line.Substring(1); } } } _currentReply.RawString += line; } else { _currentReply = new Reply(line); if ((line[3] == ' ') || // EndReply (line[3] == '-')) // MidReply { HandleFinishedReply(); } else if (line[3] == '+') // DataReply { _receiveData = true; } else { throw new NullReplyCodeException(line, 3); } } }
protected override void ParseToEvent(Reply reply) { base.ParseToEvent(reply); Signal = EventLine; }
/// <summary> /// Create a reply as copy of another. /// </summary> /// <param name="reply">Reply to copy from.</param> protected Reply(Reply reply) { this.RawString = reply.RawString; this.Code = reply.Code; }
protected override void ParseToEvent(Reply reply) { base.ParseToEvent(reply); LogMessage = EventLine; }
protected virtual void ParseToEvent(Reply reply) { RawString = reply.RawString; EventLine = reply.ReplyLine.Substring(reply.ReplyLine.IndexOf(" ")).Replace("\r\n", ""); }
protected override void ParseToEvent(Reply reply) { base.ParseToEvent(reply); int index = 0; string[] split = EventLine.Split(' '); Type = Utility.ParseEnum<BuildTimeoutSetTypes>(split[index]); index++; for (int i = index; i < split.Length; i++) { if (split[i].Contains("=")) { string key = split[i].Split('=')[0]; string value = split[i].Split('=')[1]; switch (key.ToUpper()) { case "TOTAL_TIMES": int tc = 0; int.TryParse(value, out tc); TimeoutsCount = tc; break; case "TIMEOUT_MS": int t = 0; int.TryParse(value, out t); Timeout = t; break; case "XM": int xm = 0; int.TryParse(value, out xm); Xm = xm; break; case "ALPHA": Alpha = value; break; case "CUTOFF_QUANTILE": Quantile = value; break; case "TIMEOUT_RATE": TimeoutRate = value; break; case "CLOSE_MS": int ct = 0; int.TryParse(value, out ct); CloseTimeout = ct; break; case "CLOSE_RATE": CloseRate = value; break; } } } }