mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-19 19:29:15 +12:00
Allow HISP Noobs to run even w a web server already running
This commit is contained in:
parent
62e1a7a122
commit
994dc382c8
4 changed files with 260 additions and 247 deletions
Binary file not shown.
|
@ -277,11 +277,11 @@ namespace HTTP
|
||||||
e.AcceptSocket = null;
|
e.AcceptSocket = null;
|
||||||
} while (!ServerSocket.AcceptAsync(e));
|
} while (!ServerSocket.AcceptAsync(e));
|
||||||
}
|
}
|
||||||
public ContentServer()
|
public ContentServer(string ip)
|
||||||
{
|
{
|
||||||
|
|
||||||
WriteDebugOutput("Listening for connections on port 80.");
|
WriteDebugOutput("Listening for connections on port 80.");
|
||||||
IPEndPoint ep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 80);
|
IPEndPoint ep = new IPEndPoint(IPAddress.Parse(ip), 80);
|
||||||
ServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
ServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||||
ServerSocket.Bind(ep);
|
ServerSocket.Bind(ep);
|
||||||
ServerSocket.Listen(0x7fffffff);
|
ServerSocket.Listen(0x7fffffff);
|
||||||
|
|
|
@ -19,7 +19,9 @@ namespace HISP
|
||||||
{
|
{
|
||||||
public static class Program
|
public static class Program
|
||||||
{
|
{
|
||||||
|
public static Random rand = new Random(Guid.NewGuid().GetHashCode());
|
||||||
private static LoadingForm lfrm;
|
private static LoadingForm lfrm;
|
||||||
|
public static string IP;
|
||||||
public static string BaseDir;
|
public static string BaseDir;
|
||||||
private static ContentServer cs;
|
private static ContentServer cs;
|
||||||
private static void addToList(string path)
|
private static void addToList(string path)
|
||||||
|
@ -60,11 +62,21 @@ namespace HISP
|
||||||
lfrm.StartProgress.Increment(1);
|
lfrm.StartProgress.Increment(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static string GetOctlet()
|
||||||
|
{
|
||||||
|
return rand.Next(0, 255).ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GenIP()
|
||||||
|
{
|
||||||
|
return "127" + "." + GetOctlet() + "." + GetOctlet() + "." + GetOctlet();
|
||||||
|
}
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
BaseDir = Path.Combine(Environment.GetEnvironmentVariable("APPDATA"), "HISP", "N00BS");
|
BaseDir = Path.Combine(Environment.GetEnvironmentVariable("APPDATA"), "HISP", "N00BS");
|
||||||
Directory.CreateDirectory(BaseDir);
|
Directory.CreateDirectory(BaseDir);
|
||||||
|
IP = GenIP();
|
||||||
|
|
||||||
lfrm = new LoadingForm();
|
lfrm = new LoadingForm();
|
||||||
Task startForm = new Task(StartLRFrm);
|
Task startForm = new Task(StartLRFrm);
|
||||||
|
@ -74,7 +86,7 @@ namespace HISP
|
||||||
ConfigReader.OpenConfig();
|
ConfigReader.OpenConfig();
|
||||||
ConfigReader.SqlLite = true;
|
ConfigReader.SqlLite = true;
|
||||||
ConfigReader.LogLevel = 0;
|
ConfigReader.LogLevel = 0;
|
||||||
ConfigReader.BindIP = "127.0.0.1";
|
ConfigReader.BindIP = IP;
|
||||||
ConfigReader.CrossDomainPolicyFile = Path.Combine(BaseDir, "CrossDomainPolicy.xml");
|
ConfigReader.CrossDomainPolicyFile = Path.Combine(BaseDir, "CrossDomainPolicy.xml");
|
||||||
ConfigReader.DatabaseName = Path.Combine(BaseDir, "game1.db");
|
ConfigReader.DatabaseName = Path.Combine(BaseDir, "game1.db");
|
||||||
|
|
||||||
|
@ -82,6 +94,7 @@ namespace HISP
|
||||||
Database.OpenDatabase();
|
Database.OpenDatabase();
|
||||||
IncrementProgress();
|
IncrementProgress();
|
||||||
|
|
||||||
|
|
||||||
if (Database.GetUsers().Length <= 0)
|
if (Database.GetUsers().Length <= 0)
|
||||||
{
|
{
|
||||||
RegisterForm rfrm = new RegisterForm();
|
RegisterForm rfrm = new RegisterForm();
|
||||||
|
@ -92,7 +105,7 @@ namespace HISP
|
||||||
|
|
||||||
// Start Web Server
|
// Start Web Server
|
||||||
try{
|
try{
|
||||||
cs = new ContentServer();
|
cs = new ContentServer(IP);
|
||||||
string[] fileList = Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(),"client"), "*", SearchOption.AllDirectories);
|
string[] fileList = Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(),"client"), "*", SearchOption.AllDirectories);
|
||||||
foreach (string file in fileList)
|
foreach (string file in fileList)
|
||||||
addToList(file);
|
addToList(file);
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace HISP
|
||||||
private void SystemTrayIcon_Load(object sender, EventArgs e)
|
private void SystemTrayIcon_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
clientProcess.StartInfo.FileName = "flash.dll";
|
clientProcess.StartInfo.FileName = "flash.dll";
|
||||||
clientProcess.StartInfo.Arguments = "http://127.0.0.1/horseisle.swf?SERVER=127.0.0.1&PORT=12321";
|
clientProcess.StartInfo.Arguments = "http://"+ Program.IP +"/horseisle.swf?SERVER="+ Program.IP +"&PORT=12321";
|
||||||
|
|
||||||
clientProcess.StartInfo.RedirectStandardOutput = true;
|
clientProcess.StartInfo.RedirectStandardOutput = true;
|
||||||
clientProcess.StartInfo.RedirectStandardError = true;
|
clientProcess.StartInfo.RedirectStandardError = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue