2007-10-22  Robert Jordan  <robertj@gmx.net>

	* Makefile.am: Reflect changes.
	* Mono.WebServer.Apache/main.cs: Remove XSP-related code.
	* Mono.WebServer.XSP/main.cs: Remove ModMono-related code.
	* Mono.WebServer.Apache/Makefile.am: Create from .Makefile.am.
	* Mono.WebServer.XSP/Makefile.am: Create from Makefile.am.
	* server.cs: Copy as main.cs to Mono.WebServer.Apache and
	Mono.WebServer.XSP
	* security.cs: Move to Mono.WebServer.XSP/SecurityConfiguration.cs
	* ModMono*.cs: Move to Mono.WebServer.Apache.
	* Mono.WebServer.Apache: Create.
	* Mono.WebServer.FastCgi: Create.
	* Mono.WebServer.XSP: Create.
In .:
2007-10-22  Robert Jordan  <robertj@gmx.net>

	* configure.in, scripts/Makefile.am:
	 Reflect src changes (fastcgi integration).


svn path=/branches/robertj/xsp/; revision=87874
This commit is contained in:
Robert Jordan 2007-10-21 22:09:08 +00:00
Родитель 9f405db549
Коммит 8781bc8990
21 изменённых файлов: 514 добавлений и 324 удалений

Просмотреть файл

@ -1,3 +1,8 @@
2007-10-22 Robert Jordan <robertj@gmx.net>
* configure.in, scripts/Makefile.am:
Reflect src changes (fastcgi integration).
2007-10-03 Juraj Skripsky <js@hotfeet.ch>
* src/ModMonoRequest.cs: put the ModMonoConfig struct in charge to

Просмотреть файл

