private void InternalMain() { System.Threading.Thread.CurrentThread.Name = "Root"; System.AppDomain.CurrentDomain.SetPrincipalPolicy(System.Security.Principal.PrincipalPolicy.UnauthenticatedPrincipal); System.AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); { List <string> addrs = new List <string>(); foreach (System.Net.NetworkInformation.NetworkInterface itf in System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()) { foreach (System.Net.NetworkInformation.UnicastIPAddressInformation info in itf.GetIPProperties().UnicastAddresses) { if (!System.Net.IPAddress.IsLoopback(info.Address) && (info.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork || (info.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6 && !info.Address.IsIPv6LinkLocal) ) ) { addrs.Add(info.Address.ToString()); } } } Logger.Info("Local addresses: " + string.Join(",", addrs.ToArray())); } int port = 8081; Root root = new Root(); root.Initialize(); SC.Remoting.ServerEncryptionSinkProvider encrProvider = new SC.Remoting.ServerEncryptionSinkProvider(); SC.Remoting.ServerAuthenticationSinkProvider authProvider = new SC.Remoting.ServerAuthenticationSinkProvider(SC.Security.SecurityManager.Instance); System.Runtime.Remoting.Channels.SoapServerFormatterSinkProvider soapFormatter = new System.Runtime.Remoting.Channels.SoapServerFormatterSinkProvider(); soapFormatter.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; encrProvider.Next = authProvider; authProvider.Next = soapFormatter; System.Runtime.Remoting.Channels.Http.HttpServerChannel channel = null; while (channel == null) { try { channel = new System.Runtime.Remoting.Channels.Http.HttpServerChannel("Access", port, encrProvider); } catch (System.Net.Sockets.SocketException se) { Logger.Error("Waiting 5 seconds for socket on port " + port, se); System.Threading.Thread.Sleep(5000); } } System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel, false); System.Runtime.Remoting.ObjRef Ref = System.Runtime.Remoting.RemotingServices.Marshal(root, "ServerChecker4Root"); //root.AddServer("Blah"); /*Server s = root.GetServer("Blah"); * s.Arguments = "file.txt"; * s.EndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("81.19.219.88"), 27015); * s.Executable = "notepad.exe"; * s.Protocol = System.Net.TransportType.Udp; * s.StartupTimeout = 1000; * //s.Username = "******"; * s.WorkingDirectory = "c:\\"; * s.StopOnExit = true; * s.AcquireOnStart = true; * System.Console.WriteLine(s.ToString()); * * SC.DefaultPlugins.ServerCheckPlugin plugin = s.GetPlugin("ServerCheckPlugin") as SC.DefaultPlugins.ServerCheckPlugin; * plugin.GameType = SC.DefaultPlugins.eGameType.HalfLife; * plugin.Timeout = 1000;*/ if (semaphore != null) { semaphore.WaitOne(); } else { System.Console.ReadKey(); } System.Runtime.Remoting.RemotingServices.Disconnect(root); System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(channel); root.Cleanup(); }
private void InternalMain() { System.Threading.Thread.CurrentThread.Name = "Root"; System.AppDomain.CurrentDomain.SetPrincipalPolicy(System.Security.Principal.PrincipalPolicy.UnauthenticatedPrincipal); System.AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); { List<string> addrs = new List<string>(); foreach (System.Net.NetworkInformation.NetworkInterface itf in System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()) { foreach (System.Net.NetworkInformation.UnicastIPAddressInformation info in itf.GetIPProperties().UnicastAddresses) { if ( !System.Net.IPAddress.IsLoopback(info.Address) && ( info.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork || (info.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6 && !info.Address.IsIPv6LinkLocal) ) ) addrs.Add(info.Address.ToString()); } } Logger.Info("Local addresses: " + string.Join(",", addrs.ToArray())); } int port = 8081; Root root = new Root(); root.Initialize(); SC.Remoting.ServerEncryptionSinkProvider encrProvider = new SC.Remoting.ServerEncryptionSinkProvider(); SC.Remoting.ServerAuthenticationSinkProvider authProvider = new SC.Remoting.ServerAuthenticationSinkProvider(SC.Security.SecurityManager.Instance); System.Runtime.Remoting.Channels.SoapServerFormatterSinkProvider soapFormatter = new System.Runtime.Remoting.Channels.SoapServerFormatterSinkProvider(); soapFormatter.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; encrProvider.Next = authProvider; authProvider.Next = soapFormatter; System.Runtime.Remoting.Channels.Http.HttpServerChannel channel = null; while (channel == null) { try { channel = new System.Runtime.Remoting.Channels.Http.HttpServerChannel("Access", port, encrProvider); } catch (System.Net.Sockets.SocketException se) { Logger.Error("Waiting 5 seconds for socket on port " + port, se); System.Threading.Thread.Sleep(5000); } } System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel, false); System.Runtime.Remoting.ObjRef Ref = System.Runtime.Remoting.RemotingServices.Marshal(root, "ServerChecker4Root"); //root.AddServer("Blah"); /*Server s = root.GetServer("Blah"); s.Arguments = "file.txt"; s.EndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("81.19.219.88"), 27015); s.Executable = "notepad.exe"; s.Protocol = System.Net.TransportType.Udp; s.StartupTimeout = 1000; //s.Username = "******"; s.WorkingDirectory = "c:\\"; s.StopOnExit = true; s.AcquireOnStart = true; System.Console.WriteLine(s.ToString()); SC.DefaultPlugins.ServerCheckPlugin plugin = s.GetPlugin("ServerCheckPlugin") as SC.DefaultPlugins.ServerCheckPlugin; plugin.GameType = SC.DefaultPlugins.eGameType.HalfLife; plugin.Timeout = 1000;*/ if (semaphore != null) semaphore.WaitOne(); else System.Console.ReadKey(); System.Runtime.Remoting.RemotingServices.Disconnect(root); System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(channel); root.Cleanup(); }