static int Main(string[] args) { string param; if (args.Length == 0) { param = "--all"; } else { param = args[0]; } const string AllPolicy = @"<?xml version='1.0'?> <cross-domain-policy> <allow-access-from domain=""*"" to-ports=""*"" /> </cross-domain-policy>"; const string LocalPolicy = @"<?xml version='1.0'?> <cross-domain-policy> <allow-access-from domain=""*"" to-ports=""4500-4550"" /> </cross-domain-policy>"; string policy = null; switch (param) { case "-h": case "--h": Console.WriteLine("PSUnityServer.exe [--all | --range | --file policy]"); Console.WriteLine("\t--all Allow access on every port)"); Console.WriteLine("\t--range Allow access on portrange 4500-4550)"); Console.WriteLine("See http://docs.unity3d.com/Manual/SecuritySandbox.html for more information about Unity sandbox security."); return 1; case "--all": policy = AllPolicy; break; case "--local": policy = LocalPolicy; break; case "--file": if (args.Length < 2) { Console.WriteLine("Missing policy file name after '--file'."); return 2; } string filename = args[1]; if (!File.Exists(filename)) { Console.WriteLine("Could not find policy file '{0}'.", filename); return 3; } using (StreamReader sr = new StreamReader(filename)) { policy = sr.ReadToEnd(); } break; default: Console.WriteLine("Unknown option '{0}'.", args[0]); return 4; } SocketPolicyServer server = new SocketPolicyServer(policy); int result = server.Start(); if (result != 0) return result; // Start the PSUnity server threadedServer psUnityServer = new threadedServer(); Console.WriteLine("Hit Return to stop the server."); Console.ReadLine(); server.Stop(); return 0; }
static int Main(string[] args) { string param; if (args.Length == 0) { param = "--all"; } else { param = args[0]; } const string AllPolicy = @"<?xml version='1.0'?> <cross-domain-policy> <allow-access-from domain=""*"" to-ports=""*"" /> </cross-domain-policy>"; const string LocalPolicy = @"<?xml version='1.0'?> <cross-domain-policy> <allow-access-from domain=""*"" to-ports=""4500-4550"" /> </cross-domain-policy>"; string policy = null; switch (param) { case "-h": case "--h": Console.WriteLine("PSUnityServer.exe [--all | --range | --file policy]"); Console.WriteLine("\t--all Allow access on every port)"); Console.WriteLine("\t--range Allow access on portrange 4500-4550)"); Console.WriteLine("See http://docs.unity3d.com/Manual/SecuritySandbox.html for more information about Unity sandbox security."); return(1); case "--all": policy = AllPolicy; break; case "--local": policy = LocalPolicy; break; case "--file": if (args.Length < 2) { Console.WriteLine("Missing policy file name after '--file'."); return(2); } string filename = args[1]; if (!File.Exists(filename)) { Console.WriteLine("Could not find policy file '{0}'.", filename); return(3); } using (StreamReader sr = new StreamReader(filename)) { policy = sr.ReadToEnd(); } break; default: Console.WriteLine("Unknown option '{0}'.", args[0]); return(4); } SocketPolicyServer server = new SocketPolicyServer(policy); int result = server.Start(); if (result != 0) { return(result); } // Start the PSUnity server threadedServer psUnityServer = new threadedServer(); Console.WriteLine("Hit Return to stop the server."); Console.ReadLine(); server.Stop(); return(0); }