static int Main(string[] args) { ShowVersion(); if (3 < args.Length) { return ShowUsage(); } string strServerIP = string.Empty; if (0 == args.Length) { ShowUsage(); } else { strServerIP = args[0]; } if ("/ca-setup" == strServerIP) { string strIPAddr = string.Empty; if (args.Length > 1) { strIPAddr = args[1]; } if (strIPAddr.Length > 0) { if ('*' == strIPAddr[0]) { if (1 == strIPAddr.Length) { strIPAddr += ":"; strIPAddr += CAHTTPProxy.DEFAULT_PORT.ToString(); } CAHTTPProxy proxy = new CAHTTPProxy(string.Empty); strIPAddr = strIPAddr.Replace("*", proxy._strDnsHostName); } } else { strIPAddr = string.Format("localhost:{0}", CAHTTPProxy.DEFAULT_PORT); } string strMacAddr = string.Empty; if (args.Length > 2) { strMacAddr = args[2]; } string strUDevNum = Console.ReadLine(); string strUDevPin = Console.ReadLine(); if ("*" == strMacAddr) { strMacAddr = Console.ReadLine(); } new CAWebClient.CAAuthData(strUDevNum, strUDevPin, string.Format("http://{0}/ca/", strIPAddr), strMacAddr); } else if ("/m3u-setup" == strServerIP) { TextReader iniReader = Console.In; if (args.Length > 1) { iniReader = new StreamReader(File.Open(args[1], FileMode.Open), Encoding.Default); } string strRndMacAddress = _strMacAddress; CAHTTPProxy proxy = new CAHTTPProxy(string.Empty); string strAppParam; IPAddress mifaceIP = IPAddress.None; if (null != (strAppParam = ConfigurationManager.AppSettings["mifaceIP"])) { mifaceIP = IPAddress.Parse(strAppParam); } proxy.Start(mifaceIP); int ndx = 0x100; while (strRndMacAddress == proxy.MacAddress && ndx-- > 0) { proxy.Loop(80); } CAWebClient client = new CAWebClient(proxy.MacAddress); string xmlCA = client.CAXmlString; TVGMapConfigWriter writerTVG = new TVGMapConfigWriter(iniReader, xmlCA); int iCount = writerTVG.WriteCA(Stream.Null); Log.Message(string.Format("{0} tvg names successfully added to configuration.", iCount)); proxy.Stop(); } else if ("/stream-setup" == strServerIP) { string strclass; if (args.Length > 1) { switch (args[1]) { case StreamProxy.CLASS_NAME: strclass = StreamProxy.Name; break; case MemoryCacheClass16.CLASS_NAME: strclass = StreamProxyEx<MemoryCacheClass16>.Name; break; case MemoryCacheClass32.CLASS_NAME: strclass = StreamProxyEx<MemoryCacheClass32>.Name; break; case MemoryCacheClass64.CLASS_NAME: strclass = StreamProxyEx<MemoryCacheClass64>.Name; break; case MemoryCacheClass128.CLASS_NAME: strclass = StreamProxyEx<MemoryCacheClass128>.Name; break; case MemoryCacheClass256.CLASS_NAME: strclass = StreamProxyEx<MemoryCacheClass256>.Name; break; case MemoryCacheClass512.CLASS_NAME: strclass = StreamProxyEx<MemoryCacheClass512>.Name; break; case MemoryCacheClass1024.CLASS_NAME: strclass = StreamProxyEx<MemoryCacheClass1024>.Name; break; case MemoryCacheClass2048.CLASS_NAME: strclass = StreamProxyEx<MemoryCacheClass2048>.Name; break; default: strclass = string.Empty; break; } } else { strclass = StreamProxyEx<MemoryCacheClass32>.Name; } if (strclass.Length > 0) { new ProxyStreamConfig(strclass); } else { Log.Message(string.Format("Proxy stream {0} not found.", args[1])); } } else if ("/process-setup" == strServerIP) { ProcessTuneSection.PriorityLevel? prPriority = ProcessTuneSection.PriorityLevel.High; if (args.Length > 1) { if (0 == string.Compare(ProcessTuneSection.PriorityLevel.Low.ToString(), args[1], true)) { prPriority = ProcessTuneSection.PriorityLevel.Low; } else if (0 != string.Compare(ProcessTuneSection.PriorityLevel.High.ToString(), args[1], true)) { prPriority = null; } } if (prPriority.HasValue) { new ProcessTuneSection(prPriority.Value); } else { Log.Message(string.Format("Unknown process tune setting {0}, allowed only \"low\" or \"high\".", args[1])); } } else if ("/service-install" == strServerIP) { System.Configuration.Install.TransactedInstaller ti = null; ti = new System.Configuration.Install.TransactedInstaller(); ti.Installers.Add(new ProjectInstaller()); ti.Context = new System.Configuration.Install.InstallContext("", null); string path = Assembly.GetExecutingAssembly().Location; ti.Context.Parameters["assemblypath"] = path; ti.Install(new Hashtable()); } else if ("/service-uninstall" == strServerIP) { System.Configuration.Install.TransactedInstaller ti = null; ti = new System.Configuration.Install.TransactedInstaller(); ti.Installers.Add(new ProjectInstaller()); ti.Context = new System.Configuration.Install.InstallContext("", null); string path = Assembly.GetExecutingAssembly().Location; ti.Context.Parameters["assemblypath"] = path; ti.Uninstall(null); } else if ("/service-run" == strServerIP) { RedirectStd(); System.ServiceProcess.ServiceBase.Run(new CAHTTPProxy(string.Empty)); } else { string strAppParam; IPAddress mifaceIP = IPAddress.None; if (args.Length > 1) { mifaceIP = IPAddress.Parse(args[1]); } else if (null != (strAppParam = ConfigurationManager.AppSettings["mifaceIP"])) { mifaceIP = IPAddress.Parse(strAppParam); } CAHTTPProxy CAHTTPProxy = new CAHTTPProxy(strServerIP); CAHTTPProxy.Start(mifaceIP); while (!Console.KeyAvailable) { CAHTTPProxy.Loop(125); } CAHTTPProxy.Stop(); } return 0; }
private void UpdateCATopics() { string xmlTopics = _CABodyTopics; if (null == xmlTopics) { if (null == CAWebClient.CAAuthData.GetSection()) { using (StreamReader streamXml = File.OpenText("tvgroup.xml")) { _CABodyTopics = streamXml.ReadToEnd(); } } else { CAWebClient client = new CAWebClient(); _CABodyTopics = client.TopicsXmlString; } } }