@ -1,5 +1,5 @@
AC_PREREQ(2.57)
AC_INIT(src/server.cs)
AC_INIT(src/Mono.WebServer.XSP/main.cs)
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE(xsp, 1.2.5)
AM_MAINTAINER_MODE
@ -91,13 +91,17 @@ AC_OUTPUT([
man/Makefile
scripts/Makefile
src/Makefile
src/AssemblyInfo.cs
src/AssemblyInfoModMono.cs
src/Mono.WebServer/AssemblyInfo.cs
src/Mono.WebServer/AssemblyInfo2.cs
src/Mono.WebServer/Makefile
src/Mono.WebServer/xsp.pc
src/Mono.WebServer/xsp-2.pc
src/Mono.WebServer.Apache/Makefile
src/Mono.WebServer.Apache/AssemblyInfo.cs
src/Mono.WebServer.FastCgi/Makefile
src/Mono.WebServer.FastCgi/AssemblyInfo.cs
src/Mono.WebServer.XSP/Makefile
src/Mono.WebServer.XSP/AssemblyInfo.cs
test/Makefile
test/1.1/Makefile
test/1.1/authtest/Makefile

Просмотреть файл

@ -1,12 +1,12 @@
EXTRA_DIST = script.in
bin2_scripts_real = xsp2 mod-mono-server2
bin2_scripts_real = xsp2 mod-mono-server2 fastcgi-mono-server2
if NET_2_0
bin2_scripts = $(bin2_scripts_real)
tool2_scripts = asp-state2 dbsessmgr2
endif
bin1_scripts = xsp mod-mono-server
bin1_scripts = xsp mod-mono-server fastcgi-mono-server
tool_scripts = asp-state dbsessmgr
bin_SCRIPTS = $(bin1_scripts) $(bin2_scripts) $(tool_scripts) $(tool2_scripts)

Просмотреть файл

@ -1,4 +0,0 @@
Makefile
Makefile.in
AssemblyInfo*.cs
*.mdb

14
src/ChangeLog Normal file
Просмотреть файл

@ -0,0 +1,14 @@
2007-10-22 Robert Jordan <robertj@gmx.net>
* Makefile.am: Reflect changes.
* Mono.WebServer.Apache/main.cs: Remove XSP-related code.
* Mono.WebServer.XSP/main.cs: Remove ModMono-related code.
* Mono.WebServer.Apache/Makefile.am: Create from .Makefile.am.
* Mono.WebServer.XSP/Makefile.am: Create from Makefile.am.
* server.cs: Copy as main.cs to Mono.WebServer.Apache and
Mono.WebServer.XSP
* security.cs: Move to Mono.WebServer.XSP/SecurityConfiguration.cs
* ModMono*.cs: Move to Mono.WebServer.Apache.
* Mono.WebServer.Apache: Create.
* Mono.WebServer.FastCgi: Create.
* Mono.WebServer.XSP: Create.

Просмотреть файл

@ -1,89 +1,7 @@
SUBDIRS=Mono.WebServer
builddir=$(top_builddir)/src
MCSFLAGS= -debug+ -debug:full -nologo -nowarn:618 $(WEBTRACING)
xspdir = $(prefix)/lib/xsp/1.0
modmonoserverdir = $(prefix)/lib/xsp/1.0
xsp2dir = $(prefix)/lib/xsp/2.0
modmonoserver2dir = $(prefix)/lib/xsp/2.0
GACUTIL1=$(GACUTIL) -package 1.0
if NET_2_0
XSP2_EXE = xsp2.exe
MODMONOSERVER2_EXE = mod-mono-server2.exe
GACUTIL2=$(GACUTIL) -package 2.0
endif
if !XSP_ONLY
modmonoserver_SCR = mod-mono-server.exe
modmonoserver2_SCR = $(MODMONOSERVER2_EXE)
endif
noinst_SCRIPTS=xsp.exe xsp.exe $(XSP2_EXE) $(modmonoserver_SCR) $(modmonoserver2_SCR)
CLEANFILES = *.exe *.mdb
#
xsp_references= -r:System.Web.dll -r:Mono.WebServer/Mono.WebServer.dll -r:Mono.Security.dll
xsp2_references= -r:System.Web.dll -r:System.Configuration.dll -r:Mono.WebServer/Mono.WebServer2.dll -r:Mono.Security.dll
if PLATFORM_WIN32
modmono_references= -lib:"$(prefix)/lib" -r:Mono.WebServer/Mono.WebServer.dll \
-r:System.Web.dll -r:Mono.Posix.dll -r:Mono.Security.dll
modmono2_references= -lib:"$(prefix)/lib" -r:Mono.WebServer/Mono.WebServer2.dll \
-r:System.Web.dll -r:Mono.Posix.dll -r:Mono.Security.dll
if XSP_ONLY
SUBDIRS=Mono.WebServer Mono.WebServer.XSP
else
modmono_references= -r:System.Web.dll -r:Mono.WebServer/Mono.WebServer.dll -r:Mono.Posix.dll -r:Mono.Security.dll
modmono2_references= -r:System.Web.dll -r:System.Configuration.dll -r:Mono.WebServer/Mono.WebServer2.dll \
-r:Mono.Posix.dll -r:Mono.Security.dll
SUBDIRS=Mono.WebServer Mono.WebServer.XSP Mono.WebServer.Apache Mono.WebServer.FastCGI
endif
xsp_sources = server.cs security.cs
xsp_build_sources = $(addprefix $(srcdir)/, $(xsp_sources)) AssemblyInfo.cs
modmono_only = ModMonoRequest.cs \
ModMonoWorkerRequest.cs \
ModMonoApplicationHost.cs \
ModMonoTCPWebSource.cs \
ModMonoRequestBroker.cs \
ModMonoWebSource.cs \
ModMonoWorker.cs
modmono_sources = $(modmono_only) $(xsp_sources)
modmono_build_sources = $(addprefix $(srcdir)/, $(modmono_sources)) AssemblyInfoModMono.cs
EXTRA_DIST = $(xsp_sources) $(modmono_only) AssemblyInfo.cs.in AssemblyInfoModMono.cs.in mono.pub mono.snk
xsp.exe: $(xsp_build_sources)
$(MCS) $(MCSFLAGS) $(xsp_references) /out:$@ $(xsp_build_sources)
$(SN) -q -R $(builddir)/$@ $(srcdir)/mono.snk
mod-mono-server.exe: $(modmono_build_sources)
$(MCS) $(MCSFLAGS) $(modmono_references) /d:MODMONO_SERVER /out:$@ $(modmono_build_sources)
$(SN) -q -R $(builddir)/$@ $(srcdir)/mono.snk
xsp2.exe: $(xsp_build_sources)
$(GMCS) -d:NET_2_0 $(MCSFLAGS) $(xsp2_references) /out:$@ $(xsp_build_sources)
$(SN) -q -R $(builddir)/$@ $(srcdir)/mono.snk
mod-mono-server2.exe: $(modmono_build_sources)
$(GMCS) -d:NET_2_0 $(MCSFLAGS) $(modmono2_references) /d:MODMONO_SERVER /out:$@ $(modmono_build_sources)
$(SN) -q -R $(builddir)/$@ $(srcdir)/mono.snk
install-data-local:
for i in xsp.exe $(modmonoserver_SCR) ; do \
$(GACUTIL1) $(GACUTIL_FLAGS) -i $(top_builddir)/src/$$i ; \
done
#if NET_2_0
for i in xsp2.exe $(modmonoserver2_SCR) ; do \
$(GACUTIL2) $(GACUTIL_FLAGS) -i $(top_builddir)/src/$$i ; \
done
#endif
uninstall-local:
-for i in xsp mod-mono-server xsp2 mod-mono-server2 ; do \
$(GACUTIL) $(GACUTIL_FLAGS) -u $$(basename $$i .exe) ; \
done
EXTRA_DIST = mono.pub mono.snk

Просмотреть файл

@ -1,9 +1,9 @@
// AssemblyInfoModMono.cs.in:
// AssemblyInfo.cs.in:
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
// Copyright (c) 2002,2003,2004,2005,2006 Novell, Inc. (http://www.novell.com)
// Copyright (c) 2002-2007 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@ -29,9 +29,9 @@ using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: AssemblyVersion("@VERSION@")]
[assembly: AssemblyTitle ("ModMono-XSP Server")]
[assembly: AssemblyDescription ("Minimalistic web server for testing System.Web")]
[assembly: AssemblyCopyright ("(c) 2002-2006 Novell, Inc.")]
[assembly: AssemblyTitle ("Mono.WebServer.Apache")]
[assembly: AssemblyDescription ("Mod_mono backend for XSP")]
[assembly: AssemblyCopyright ("(c) 2002-2007 Novell, Inc.")]
[assembly: AssemblyCompany ("Novell, Inc.")]
[assembly: AssemblyDelaySign(true)]
[assembly: AssemblyKeyFile("@top_srcdir@/src/mono.pub")]

Просмотреть файл

@ -0,0 +1,48 @@
builddir=$(top_builddir)/src/Mono.WebServer.Apache
MCSFLAGS= -debug+ -debug:full -nologo -nowarn:618 $(WEBTRACING)
GACUTIL1=$(GACUTIL) -package 1.0
if NET_2_0
MODMONOSERVER2_EXE = mod-mono-server2.exe
GACUTIL2=$(GACUTIL) -package 2.0
endif
noinst_SCRIPTS=mod-mono-server.exe $(MODMONOSERVER2_EXE)
CLEANFILES = *.exe *.mdb
if PLATFORM_WIN32
references= -lib:"$(prefix)/lib" -r:../Mono.WebServer/Mono.WebServer.dll \
-r:System.Web.dll -r:Mono.Posix.dll -r:Mono.Security.dll
references2= -lib:"$(prefix)/lib" -r:../Mono.WebServer/Mono.WebServer2.dll \
-r:System.Web.dll -r:Mono.Posix.dll -r:Mono.Security.dll
else
references= -r:System.Web.dll -r:../Mono.WebServer/Mono.WebServer.dll -r:Mono.Posix.dll -r:Mono.Security.dll
references2= -r:System.Web.dll -r:System.Configuration.dll -r:../Mono.WebServer/Mono.WebServer2.dll \
-r:Mono.Posix.dll -r:Mono.Security.dll
endif
sources = $(addprefix $(srcdir)/, $(shell cat Mono.WebServer.Apache.sources))
EXTRA_DIST = $(sources) AssemblyInfo.cs.in
mod-mono-server.exe: $(sources)
$(MCS) $(MCSFLAGS) $(references) /d:MODMONO_SERVER /out:$@ $(sources)
$(SN) -q -R $(builddir)/$@ $(builddir)/../mono.snk
mod-mono-server2.exe: $(sources)
$(GMCS) -d:NET_2_0 $(MCSFLAGS) $(references2) /d:MODMONO_SERVER /out:$@ $(sources)
$(SN) -q -R $(builddir)/$@ $(builddir)/../mono.snk
install-data-local:
$(GACUTIL1) $(GACUTIL_FLAGS) -i $(builddir)/mod-mono-server.exe
#if NET_2_0
$(GACUTIL2) $(GACUTIL_FLAGS) -i $(builddir)/mod-mono-server2.exe
#endif
uninstall-local:
-for i in mod-mono-server mod-mono-server2 ; do \
$(GACUTIL) $(GACUTIL_FLAGS) -u $i ; \
done

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -0,0 +1,376 @@
//
// Mono.WebServer.Apache/main.cs: Mod_mono Backend for XSP.
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
// (C) 2002,2003 Ximian, Inc (http://www.ximian.com)
// (C) Copyright 2004-2007 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Configuration;
using System.Collections.Specialized;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Reflection;
using System.Web.Hosting;
using Mono.WebServer;
namespace Mono.WebServer.Apache
{
public class Server
{
static void ShowVersion ()
{
Assembly assembly = Assembly.GetExecutingAssembly ();
string version = assembly.GetName ().Version.ToString ();
object [] att = assembly.GetCustomAttributes (typeof (AssemblyTitleAttribute), false);
//string title = ((AssemblyTitleAttribute) att [0]).Title;
att = assembly.GetCustomAttributes (typeof (AssemblyCopyrightAttribute), false);
string copyright = ((AssemblyCopyrightAttribute) att [0]).Copyright;
att = assembly.GetCustomAttributes (typeof (AssemblyDescriptionAttribute), false);
string description = ((AssemblyDescriptionAttribute) att [0]).Description;
Console.WriteLine ("{0} {1}\n(c) {2}\n{3}",
Path.GetFileName (assembly.Location), version, copyright, description);
}
static void ShowHelp ()
{
Console.WriteLine ("mod-mono-server.exe is a ASP.NET server used from mod_mono.");
Console.WriteLine ("Usage is:\n");
Console.WriteLine (" mod-mono-server.exe [...]");
Console.WriteLine ();
Console.WriteLine (" The arguments --filename and --port are mutually exlusive.");
Console.WriteLine (" --filename file: a unix socket filename to listen on.");
Console.WriteLine (" Default value: /tmp/mod_mono_server");
Console.WriteLine (" AppSettings key name: MonoUnixSocket");
Console.WriteLine ();
Console.WriteLine (" --port N: n is the tcp port to listen on.");
Console.WriteLine (" Default value: none");
Console.WriteLine (" AppSettings key name: MonoServerPort");
Console.WriteLine ();
Console.WriteLine (" --address addr: addr is the ip address to listen on.");
Console.WriteLine (" Default value: 127.0.0.1");
Console.WriteLine (" AppSettings key name: MonoServerAddress");
Console.WriteLine ();
Console.WriteLine (" --root rootdir: the server changes to this directory before");
Console.WriteLine (" anything else.");
Console.WriteLine (" Default value: current directory.");
Console.WriteLine (" AppSettings key name: MonoServerRootDir");
Console.WriteLine ();
Console.WriteLine (" --appconfigfile FILENAME: adds application definitions from the XML");
Console.WriteLine (" configuration file. See sample configuration file that");
Console.WriteLine (" comes with the server.");
Console.WriteLine (" AppSettings key name: MonoApplicationsConfigFile");
Console.WriteLine ();
Console.WriteLine (" --appconfigdir DIR: adds application definitions from all XML files");
Console.WriteLine (" found in the specified directory DIR. Files must have");
Console.WriteLine (" '.webapp' extension");
Console.WriteLine (" AppSettings key name: MonoApplicationsConfigDir");
Console.WriteLine ();
Console.WriteLine (" --applications APPS:");
Console.WriteLine (" a comma separated list of virtual directory and");
Console.WriteLine (" real directory for all the applications we want to manage");
Console.WriteLine (" with this server. The virtual and real dirs. are separated");
Console.WriteLine (" by a colon. Optionally you may specify virtual host name");
Console.WriteLine (" and a port.");
Console.WriteLine ();
Console.WriteLine (" [[hostname:]port:]VPath:realpath,...");
Console.WriteLine ();
Console.WriteLine (" Samples: /:.");
Console.WriteLine (" the virtual / is mapped to the current directory.");
Console.WriteLine ();
Console.WriteLine (" /blog:../myblog");
Console.WriteLine (" the virtual /blog is mapped to ../myblog");
Console.WriteLine ();
Console.WriteLine (" myhost.someprovider.net:/blog:../myblog");
Console.WriteLine (" the virtual /blog at myhost.someprovider.net is mapped to ../myblog");
Console.WriteLine ();
Console.WriteLine (" /:.,/blog:../myblog");
Console.WriteLine (" Two applications like the above ones are handled.");
Console.WriteLine (" Default value: /:.");
Console.WriteLine (" AppSettings key name: MonoApplications");
Console.WriteLine ();
Console.WriteLine (" --terminate: gracefully terminates a running mod-mono-server instance.");
Console.WriteLine (" All other options but --filename or --address and --port");
Console.WriteLine (" are ignored if this option is provided.");
Console.WriteLine (" --master: this instance will be used to by mod_mono to create ASP.NET");
Console.WriteLine (" applications on demand. If this option is provided, there is no");
Console.WriteLine (" need to provide a list of applications to start.");
Console.WriteLine (" --nonstop: don't stop the server by pressing enter. Must be used");
Console.WriteLine (" when the server has no controlling terminal.");
Console.WriteLine ();
Console.WriteLine (" --version: displays version information and exits.");
Console.WriteLine (" --verbose: prints extra messages. Mainly useful for debugging.");
Console.WriteLine ();
}
[Flags]
enum Options {
NonStop = 1,
Verbose = 1 << 1,
Applications = 1 << 2,
AppConfigDir = 1 << 3,
AppConfigFile = 1 << 4,
Root = 1 << 5,
FileName = 1 << 6,
Address = 1 << 7,
Port = 1 << 8,
Terminate = 1 << 9,
Https = 1 << 10,
Master = 1 << 11
}
static void CheckAndSetOptions (string name, Options value, ref Options options)
{
if ((options & value) != 0) {
ShowHelp ();
Console.WriteLine ();
Console.WriteLine ("ERROR: Option '{0}' duplicated.", name);
Environment.Exit (1);
}
options |= value;
if ((options & Options.FileName) != 0 &&
((options & Options.Port) != 0 || (options & Options.Address) != 0)) {
ShowHelp ();
Console.WriteLine ();
Console.WriteLine ("ERROR: --port/--address and --filename are mutually exclusive");
Environment.Exit (1);
}
}
static NameValueCollection AppSettings {
get {
#if NET_2_0
return ConfigurationManager.AppSettings;
#else
return ConfigurationSettings.AppSettings;
#endif
}
}
public static void CurrentDomain_UnhandledException (object sender, UnhandledExceptionEventArgs e)
{
Exception ex = (Exception)e.ExceptionObject;
Console.WriteLine ("Handling exception type {0}", ex.GetType ().Name);
Console.WriteLine ("Message is {0}", ex.Message);
Console.WriteLine ("IsTerminating is set to {0}", e.IsTerminating);
}
public static int Main (string [] args)
{
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler (CurrentDomain_UnhandledException);
bool nonstop = false;
bool verbose = false;
Trace.Listeners.Add (new TextWriterTraceListener (Console.Out));
string apps = AppSettings ["MonoApplications"];
string appConfigDir = AppSettings ["MonoApplicationsConfigDir"];
string appConfigFile = AppSettings ["MonoApplicationsConfigFile"];
string rootDir = AppSettings ["MonoServerRootDir"];
object oport;
string ip = AppSettings ["MonoServerAddress"];
bool master = false;
string filename = AppSettings ["MonoUnixSocket"];
if (ip == "" || ip == null)
ip = "0.0.0.0";
oport = AppSettings ["MonoServerPort"];
if (oport == null)
oport = 8080;
Options options = 0;
int hash = 0;
for (int i = 0; i < args.Length; i++){
string a = args [i];
int idx = (i + 1 < args.Length) ? i + 1 : i;
hash ^= args [idx].GetHashCode () + i;
switch (a){
case "--filename":
CheckAndSetOptions (a, Options.FileName, ref options);
filename = args [++i];
break;
case "--terminate":
CheckAndSetOptions (a, Options.Terminate, ref options);
break;
case "--master":
CheckAndSetOptions (a, Options.Master, ref options);
master = true;
break;
case "--port":
CheckAndSetOptions (a, Options.Port, ref options);
oport = args [++i];
break;
case "--address":
CheckAndSetOptions (a, Options.Address, ref options);
ip = args [++i];
break;
case "--root":
CheckAndSetOptions (a, Options.Root, ref options);
rootDir = args [++i];
break;
case "--applications":
CheckAndSetOptions (a, Options.Applications, ref options);
apps = args [++i];
break;
case "--appconfigfile":
CheckAndSetOptions (a, Options.AppConfigFile, ref options);
appConfigFile = args [++i];
break;
case "--appconfigdir":
CheckAndSetOptions (a, Options.AppConfigDir, ref options);
appConfigDir = args [++i];
break;
case "--nonstop":
nonstop = true;
break;
case "--help":
ShowHelp ();
return 0;
case "--version":
ShowVersion ();
return 0;
case "--verbose":
verbose = true;
break;
default:
Console.WriteLine ("Unknown argument: {0}", a);
ShowHelp ();
return 1;
}
}
if (hash < 0)
hash = -hash;
string lockfile;
bool useTCP = ((options & Options.Port) != 0);
if (!useTCP) {
if (filename == null || filename == "")
filename = "/tmp/mod_mono_server";
if ((options & Options.Address) != 0) {
ShowHelp ();
Console.WriteLine ();
Console.WriteLine ("ERROR: --address without --port");
Environment.Exit (1);
} lockfile = Path.Combine (Path.GetTempPath (), Path.GetFileName (filename));
lockfile = String.Format ("{0}_{1}", lockfile, hash);
} else {
lockfile = Path.Combine (Path.GetTempPath (), "mod_mono_TCP_");
lockfile = String.Format ("{0}_{1}", lockfile, hash);
}
IPAddress ipaddr = null;
ushort port;
try {
port = Convert.ToUInt16 (oport);
} catch (Exception) {
Console.WriteLine ("The value given for the listen port is not valid: " + oport);
return 1;
}
try {
ipaddr = IPAddress.Parse (ip);
} catch (Exception) {
Console.WriteLine ("The value given for the address is not valid: " + ip);
return 1;
}
if (rootDir != null && rootDir != "") {
try {
Environment.CurrentDirectory = rootDir;
} catch (Exception e) {
Console.WriteLine ("Error: {0}", e.Message);
return 1;
}
}
rootDir = Directory.GetCurrentDirectory ();
WebSource webSource;
if (useTCP) {
webSource = new ModMonoTCPWebSource (ipaddr, port, lockfile);
} else {
webSource = new ModMonoWebSource (filename, lockfile);
}
if ((options & Options.Terminate) != 0) {
if (verbose)
Console.WriteLine ("Shutting down running mod-mono-server...");
bool res = ((ModMonoWebSource) webSource).GracefulShutdown ();
if (verbose)
Console.WriteLine (res ? "Done." : "Failed");
return (res) ? 0 : 1;
}
ApplicationServer server = new ApplicationServer (webSource);
server.Verbose = verbose;
Console.WriteLine (Assembly.GetExecutingAssembly ().GetName ().Name);
if (apps != null)
server.AddApplicationsFromCommandLine (apps);
if (appConfigFile != null)
server.AddApplicationsFromConfigFile (appConfigFile);
if (appConfigDir != null)
server.AddApplicationsFromConfigDirectory (appConfigDir);
if (!master && apps == null && appConfigDir == null && appConfigFile == null)
server.AddApplicationsFromCommandLine ("/:.");
if (!useTCP) {
Console.WriteLine ("Listening on: {0}", filename);
} else {
Console.WriteLine ("Listening on port: {0", port);
Console.WriteLine ("Listening on address: {0}", ip);
}
Console.WriteLine ("Root directory: {0}", rootDir);
try {
if (server.Start (!nonstop) == false)
return 2;
if (!nonstop) {
Console.WriteLine ("Hit Return to stop the server.");
Console.ReadLine ();
server.Stop ();
}
} catch (Exception e) {
Console.WriteLine ("Error: {0}", e.Message);
return 1;
}
return 0;
}
}
}

Просмотреть файл

@ -3,7 +3,7 @@
// Authors:
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
// Copyright (c) 2002,2003,2004,2005,2006 Novell, Inc. (http://www.novell.com)
// Copyright (c) 2002-2007 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@ -29,9 +29,9 @@ using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: AssemblyVersion("@VERSION@")]
[assembly: AssemblyTitle ("Mono-XSP Server")]
[assembly: AssemblyTitle ("Mono.WebServer.XSP")]
[assembly: AssemblyDescription ("Minimalistic web server for testing System.Web")]
[assembly: AssemblyCopyright ("(c) 2002-2006 Novell, Inc.")]
[assembly: AssemblyCopyright ("(c) 2002-2007 Novell, Inc.")]
[assembly: AssemblyCompany ("Novell, Inc.")]
[assembly: AssemblyDelaySign(true)]
[assembly: AssemblyKeyFile("@top_srcdir@/src/mono.pub")]

Просмотреть файл

@ -0,0 +1,44 @@
builddir=$(top_builddir)/src/Mono.WebServer.XSP
MCSFLAGS= -debug+ -debug:full -nologo -nowarn:618 $(WEBTRACING)
GACUTIL1=$(GACUTIL) -package 1.0
if NET_2_0
XSP2_EXE = xsp2.exe
GACUTIL2=$(GACUTIL) -package 2.0
endif
noinst_SCRIPTS=xsp.exe xsp.exe $(XSP2_EXE)
CLEANFILES = *.exe *.mdb
#
references = -r:System.Web.dll -r:../Mono.WebServer/Mono.WebServer.dll -r:Mono.Security.dll
references2 = -r:System.Web.dll -r:System.Configuration.dll -r:../Mono.WebServer/Mono.WebServer2.dll -r:Mono.Security.dll
sources = main.cs SecurityConfiguration.cs
build_sources = $(addprefix $(srcdir)/, $(sources)) AssemblyInfo.cs
EXTRA_DIST = $(sources) AssemblyInfo.cs.in
xsp.exe: $(build_sources)
$(MCS) $(MCSFLAGS) $(references) /out:$@ $(build_sources)
$(SN) -q -R $(builddir)/$@ $(builddir)/../mono.snk
xsp2.exe: $(build_sources)
$(GMCS) -d:NET_2_0 $(MCSFLAGS) $(references2) /out:$@ $(build_sources)
$(SN) -q -R $(builddir)/$@ $(builddir)/../mono.snk
install-data-local:
$(GACUTIL1) $(GACUTIL_FLAGS) -i $(builddir)/xsp.exe
#if NET_2_0
$(GACUTIL2) $(GACUTIL_FLAGS) -i $(builddir)/xsp2.exe
#endif
uninstall-local:
-for i in xsp xsp2 ; do \
$(GACUTIL) $(GACUTIL_FLAGS) -u $i ; \
done

Просмотреть файл

Просмотреть файл

@ -1,11 +1,11 @@
//
// server.cs: Web Server that uses ASP.NET hosting
// Mono.WebServer.XSP/main.cs: Web Server that uses ASP.NET hosting
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
// (C) 2002,2003 Ximian, Inc (http://www.ximian.com)
// (C) Copyright 2004 Novell, Inc. (http://www.novell.com)
// (C) Copyright 2004-2007 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@ -37,18 +37,14 @@ using System.Reflection;
using System.Web.Hosting;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
#if !MODMONO_SERVER
using Mono.Security.Protocol.Tls;
#endif
using Mono.WebServer;
namespace Mono.XSP
namespace Mono.WebServer.XSP
{
public class Server
{
#if !MODMONO_SERVER
static RSA key;
#endif
static void ShowVersion ()
{
@ -66,40 +62,19 @@ namespace Mono.XSP
static void ShowHelp ()
{
#if MODMONO_SERVER
Console.WriteLine ("mod-mono-server.exe is a ASP.NET server used from mod_mono.");
Console.WriteLine ("Usage is:\n");
Console.WriteLine (" mod-mono-server.exe [...]");
Console.WriteLine ();
Console.WriteLine (" The arguments --filename and --port are mutually exlusive.");
Console.WriteLine (" --filename file: a unix socket filename to listen on.");
Console.WriteLine (" Default value: /tmp/mod_mono_server");
Console.WriteLine (" AppSettings key name: MonoUnixSocket");
Console.WriteLine ();
#else
Console.WriteLine ("XSP server is a sample server that hosts the ASP.NET runtime in a");
Console.WriteLine ("minimalistic HTTP server\n");
Console.WriteLine ("Usage is:\n");
Console.WriteLine (" xsp.exe [...]");
Console.WriteLine ();
#endif
Console.WriteLine (" --port N: n is the tcp port to listen on.");
#if MODMONO_SERVER
Console.WriteLine (" Default value: none");
#else
Console.WriteLine (" Default value: 8080");
#endif
Console.WriteLine (" AppSettings key name: MonoServerPort");
Console.WriteLine ();
Console.WriteLine (" --address addr: addr is the ip address to listen on.");
#if MODMONO_SERVER
Console.WriteLine (" Default value: 127.0.0.1");
#else
Console.WriteLine (" Default value: 0.0.0.0");
#endif
Console.WriteLine (" AppSettings key name: MonoServerAddress");
Console.WriteLine ();
#if !MODMONO_SERVER
Console.WriteLine (" --https: enable SSL for the server");
Console.WriteLine (" Default value: false.");
Console.WriteLine (" AppSettings key name: ");
@ -129,7 +104,6 @@ namespace Mono.XSP
Console.WriteLine (" Default value: Default (all)");
Console.WriteLine (" AppSettings key name: ");
Console.WriteLine ();
#endif
Console.WriteLine (" --root rootdir: the server changes to this directory before");
Console.WriteLine (" anything else.");
Console.WriteLine (" Default value: current directory.");
@ -168,14 +142,6 @@ namespace Mono.XSP
Console.WriteLine (" Default value: /:.");
Console.WriteLine (" AppSettings key name: MonoApplications");
Console.WriteLine ();
#if MODMONO_SERVER
Console.WriteLine (" --terminate: gracefully terminates a running mod-mono-server instance.");
Console.WriteLine (" All other options but --filename or --address and --port");
Console.WriteLine (" are ignored if this option is provided.");
Console.WriteLine (" --master: this instance will be used to by mod_mono to create ASP.NET");
Console.WriteLine (" applications on demand. If this option is provided, there is no");
Console.WriteLine (" need to provide a list of applications to start.");
#endif
Console.WriteLine (" --nonstop: don't stop the server by pressing enter. Must be used");
Console.WriteLine (" when the server has no controlling terminal.");
Console.WriteLine ();
@ -220,12 +186,10 @@ namespace Mono.XSP
}
}
#if !MODMONO_SERVER
static AsymmetricAlgorithm GetPrivateKey (X509Certificate certificate, string targetHost)
{
return key;
}
#endif
static NameValueCollection AppSettings {
get {
@ -261,9 +225,7 @@ namespace Mono.XSP
object oport;
string ip = AppSettings ["MonoServerAddress"];
bool master = false;
#if MODMONO_SERVER
string filename = AppSettings ["MonoUnixSocket"];
#endif
if (ip == "" || ip == null)
ip = "0.0.0.0";
@ -279,19 +241,6 @@ namespace Mono.XSP
hash ^= args [idx].GetHashCode () + i;
switch (a){
#if MODMONO_SERVER
case "--filename":
CheckAndSetOptions (a, Options.FileName, ref options);
filename = args [++i];
break;
case "--terminate":
CheckAndSetOptions (a, Options.Terminate, ref options);
break;
case "--master":
CheckAndSetOptions (a, Options.Master, ref options);
master = true;
break;
#else
case "--https":
CheckAndSetOptions (a, Options.Https, ref options);
security.Enabled = true;
@ -323,7 +272,6 @@ namespace Mono.XSP
case "--protocols":
security.SetProtocol (args [++i]);
break;
#endif
case "--port":
CheckAndSetOptions (a, Options.Port, ref options);
oport = args [++i];
@ -367,28 +315,6 @@ namespace Mono.XSP
}
}
#if MODMONO_SERVER
if (hash < 0)
hash = -hash;
string lockfile;
bool useTCP = ((options & Options.Port) != 0);
if (!useTCP) {
if (filename == null || filename == "")
filename = "/tmp/mod_mono_server";
if ((options & Options.Address) != 0) {
ShowHelp ();
Console.WriteLine ();
Console.WriteLine ("ERROR: --address without --port");
Environment.Exit (1);
} lockfile = Path.Combine (Path.GetTempPath (), Path.GetFileName (filename));
lockfile = String.Format ("{0}_{1}", lockfile, hash);
} else {
lockfile = Path.Combine (Path.GetTempPath (), "mod_mono_TCP_");
lockfile = String.Format ("{0}_{1}", lockfile, hash);
}
#endif
IPAddress ipaddr = null;
ushort port;
try {
@ -417,24 +343,6 @@ namespace Mono.XSP
rootDir = Directory.GetCurrentDirectory ();
WebSource webSource;
#if MODMONO_SERVER
if (useTCP) {
webSource = new ModMonoTCPWebSource (ipaddr, port, lockfile);
} else {
webSource = new ModMonoWebSource (filename, lockfile);
}
if ((options & Options.Terminate) != 0) {
if (verbose)
Console.WriteLine ("Shutting down running mod-mono-server...");
bool res = ((ModMonoWebSource) webSource).GracefulShutdown ();
if (verbose)
Console.WriteLine (res ? "Done." : "Failed");
return (res) ? 0 : 1;
}
#else
if (security.Enabled) {
try {
key = security.KeyPair;
@ -449,7 +357,7 @@ namespace Mono.XSP
} else {
webSource = new XSPWebSource (ipaddr, port);
}
#endif
ApplicationServer server = new ApplicationServer (webSource);
server.Verbose = verbose;
@ -465,15 +373,9 @@ namespace Mono.XSP
if (!master && apps == null && appConfigDir == null && appConfigFile == null)
server.AddApplicationsFromCommandLine ("/:.");
#if MODMONO_SERVER
if (!useTCP) {
Console.WriteLine ("Listening on: {0}", filename);
} else
#endif
{
Console.WriteLine ("Listening on port: {0} {1}", port, security);
Console.WriteLine ("Listening on address: {0}", ip);
}
Console.WriteLine ("Root directory: {0}", rootDir);

Просмотреть файл

@ -1,117 +0,0 @@
//
// Copied from System.Web.Util.WebTrace and changed a few lines
// Under MS runtime, Trace does not work because System.Web disables normal
// tracing.
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
// (C) 2002 Ximian, Inc (http://www.ximian.com)
//
using System;
using System.Collections;
using System.Diagnostics;
namespace Mono.WebServer
{
internal class WebTrace
{
static Stack ctxStack;
static bool trace;
static int indentation; // Number of \t
static WebTrace ()
{
ctxStack = new Stack ();
}
[Conditional("WEBTRACE")]
static public void PushContext (string context)
{
ctxStack.Push (context);
indentation++;
}
[Conditional("WEBTRACE")]
static public void PopContext ()
{
if (ctxStack.Count == 0)
return;
indentation--;
ctxStack.Pop ();
}
static public string Context
{
get {
if (ctxStack.Count == 0)
return String.Empty;
return (string) ctxStack.Peek ();
}
}
static public bool StackTrace
{
get { return trace; }
set { trace = value; }
}
[Conditional("WEBTRACE")]
static public void WriteLine (string msg)
{
Console.WriteLine (Format (msg));
}
[Conditional("WEBTRACE")]
static public void WriteLine (string msg, object arg)
{
Console.WriteLine (Format (String.Format (msg, arg)));
}
[Conditional("WEBTRACE")]
static public void WriteLine (string msg, object arg1, object arg2)
{
Console.WriteLine (Format (String.Format (msg, arg1, arg2)));
}
[Conditional("WEBTRACE")]
static public void WriteLine (string msg, object arg1, object arg2, object arg3)
{
Console.WriteLine (Format (String.Format (msg, arg1, arg2, arg3)));
}
[Conditional("WEBTRACE")]
static public void WriteLine (string msg, params object [] args)
{
Console.WriteLine (Format (String.Format (msg, args)));
}
static string Tabs
{
get {
if (indentation == 0)
return String.Empty;
return new String ('\t', indentation);
}
}
static string Format (string msg)
{
string ctx = Tabs + Context;
if (ctx.Length != 0)
ctx += ": ";
string result = ctx + msg;
if (trace)
result += "\n" + Environment.StackTrace;
return result;
}
}
}