public override string ToString() { return(PartitionId.PadRight(3, ' ') + " " + LocalPort.ToString().PadRight(5 + 5, ' ') + " " + ForeignPort.ToString().PadRight(5 + 5, ' ') + " " + ForeignIp.ToString().PadRight(15, ' ') + " " + InboundIBBK.ToString().PadRight(20, ' ') + " " + InboundByte.ToString().PadRight(20, ' ') + " " + InboundIBBKDup.ToString().PadRight(20, ' ') + " " + InboundByteDup.ToString().PadRight(20, ' ') + " " + EfficiencyFormatter(InboundEfficiency).PadRight(6 + 7, ' ') + " " + OutboundIBBK.ToString().PadRight(20, ' ') + " " + OutboundByte.ToString().PadRight(20, ' ') + " " + OutboundIBBKDup.ToString().PadRight(20, ' ') + " " + OutboundByteDup.ToString().PadRight(20, ' ') + " " + EfficiencyFormatter(OutboundEfficiency).PadRight(6 + 8, ' ') + " " + RcvdSocket.ToString().PadRight(20, ' ') + " " + MaxRecvWindow.ToString().PadRight(10 + 3, ' ') + " " + RecvWindowClosed.ToString().PadRight(20, ' ') + " " + SendSocket.ToString().PadRight(20, ' ') + " " + MaxSendWindow.ToString().PadRight(10 + 3, ' ') + " " + Retransmitted.ToString().PadRight(20, ' ') + " " + InRetransmitMode.ToString().PadRight(20, ' ') + " " + HighestDepth.ToString().PadRight(20, ' ') + " " + Sws.ToString().PadRight(20, ' ') + " " + ProtocolFormatter(Protocol, FlagAA).PadRight(8, ' ') + " " + LocalCallFormatter(localCall).PadRight(3 + 4, ' ') + " " + StateFormatter(state).PadRight(12, ' ') + " " + StartTime.ToString().PadRight(22, ' ') + " " + EndTime.ToString().PadRight(22, ' ')); }
/// <summary> /// Initializes the underlying <see cref="UdpClient" /> connection. /// </summary> /// <remarks> /// <para> /// The underlying <see cref="UdpClient"/> is initialized and binds to the /// port number from which you intend to communicate. /// </para> /// <para> /// Exceptions are passed to the <see cref="AppenderSkeleton.ErrorHandler"/>. /// </para> /// </remarks> protected virtual void InitializeClientConnection() { try { if (LocalPort == 0) { #if NETCF || NET_1_0 || SSCLI_1_0 || CLI_1_0 this.Client = new UdpClient(); #else Client = new UdpClient(RemoteAddress.AddressFamily); #endif } else { #if NETCF || NET_1_0 || SSCLI_1_0 || CLI_1_0 this.Client = new UdpClient(this.LocalPort); #else Client = new UdpClient(LocalPort, RemoteAddress.AddressFamily); #endif } } catch (Exception ex) { ErrorHandler.Error( "Could not initialize the UdpClient connection on port " + LocalPort.ToString(NumberFormatInfo.InvariantInfo) + ".", ex, ErrorCode.GenericFailure); Client = null; } }
public string ToSummary() { return(DateFormatter(EndTime) + " " + PartitionId.PadRight(2, ' ') + " " + ProtocolFormatter(Protocol, FlagAA).PadRight(8, ' ') + " " + LocalPort.ToString().PadRight(5, ' ') + " " + (ForeignIp + ":" + ForeignPort).PadRight(21, ' ')); }
public override string ToString() { List <string> paraList = new List <string>(); paraList.Add(LocalAddress); paraList.Add(LocalPort.ToString()); paraList.Add(MacAddress.ToString()); return(String.Format("{0}://{1}", Prefix, String.Join(SpitChar, paraList))); }
private void ParameterSaveCommandExecute() { Inifile.INIWriteValue(iniParameterPath, "System", "RemotePath", RemotePath); Inifile.INIWriteValue(iniParameterPath, "System", "MachineID", MachineID); Inifile.INIWriteValue(iniParameterPath, "Remote", "IP", RemoteIP); Inifile.INIWriteValue(iniParameterPath, "Remote", "PORT", RemotePort.ToString()); Inifile.INIWriteValue(iniParameterPath, "Local", "IP", LocalIP); Inifile.INIWriteValue(iniParameterPath, "Local", "PORT", LocalPort.ToString()); AddMessage("保存参数"); }
public override bool Equals(object obj) { var item = obj as Connection; if (item == null) { return(false); } return(OwnerPid.Equals(item.OwnerPid) && ExternalPort.Equals(item.ExternalPort) && LocalPort.Equals(item.LocalPort) && ExternalAddress.Equals(item.ExternalAddress) && LocalAddress.Equals(item.LocalAddress) && Protocol.Equals(item.Protocol) && State.Equals(item.State)); }
/// <summary> /// Initializes the underlying <see cref="UdpClient" /> connection. /// </summary> /// <remarks> /// <para> /// The underlying <see cref="UdpClient"/> is initialized and binds to the /// port number from which you intend to communicate. /// </para> /// <para> /// Exceptions are passed to the <see cref="AppenderSkeleton.ErrorHandler"/>. /// </para> /// </remarks> protected virtual void InitializeClientConnection() { try { if (LocalPort == 0) { Client = new UdpClient(); } else { Client = new UdpClient(LocalPort); } } catch (Exception ex) { ErrorHandler.Error( "Could not initialize the UdpClient connection on port " + LocalPort.ToString(NumberFormatInfo.InvariantInfo) + ".", ex, ErrorCode.GenericFailure); Client = null; } }
/// <summary> /// Gets the Xml tree for the custom serialiser /// </summary> /// <returns>An XElement </returns> public XElement GetXmlTree() { var element = new XElement(Namespaces.NsWindowsAzure + "InputEndpoint", new XElement(Namespaces.NsWindowsAzure + "LocalPort", LocalPort.ToString(CultureInfo.InvariantCulture)), new XElement(Namespaces.NsWindowsAzure + "Name", EndpointName.ToString(CultureInfo.InvariantCulture))); if (Port.HasValue) { element.Add(new XElement(Namespaces.NsWindowsAzure + "Port", Port.Value.ToString(CultureInfo.InvariantCulture))); } element.Add(new XElement(Namespaces.NsWindowsAzure + "Protocol", content: Protocol.ToString().ToLower())); return(element); }
public override string ToString() { return((new System.Net.IPAddress(LocalIP)).ToString() + ":" + LocalPort.ToString() + "=>" + (new System.Net.IPAddress(RemoteIP)).ToString() + ":" + RemotePort.ToString()); }
public static void GetConfigFromUserInput() { bool isComplete = false; while (!isComplete) { Output.Display("\nCreate a new log file? (Y/n - 'No' will append to existing file):> "); var newLog = Console.ReadLine(); Output.Display($"Enter a local port to listen on:\n[ Default: {LocalPort} ]:> "); var port = Console.ReadLine(); if (string.IsNullOrWhiteSpace(port)) { port = LocalPort.ToString(); } Output.Display($"Enter a local endpoint to listen on\n[ Default: {CallbackEndpoint} ]:> "); var endpoint = Console.ReadLine(); if (string.IsNullOrWhiteSpace(endpoint)) { endpoint = CallbackEndpoint; } Output.Display($"Enter Identity Server endpoint to use\n[ Default: {IdentityServerEndpoint} ]:> "); var identityEndpoint = Console.ReadLine(); if (string.IsNullOrWhiteSpace(identityEndpoint)) { identityEndpoint = IdentityServerEndpoint; } Output.Display($"Enter Client Id to use\n[ Default: {ClientId} ]:> "); var clientid = Console.ReadLine(); if (string.IsNullOrWhiteSpace(clientid)) { clientid = ClientId; } Output.Display($"Enter Client Secret to use\n[ Default: {ClientSecret} ]:> "); var clientsecret = Console.ReadLine(); if (string.IsNullOrWhiteSpace(clientsecret)) { clientsecret = ClientSecret; } Console.WriteLine("\nConfiguration is:"); if (newLog.IsYes()) { Output.Display("* A new log file will be created.\n"); } else { Output.Display("* Exiting log file will be appended to.\n"); } Output.Display($"* Local callback endpoint is:\n\t["); Output.Display(ConstructEndpointUrl(endpoint, port), InfoType.Emphasis); Output.Display(" ].\n"); Output.Display("* Identity Server endpoint is:\n\t[ "); Output.Display(identityEndpoint, InfoType.Emphasis); Output.Display(" ].\n"); Output.Display($"* Client Id is: [ "); Output.Display(clientid, InfoType.Emphasis); Output.Display(" ].\n"); Output.Display($"* Client Secret is: [ "); Output.Display(clientsecret, InfoType.Emphasis); Output.Display(" ].\n"); Output.Display(">> Is this correct? (Y/n)> "); var answer = Console.ReadLine(); if (answer.IsYes()) { if (newLog.IsYes()) { CreateNewLogFile = true; } else { CreateNewLogFile = false; } CallbackEndpoint = endpoint; LocalPort = port.AsNumber(80); if (LocalPort >= 80) { isComplete = true; } IdentityServerEndpoint = identityEndpoint; ClientId = clientid; ClientSecret = clientsecret; } else { Output.Display("\n"); } } }
private void cmdConnect_Click(object sender, EventArgs e) { int LocalPort; int RemotePort; switch (lstRemotePort.Text) { case "HTTP": lstRemotePort.Text = "80"; break; case "HTTPS": lstRemotePort.Text = "443"; break; case "RDP": lstRemotePort.Text = "3389"; break; case "POP3": lstRemotePort.Text = "110"; break; case "SMTP": lstRemotePort.Text = "25"; break; case "IMAP": lstRemotePort.Text = "143"; break; case "SSH": lstRemotePort.Text = "22"; break; case "TELNET": lstRemotePort.Text = "23"; break; } if (int.TryParse(txtLocalPort.Text, out LocalPort) == false) { MessageBox.Show(this, "Invalid Local Port.", Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (LocalPort < 1 || LocalPort > 65535) { MessageBox.Show(this, "Invalid Local Port.", Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (txtRemoteServer.Text.Trim() == "") { MessageBox.Show(this, "Invalid Remote Server.", Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (txtRemoteServer.Text.Contains("\"") == true || txtRemoteServer.Text.Contains("^") == true || txtRemoteServer.Text.Contains("\\") == true || txtRemoteServer.Text.Contains("%") == true) { MessageBox.Show(this, "Invalid Remote Server.", Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (int.TryParse(lstRemotePort.Text, out RemotePort) == false) { MessageBox.Show(this, "Invalid Remote Port.", Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (RemotePort < 1 || RemotePort > 65535) { MessageBox.Show(this, "Invalid Remote Port.", Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } string Exec = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "FoxSDC_RemoteConnect.exe"); string SessionID = Program.net.CloneSession(); if (string.IsNullOrWhiteSpace(SessionID) == true) { MessageBox.Show(this, "Cannot get a new SessionID from the Server", Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } try { Process p = new Process(); p.StartInfo.FileName = Exec; p.StartInfo.Arguments = "-direct \"" + Program.net.ConnectedURL + "\" \"" + MID + "\" \"" + SessionID + "\" " + LocalPort.ToString() + " \"" + txtRemoteServer.Text + "\" " + RemotePort.ToString(); p.StartInfo.UseShellExecute = false; p.Start(); } catch (Exception ee) { MessageBox.Show(this, "Cannot start the process " + Exec + " - " + ee.Message, Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Debug.WriteLine(ee.ToString()); return; } }