コード例 #1
0
        public XSPWorker(Socket client, EndPoint localEP, ApplicationServer server,
                         bool secureConnection,
                         Mono.Security.Protocol.Tls.SecurityProtocolType SecurityProtocol,
                         X509Certificate cert,
                         PrivateKeySelectionCallback keyCB,
                         bool allowClientCert,
                         bool requireClientCert)
        {
            if (secureConnection)
            {
                ssl = new SslInformations();
                ssl.AllowClientCertificate   = allowClientCert;
                ssl.RequireClientCertificate = requireClientCert;
                ssl.RawServerCertificate     = cert.GetRawCertData();

                netStream = new LingeringNetworkStream(client, true);
                SslServerStream s = new SslServerStream(netStream, cert, requireClientCert, false);
                s.PrivateKeyCertSelectionDelegate += keyCB;
                s.ClientCertValidationDelegate    += new CertificateValidationCallback(ClientCertificateValidation);
                stream = s;
            }
            else
            {
                netStream = new LingeringNetworkStream(client, false);
                stream    = netStream;
            }

            sock          = client;
            this.server   = server;
            this.remoteEP = (IPEndPoint)client.RemoteEndPoint;
            this.localEP  = (IPEndPoint)localEP;
        }
コード例 #2
0
 public XSPWorker(Socket client, EndPoint localEP, ApplicationServer server)
 {
     netStream     = new LingeringNetworkStream(client, false);
     stream        = netStream;
     sock          = client;
     this.server   = server;
     this.remoteEP = (IPEndPoint)client.RemoteEndPoint;
     this.localEP  = (IPEndPoint)localEP;
 }
コード例 #3
0
ファイル: XSPWorker.cs プロジェクト: nuxleus/xsp
        public XSPWorker(Socket client, EndPoint localEP, ApplicationServer server,
			bool secureConnection,
			Mono.Security.Protocol.Tls.SecurityProtocolType SecurityProtocol,
			X509Certificate cert,
			PrivateKeySelectionCallback keyCB,
			bool allowClientCert,
			bool requireClientCert)
        {
            if (secureConnection) {
                ssl = new SslInformation ();
                ssl.AllowClientCertificate = allowClientCert;
                ssl.RequireClientCertificate = requireClientCert;
                ssl.RawServerCertificate = cert.GetRawCertData ();

                netStream = new LingeringNetworkStream (client, true);
                SslServerStream s = new SslServerStream (netStream, cert, requireClientCert, false);
                s.PrivateKeyCertSelectionDelegate += keyCB;
                s.ClientCertValidationDelegate += new CertificateValidationCallback (ClientCertificateValidation);
                stream = s;
            } else {
                netStream = new LingeringNetworkStream (client, false);
                stream = netStream;
            }

            sock = client;
            this.server = server;
            this.remoteEP = (IPEndPoint) client.RemoteEndPoint;
            this.localEP = (IPEndPoint) localEP;
        }
コード例 #4
0
		public override void Close ()
		{
			if (closed)
				return;

			closed = true;
			try {
				modRequest.Close ();
			} catch {} // ignore any error
			try {
				if (Stream != null) {
					Stream.Close ();
					Stream = null;
				}
			} catch {}
		}
コード例 #5
0
		void InnerRun (object state)
		{
			requestId = -1;
			broker = null;
			
			RequestReader rr = new RequestReader (Stream);
			if (rr.ShuttingDown) {
				Close ();
				server.Stop ();
				return;
			}

			string vhost = rr.Request.GetRequestHeader ("Host");
			int port = -1;
			if (vhost != null) {
				int colon = vhost.IndexOf (':');
				if (colon != -1) {
					port = Int32.Parse (vhost.Substring (colon + 1));
					vhost = vhost.Substring (0, colon);
				} else {
					port = 80;
				}
			}

			VPathToHost vapp = null;
			string vpath = rr.GetUriPath ();
			string path = rr.GetPhysicalPath ();
			if (path == null) {
				vapp = server.GetApplicationForPath (vhost, port, vpath, false);
			} else {
				vapp = GetOrCreateApplication (vhost, port, path, vpath);
			}

			if (vapp == null) {
				rr.Decline ();
				Stream.Close ();
				Stream = null;
				return;
			}

			ModMonoApplicationHost host = (ModMonoApplicationHost) vapp.AppHost;
			if (host == null) {
				rr.Decline ();
				Stream.Close ();
				Stream = null;
				return;
			}
			modRequest = rr.Request;
			
			broker = (ModMonoRequestBroker) vapp.RequestBroker; 
			requestId = broker.RegisterRequest (this);
			
			host.ProcessRequest (requestId, 
								modRequest.GetHttpVerbName(), 
								modRequest.GetQueryString(), 
								modRequest.GetUri(), 
								modRequest.GetProtocol(), 
								modRequest.GetLocalAddress(), 
								modRequest.GetServerPort(), 
								modRequest.GetRemoteAddress(), 
								modRequest.GetRemotePort(), 
								modRequest.GetRemoteName(), 
								modRequest.GetAllHeaders(),
								modRequest.GetAllHeaderValues());
		}
コード例 #6
0
		public override void Run (object state)
		{
			try {
				InnerRun (state);
			} catch (FileNotFoundException fnf) {
				// We print this one, as it might be a sign of a bad deployment
				// once we require the .exe and Mono.WebServer in bin or the GAC.
				Console.Error.WriteLine (fnf);
			} catch (IOException) {
				// This is ok (including EndOfStreamException)
			} catch (Exception e) {
				Console.Error.WriteLine (e);
			} finally {
				try {
					// Closing is enough for mod_mono. the module will return a 50x
					Stream.Close ();
					Stream = null;
				} catch {}

				if (broker != null && requestId != -1)
					broker.UnregisterRequest (requestId);
			}
		}
コード例 #7
0
		public ModMonoWorker (Socket client, ApplicationServer server)
		{
			Stream = new LingeringNetworkStream (client, true);
			Stream.EnableLingering = false;
			this.server = server;
		}
コード例 #8
0
ファイル: XSPWorker.cs プロジェクト: cyotek/translateclient
 public XSPWorker(Socket client, EndPoint localEP, ApplicationServer server)
 {
     netStream = new LingeringNetworkStream (client, false);
     stream = netStream;
     sock = client;
     this.server = server;
     this.remoteEP = (IPEndPoint) client.RemoteEndPoint;
     this.localEP = (IPEndPoint) localEP;
 }