public void DetachServerPipe() { if (this.ServerPipe != null) { this.ServerPipe.End(); this.ServerPipe = null; } }
public Session(ClientPipe clientPipe, ServerPipe serverPipe) { this.Timers = new SessionTimers(); this.Timers.ClientConnected = DateTime.Now; this.Flags = new StringDictionary(); if (clientPipe != null) { this.clientIP = (clientPipe.Address == null) ? null : clientPipe.Address.ToString(); this.clientPort = clientPipe.Port; this.Flags["x-clientIP"] = this.clientIP; this.Flags["x-clientport"] = this.clientPort.ToString(); if (clientPipe.LocalProcessID != 0) { this._localProcessID = clientPipe.LocalProcessID; this.Flags["x-ProcessInfo"] = string.Format("{0}:{1}", clientPipe.LocalProcessName, this._localProcessID); this._localProcessName = clientPipe.LocalProcessName; } } this.Response = new ServerChatter(this); this.Request = new ClientChatter(this); this.Request.ClientPipe = clientPipe; this.Response.ServerPipe = serverPipe; }
private bool ConnectToHost() { string str2; string str3; IPAddress[] addressArray; /* string sHostAndPort = this.m_session.Flags["x-overrideHost"]; if (sHostAndPort == null) { sHostAndPort = this.m_session.host; }*/ string sHostAndPort = this.m_session.Host; int iPort = this.m_session.IsHTTPS ? 0x1bb : (this.m_session.IsFTP ? 0x15 : 80); Utilities.CrackHostAndPort(sHostAndPort, out str2, ref iPort); str3 = (this.m_session.IsHTTPS ? "HTTPS:" : "") + str2 + ":" + iPort.ToString(); int port = iPort; try { addressArray = DNSResolver.GetIPAddressList(str2, true, this.m_session.Timers); } catch (Exception exception) { this.m_session.Request.FailSession(0x1f6, "JrIntercepter - DNS Lookup Failed", "JrIntercepter: DNS Lookup for " + Utilities.HtmlEncode(str2) + " failed. " + exception.Message); return false; } if ((port < 0) || (port > 0xffff)) { this.m_session.Request.FailSession(0x1f6, "Invalid Request", "HTTP Request specified an invalid port number."); return false; } try { this.ServerPipe = new ServerPipe("ServerPipe#" + this.m_session.id.ToString()); Socket socket = CreateConnectedSocket(addressArray, port, this.m_session); this.ServerPipe.WrapSocketInPipe(socket); return true; } catch (Exception exception2) { this.m_session.Request.FailSession( 0x1f6, "JrIntercepter - Connection Failed", "[JrIntercepter] Connection to " + Utilities.HtmlEncode(str2) + " failed.<BR>Exception Text: " + exception2.Message); return false; } }