зеркало из https://github.com/mono/xsp.git
2007-12-04 Marek Habersack <mhabersack@novell.com>
* src/Mono.WebServer/ApplicationServer.cs: added a new property, Port, to report the actual port ApplicationServer is listening on * src/Mono.WebServer.XSP/main.cs: accept an extra parameter to attach XSP to a random port. The actual port is printed to the console instead of the configured one, as it was done before. svn path=/trunk/xsp/; revision=90627
This commit is contained in:
Родитель
db1c083f78
Коммит
7c7d33e513
|
@ -1,3 +1,12 @@
|
|||
2007-12-04 Marek Habersack <mhabersack@novell.com>
|
||||
|
||||
* src/Mono.WebServer/ApplicationServer.cs: added a new property,
|
||||
Port, to report the actual port ApplicationServer is listening on
|
||||
|
||||
* src/Mono.WebServer.XSP/main.cs: accept an extra parameter to
|
||||
attach XSP to a random port. The actual port is printed to the
|
||||
console instead of the configured one, as it was done before.
|
||||
|
||||
2007-11-21 Marek Habersack <mhabersack@novell.com>
|
||||
|
||||
* Added several index.aspx files to avoid 404 errors on accessing
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace Mono.WebServer.XSP
|
|||
Console.WriteLine ("{0} {1}\n(c) {2}\n{3}",
|
||||
Path.GetFileName (assembly.Location), version, copyright, description);
|
||||
}
|
||||
|
||||
|
||||
static void ShowHelp ()
|
||||
{
|
||||
Console.WriteLine ("XSP server is a sample server that hosts the ASP.NET runtime in a");
|
||||
|
@ -70,6 +70,8 @@ namespace Mono.WebServer.XSP
|
|||
Console.WriteLine (" --port N: n is the tcp port to listen on.");
|
||||
Console.WriteLine (" Default value: 8080");
|
||||
Console.WriteLine (" AppSettings key name: MonoServerPort");
|
||||
Console.WriteLine (" --random-port: listen on a randomly assigned port. The port numer");
|
||||
Console.WriteLine (" will be reported to the caller via a text file.");
|
||||
Console.WriteLine ();
|
||||
Console.WriteLine (" --address addr: addr is the ip address to listen on.");
|
||||
Console.WriteLine (" Default value: 0.0.0.0");
|
||||
|
@ -164,7 +166,8 @@ namespace Mono.WebServer.XSP
|
|||
Port = 1 << 8,
|
||||
Terminate = 1 << 9,
|
||||
Https = 1 << 10,
|
||||
Master = 1 << 11
|
||||
Master = 1 << 11,
|
||||
RandomPort = 1 << 12
|
||||
}
|
||||
|
||||
static void CheckAndSetOptions (string name, Options value, ref Options options)
|
||||
|
@ -184,6 +187,11 @@ namespace Mono.WebServer.XSP
|
|||
Console.WriteLine ("ERROR: --port/--address and --filename are mutually exclusive");
|
||||
Environment.Exit (1);
|
||||
}
|
||||
|
||||
if ((options & Options.Port) != 0 && value == Options.RandomPort) {
|
||||
Console.WriteLine ("ERROR: --port and --random-port are mutually exclusive");
|
||||
Environment.Exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
static AsymmetricAlgorithm GetPrivateKey (X509Certificate certificate, string targetHost)
|
||||
|
@ -225,8 +233,8 @@ namespace Mono.WebServer.XSP
|
|||
object oport;
|
||||
string ip = AppSettings ["MonoServerAddress"];
|
||||
bool master = false;
|
||||
|
||||
if (ip == "" || ip == null)
|
||||
|
||||
if (ip == null || ip.Length == 0)
|
||||
ip = "0.0.0.0";
|
||||
|
||||
oport = AppSettings ["MonoServerPort"];
|
||||
|
@ -276,6 +284,10 @@ namespace Mono.WebServer.XSP
|
|||
CheckAndSetOptions (a, Options.Port, ref options);
|
||||
oport = args [++i];
|
||||
break;
|
||||
case "--random-port":
|
||||
CheckAndSetOptions (a, Options.RandomPort, ref options);
|
||||
oport = 0;
|
||||
break;
|
||||
case "--address":
|
||||
CheckAndSetOptions (a, Options.Address, ref options);
|
||||
ip = args [++i];
|
||||
|
@ -318,6 +330,7 @@ namespace Mono.WebServer.XSP
|
|||
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);
|
||||
|
@ -374,15 +387,17 @@ namespace Mono.WebServer.XSP
|
|||
if (!master && apps == null && appConfigDir == null && appConfigFile == null)
|
||||
server.AddApplicationsFromCommandLine ("/:.");
|
||||
|
||||
Console.WriteLine ("Listening on port: {0} {1}", port, security);
|
||||
Console.WriteLine ("Listening on address: {0}", ip);
|
||||
|
||||
Console.WriteLine ("Listening on address: {0}", ip);
|
||||
Console.WriteLine ("Root directory: {0}", rootDir);
|
||||
|
||||
try {
|
||||
if (server.Start (!nonstop) == false)
|
||||
return 2;
|
||||
|
||||
|
||||
Console.WriteLine ("Listening on port: {0} {1}", server.Port, security);
|
||||
if (port == 0)
|
||||
Console.Error.WriteLine ("Random port: {0}", server.Port);
|
||||
|
||||
if (!nonstop) {
|
||||
Console.WriteLine ("Hit Return to stop the server.");
|
||||
Console.ReadLine ();
|
||||
|
|
|
@ -93,6 +93,23 @@ namespace Mono.WebServer
|
|||
|
||||
// This is much faster than hashtable for typical cases.
|
||||
ArrayList vpathToHost = new ArrayList ();
|
||||
|
||||
public int Port {
|
||||
get {
|
||||
if (listen_socket == null
|
||||
#if NET_2_0
|
||||
|| !listen_socket.IsBound
|
||||
#endif
|
||||
)
|
||||
return -1;
|
||||
|
||||
IPEndPoint iep = listen_socket.LocalEndPoint as IPEndPoint;
|
||||
if (iep == null)
|
||||
return -1;
|
||||
|
||||
return iep.Port;
|
||||
}
|
||||
}
|
||||
|
||||
public ApplicationServer (WebSource source)
|
||||
{
|
||||
|
|
|
@ -58,8 +58,8 @@ namespace Mono.WebServer
|
|||
bool requireClientCert;
|
||||
|
||||
public XSPWebSource(IPAddress address, int port, SecurityProtocolType securityProtocol,
|
||||
X509Certificate cert, PrivateKeySelectionCallback keyCB,
|
||||
bool allowClientCert, bool requireClientCert)
|
||||
X509Certificate cert, PrivateKeySelectionCallback keyCB,
|
||||
bool allowClientCert, bool requireClientCert)
|
||||
{
|
||||
secureConnection = (cert != null && keyCB != null);
|
||||
this.bindAddress = new IPEndPoint (address, port);
|
||||
|
|
Загрузка…
Ссылка в новой задаче