protected override void OnConnectionEstablished(SslServer.ConnectedEventArgs args, TcpClient client)
		{
			int port = args.LocalEndPoint.Port;
			byte[] bytes = new byte[4]
			{
				(byte)(0x00ff & (port >> 24)),
				(byte)(0x00ff & (port >> 16)),
				(byte)(0x00ff & (port >> 8)),
				(byte)(0x00ff & (port))
			};

			client.Stream.Write(bytes, 0, 4);
		}
        /// <summary> </summary>
		protected override void OnConnectionEstablished(SslServer.ConnectedEventArgs args, TcpClient client)
		{
		}
        /// <summary>
        /// Forwards this server to the supplied target
        /// </summary>
		public TcpRedirector(TcpServer server, TcpClient target)
			: base(server)
		{
			_target = target;
		}
Example #4
0
		private TcpClient MakeSender(TunnelSender target)
		{
			TcpClient client = null;
			if (!target.UseSsl)
				client = new TcpClient(target.IpEndpoint, target.Port);
			else
			{
				X509Certificate cert = null;
				if (!String.IsNullOrEmpty(target.ClientCertificate))
					cert = new X509Certificate(target.ClientCertificate, target.ClientCertPassword);

				client = new SslClient(target.IpEndpoint, target.Port, cert, target.ExpectedCert);
			}
			return client;
		}
		public void Add(int port, TcpClient client)
		{
			_targets.Add(port, client);
		}
        /// <summary>
        /// Called to handle a handshake when connecting to the forwarding target host 
        /// </summary>
		protected abstract void OnConnectionEstablished(SslServer.ConnectedEventArgs args, TcpClient client);
		public TcpMultiplexer(TcpClient target)
		{
			_target = target;
		}