public GeneralSocket(System.Net.Sockets.AddressFamily addressFamily, System.Net.Sockets.SocketType socketType, System.Net.Sockets.ProtocolType protocolType, System.Net.EndPoint localEndPoint) : base(addressFamily, socketType, protocolType) { base.Bind(localEndPoint); }
public Socket(ns.AddressFamily addressFamily, ns.SocketType socketType, ns.ProtocolType protocolType) : base(addressFamily, socketType, protocolType) { lock (_socklist) { _socklist.Add(FD, this); } //EDB.WriteLine("Making socket w/ FD=" + FD); }
public Socket(ns.AddressFamily addressFamily, ns.SocketType socketType, ns.ProtocolType protocolType) : base(addressFamily, socketType, protocolType) { if (_socklist == null) { _socklist = new SortedList <uint, Socket>(); } _socklist.Add(FD, this); //EDB.WriteLine("Making socket w/ FD=" + FD); }
public void ConnectToVPN(string ip, int port, string user, string pass, System.Net.Sockets.ProtocolType proto) { if (connectTread != null && connectTread.IsAlive) { goDiconnect = true; connectTread.Join(); } connectTread = new Thread(() => { ConnectToVPNWorker(ip, port, user, pass, proto); }); connectTread.Start(); }
public CSADDR_INFO(BluetoothAddress local, BluetoothAddress remote, System.Net.Sockets.SocketType type, System.Net.Sockets.ProtocolType protocol) { //ensure zeros localAddr = IntPtr.Zero; localSize = 0; remoteAddr = IntPtr.Zero; remoteSize = 0; iSocketType = type; iProtocol = protocol; if (local != null) { #if V1 //have to use AllocHGlobal substitute localAddr = Marshal32.AllocHGlobal(40); Marshal.Copy(local.ToByteArray(), 0, new IntPtr(localAddr.ToInt32() + 8), 6); #else localAddr = Marshal.AllocHGlobal(40); Marshal.WriteInt64(localAddr, 8, local.ToInt64()); #endif Marshal.WriteInt16(localAddr, 0, 32); localSize = 40; } if (remote != null) { #if V1 remoteAddr = Marshal32.AllocHGlobal(40); Marshal.Copy(remote.ToByteArray(), 0, new IntPtr(remoteAddr.ToInt32() + 8), 6); #else remoteAddr = Marshal.AllocHGlobal(40); Marshal.WriteInt64(remoteAddr, 8, remote.ToInt64()); #endif remoteSize = 40; Marshal.WriteInt16(remoteAddr, 0, 32); } }
public Socket(ns.AddressFamily addressFamily, ns.SocketType socketType, ns.ProtocolType protocolType) : this(new ns.Socket(addressFamily, socketType, protocolType)) { //ROS.Debug()( $"[{ThisNode.Name}] Making socket w/ FD={FD}" ); }
private void SetProtocolVariables(String location) { try { String proType = ""; if (location.Contains(":")) { String[] parts = location.Split(new Char[] { ':' }); proType = parts[0]; _syslogPort = Convert.ToInt32(parts[1]); } else { proType = "udp"; _syslogPort = 514; } switch (proType.ToLower()) { case "tcp": _protocolType = ProtocolType.Tcp; break; default: _protocolType = ProtocolType.Udp; break; } } catch (Exception ex) { throw; } }
public override void Create(System.Net.Sockets.AddressFamily af, System.Net.Sockets.SocketType type, System.Net.Sockets.ProtocolType proto) { lock (m_syncRoot) { m_socket = new ElServerSSLSocket(new Socket(af, type, proto)); m_socket.Versions = m_protocols; // To speed the answer, we're using only the fastest cipher suites (based on experimentation ...) for (short i = SBSSLConstants.__Global.SB_SUITE_FIRST; i < SBSSLConstants.__Global.SB_SUITE_LAST; i++) { m_socket.set_CipherSuites(i, false); } // let the user overide cipher suites if they desire if (m_config.Security.CipherList != null && m_config.Security.CipherList.Count > 0) { foreach (var c in m_config.Security.CipherList) { m_socket.set_CipherSuites(c, true); } } else { m_socket.set_CipherSuites(SBSSLConstants.__Global.SB_SUITE_RSA_3DES_SHA, true); m_socket.set_CipherSuites(SBSSLConstants.__Global.SB_SUITE_RSA_AES128_SHA, true); m_socket.set_CipherSuites(SBSSLConstants.__Global.SB_SUITE_RSA_AES256_SHA, true); } m_socket.CustomCertStorage = m_certStorage; m_socket.OnError += new SBSSLCommon.TSBErrorEvent(m_socket_OnError); } }
public void Connect(string ip, int port, string user, string pass, System.Net.Sockets.ProtocolType proto) { Console.WriteLine("get connect to: " + ip + ":" + port.ToString()); this.oVpnConnetion.ConnectToVPN(ip, port, user, pass, proto); }
private void ConnectToVPNWorker(string ip, int port, string user, string pass, System.Net.Sockets.ProtocolType proto) { string appDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string pathConfig = Path.Combine(appDir, ".nfa-config.ovpn"); string pathPass = Path.Combine(appDir, ".nfa-pass.txt"); File.WriteAllText(pathPass, user + "\n" + pass); string ovpnConfig = Properties.Resources.ovpn_template; ovpnConfig = ovpnConfig.Replace("{{remote_ip_port}}", ip + " " + port.ToString()); ovpnConfig = ovpnConfig.Replace("{{user_pass}}", "\n" + user + "\n" + pass + "\n"); ovpnConfig = ovpnConfig.Replace("{{user_pass_path}}", pathPass.Replace(@"\", @"\\")); ovpnConfig = ovpnConfig.Replace("{{proto}}", proto == ProtocolType.Udp ? "udp" : "tcp"); File.WriteAllText(pathConfig, ovpnConfig); var pInfo = new ProcessStartInfo(); //pInfo.WindowStyle = ProcessWindowStyle.Hidden; pInfo.FileName = Path.Combine(dirName, @"openvpn\openvpn.exe"); pInfo.Arguments = "\"" + pathConfig + "\""; pInfo.RedirectStandardError = true; pInfo.RedirectStandardOutput = true; pInfo.RedirectStandardInput = true; //pInfo.StandardOutputEncoding = System.Text.Encoding.UTF8; //pInfo.StandardErrorEncoding = System.Text.Encoding.UTF8; pInfo.UseShellExecute = false; var p = Process.Start(pInfo); p.OutputDataReceived += p_OutputDataReceived; p.ErrorDataReceived += p_OutputDataReceived; p.BeginOutputReadLine(); p.BeginErrorReadLine(); Thread.Sleep(100); TcpClient client = null; var tryCount = 5; while (client == null && tryCount-- > 0) { try { client = new TcpClient("127.0.0.1", 7000); } catch (Exception) { Thread.Sleep(100); } } if (client == null) { return; } var stream = client.GetStream(); var telnet = new Telnet(stream); telnet.WriteLine("state on"); //telnet.WriteLine("log all on"); //telnet.WriteLine("hold off"); //telnet.WriteLine("hold release"); telnet.WriteLine("bytecount 1"); int countToDiconnect = 0; while (true) { string line = telnet.GetLine(); if (line != null) { if (onState != null && line.StartsWith(">")) { onState.Invoke(line); } Console.WriteLine(line); } if (goDiconnect) { if (p.HasExited) { break; } else if (countToDiconnect > 10) //2s { break; } else if (countToDiconnect == 0) { telnet.WriteLine("signal SIGHUP"); } countToDiconnect++; } if (line == null) { Thread.Sleep(200); } } p.WaitForExit(200); goDiconnect = false; if (!p.HasExited) { p.Kill(); } }
public MySocket(AddressFamily addressFamily, SocketType socketType, System.Net.Sockets.ProtocolType protocolType) : base(addressFamily, socketType, protocolType) { Disposed = false; LastException = null; }
public SocketDebug(System.Net.Sockets.AddressFamily family, System.Net.Sockets.SocketType type, System.Net.Sockets.ProtocolType proto, string name) : base(family, type, proto) { this.name = name; }
public Socket(ns.AddressFamily addressFamily, ns.SocketType socketType, ns.ProtocolType protocolType) : this(new ns.Socket(addressFamily, socketType, protocolType)) { //EDB.WriteLine("Making socket w/ FD=" + FD); }
public override void Create(System.Net.Sockets.AddressFamily af, System.Net.Sockets.SocketType type, System.Net.Sockets.ProtocolType proto) { throw new NotImplementedException(); }
public override void Create(System.Net.Sockets.AddressFamily af, System.Net.Sockets.SocketType type, System.Net.Sockets.ProtocolType proto) { lock (m_syncRoot) { m_socket = new Socket(af, type, proto); } }