/// <summary> /// Each HTTP processor object handles one client. If Keep-Alive is enabled then this /// object will be reused for subsequent requests until the client breaks keep-alive. /// This usually happens when it times out. Because this could easily lead to a DoS /// attack, we keep track of the number of open processors and only allow 100 to be /// persistent active at any one time. Additionally, we do not allow more than 500 /// outstanding requests. /// </summary> /// <param name="docRoot">Root-Directory of the HTTP Server</param> /// <param name="s">the Socket to work with</param> /// <param name="webserver">the "master" HttpServer Object of this Client</param> public HttpProcessor(string docRoot, Socket s, HttpServer webserver) { this.s = s; docRootFile = new FileInfo(docRoot); headers = new Hashtable(); HTTPServer = webserver; }
// TODO: redo the Variable names... /// <summary> /// Creates the Settings Processor /// </summary> /// <param name="RFilename">The Recording-Settings-Path+Filename</param> /// <param name="DRFilename">The doneRecording-Settings-Path+Filename</param> /// <param name="CFilename">The Categories-Settings-Path+Filename</param> /// <param name="CMFilename">The ChannelNameMapping-Settings-Path+Filename</param> /// <param name="CPFilename">The ChannelPictureMapping-Settings-Path+Filename</param> /// <param name="SeFilename">The Misc-Settings-Path+Filename</param> /// <param name="CMAFilename">The ChannelMulticastAdressFilename+Filename</param> /// <param name="vcrScheduler">object of the vcrScheduler</param> /// <param name="webserver">object of the webserver</param> public SettingsProcessor(String RFilename, String DRFilename,String CFilename, String SeFilename, String AuSFilename, String StationAndChannels, VCRScheduler vcrScheduler, HttpServer webserver) { RecordingsFilename = RFilename; DoneRecordingsFilename = DRFilename; CategoriesFilename = CFilename; MiscSettingsFilename = SeFilename; StationIDFilename = StationAndChannels; internal_http_server = webserver; AuthentificationSettingsFilename = AuSFilename; internal_vcr_scheduler = vcrScheduler; }
public multicastedEPGProcessor(HttpServer webserver) { everything_is_setup = false; done = false; CurrentlyRunningEvents = new List<EPG_Event_Entry>(); webserver.EPGProcessor = this; }
/// <summary> /// Constructor...sets some options... /// </summary> /// <param name="isVCR"></param> public VCRandStreaming(bool isVCR, Recording recording_info, HttpServer iHTTP) { myID = Guid.NewGuid(); internal_HTTP_Server_Object = iHTTP; done = false; internal_is_VCR = isVCR; internal_recording_info = recording_info; if (isVCR) { // OLD: recorder_stream = File.Create(internal_recording_info.Recording_Filename); recorder_stream = new FileStream(internal_recording_info.Recording_Filename, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite); binary_recorder_writer = new BinaryWriter(recorder_stream); // TODO: make the file cache size configurable cache_size = 400 * 1316; cache = new byte[cache_size]; // TODO: sometimes the cache size can be too big so the harddisk cannot write all the data within a tolerable time, we should check that and increase/decrease the cache size accordingly cache_length = 0; // it's brand new!! // set timeout #region Create the currently-recording playlist file for the XBMC player using (StreamWriter sw = new StreamWriter(XBMCPlaylistFilesHelper.generateCurrentlyRecordingPlaylistFilename(internal_recording_info))) { // Add some text to the file. if (internal_HTTP_Server_Object.Settings.HTTP_Port == 80) sw.Write(internal_HTTP_Server_Object.Settings.HTTP_URL + "/" + internal_recording_info.Recording_Filename); else sw.Write(internal_HTTP_Server_Object.Settings.HTTP_URL + ":" + internal_HTTP_Server_Object.Settings.HTTP_Port.ToString() + "/" + internal_recording_info.Recording_Filename); ConsoleOutputLogger.WriteLine("Created CurrentlyRecording Playlist File..."); } #endregion } }
static void Main(String[] args) { #region ConsoleOutputLogger ConsoleOutputLogger.verbose = true; ConsoleOutputLogger.writeLogfile = true; #endregion #region Logo ConsoleOutputLogger.WriteLine("Yet Another Proxy Server: UDP Multicast to TCP Unicast Proxy "+System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()); ConsoleOutputLogger.WriteLine("(C) 2006-2008 Stephanie Götz, Daniel Kirstenpfad and the APS Team - http://www.technology-ninja.com"); //ConsoleOutputLogger.verbose = false; #endregion #region Data HttpServer httpServer; Cassini.Server CassiniServer; VCRScheduler vcrScheduler; XBMCSyncProcessor SyncProcessor; int port = 80; string docRoot = "."; httpServer = new HttpServer(docRoot, port); vcrScheduler = new VCRScheduler(httpServer); vcrScheduler.Settings = new Settings(); httpServer.Settings = vcrScheduler.Settings; SyncProcessor = new XBMCSyncProcessor(httpServer); #endregion #region Load the Settings... SettingsProcessor Configuration = new SettingsProcessor(".\\settings\\YAPS.Recordings.dat", ".\\settings\\YAPS.DoneRecordings.dat", ".\\settings\\YAPS.Categories.dat", ".\\settings\\YAPS.Settings.dat", ".\\settings\\YAPS.Authentification.dat", ".\\settings\\YAPS.StationIDs.dat", vcrScheduler, httpServer); Configuration.LoadSettingsXML(); // tell the processors that we exist... vcrScheduler.Configuration = Configuration; httpServer.Configuration = Configuration; //Configuration.LoadSettingsXML(); Configuration.SaveSettings(); #endregion #region channelmappinginit /* ChannelAndStationMapper.Add(5, "ZDFtheaterkanal", "/images/channels/zdftheater.png", 10, "239.255.2.5", "505"); ChannelAndStationMapper.Add(6, "3Sat", "/images/channels/3sat.png", 28007, "239.255.2.6", "506"); ChannelAndStationMapper.Add(39, "KIKA", "/images/channels/kika.png", 28008, "239.255.2.39", "5039"); ChannelAndStationMapper.Add(10, "ZDF", "/images/channels/zdf.png", 28006, "239.255.2.10", "5010"); ChannelAndStationMapper.Add(11, "ZDFdokukanal", "/images/channels/zdfdoku.png", 28014, "239.255.2.11", "5011"); ChannelAndStationMapper.Add(11, "ZDFinfokanal", "/images/channels/zdfinfo.png", 28011, "239.255.2.12", "5012"); ChannelAndStationMapper.Add(13, "Sat1", "/images/channels/sat1.png", 46, "239.255.2.13", "5013"); ChannelAndStationMapper.Add(14, "ProSieben", "/images/channels/pro7.png", 898, "239.255.2.14", "5014"); ChannelAndStationMapper.Add(15, "Kabel1", "/images/channels/kabel1.png", 899, "239.255.2.15", "5015"); ChannelAndStationMapper.Add(16, "DSF", "/images/channels/dsf.png", 900, "239.255.2.16", "5016"); ChannelAndStationMapper.Add(17, "N24", "/images/channels/n24.png", 47, "239.255.2.17", "5017"); ChannelAndStationMapper.Add(18, "RTL", "/images/channels/rtl.png", 12003, "239.255.2.18", "5018"); ChannelAndStationMapper.Add(19, "RTL2", "/images/channels/rtl2.png", 12020, "239.255.2.19", "5019"); ChannelAndStationMapper.Add(20, "VOX", "/images/channels/vox.png", 12060, "239.255.2.20", "5020"); ChannelAndStationMapper.Add(21, "ntv", "/images/channels/ntv.png", 12090, "239.255.2.21", "5021"); ChannelAndStationMapper.Add(22, "SuperRTL", "/images/channels/superrtl.png", 12040, "239.255.2.22", "5022"); ChannelAndStationMapper.Add(23, "ARD", "/images/channels/ard.png", 28106, "239.255.2.23", "5023"); ChannelAndStationMapper.Add(24, "arte", "/images/channels/arte.png", 1, "239.255.2.24", "5024"); ChannelAndStationMapper.Add(25, "BR", "/images/channels/br.png", 2, "239.255.2.25", "5025"); ChannelAndStationMapper.Add(26, "BR-Alpha", "/images/channels/br-alpha.png", 28112, "239.255.2.26", "5026"); ChannelAndStationMapper.Add(27, "HR", "/images/channels/hr.png", 28108, "239.255.2.27", "5027"); ChannelAndStationMapper.Add(28, "Phoenix", "/images/channels/phoenix.png", 28114, "239.255.2.28", "5028"); ChannelAndStationMapper.Add(29, "SWR BW", "/images/channels/swr.png", 3, "239.255.2.29", "5029"); ChannelAndStationMapper.Add(30, "WDR", "/images/channels/wdr.png", 28395, "239.255.2.30", "5030"); ChannelAndStationMapper.Add(31, "Tele5", "/images/channels/tele5.png", 4, "239.255.2.31", "5031"); Configuration.SaveSettings();*/ #endregion #region Authentification //AuthentificationUser aUser; //AuthentificationEntry aEntry; // pre configured allowed clients /* aUser = HTTPAuthProcessor.AddUser("BtK"); aEntry = new AuthentificationEntry(); aEntry.accessingIP = "127.0.0.1"; aEntry.isAdministrator = true; aUser.AuthEntry.Add(aEntry); */ #endregion #region Starting up... #region internal HTTP Server ConsoleOutputLogger.WriteLine("Starting internal HTTP Server..."); Thread http_server_thread = new Thread(new ThreadStart(httpServer.listen)); http_server_thread.Start(); #endregion #region Cassini HTTP Server ConsoleOutputLogger.WriteLine("Starting Cassini HTTP Server..."); CassiniServer = new Cassini.Server(httpServer.Settings.Cassini_Port, httpServer.Settings.Cassini_VirtualDirectory, httpServer.Settings.Cassini_Root_Directory); CassiniServer.Start(); #endregion #region WCF Services if (httpServer.Settings.WCFService_Enabled) { ServiceHost YAPSServiceHost = new ServiceHost(typeof(YAPS.WCF.YAPSService), new Uri[1] { new Uri(httpServer.Settings.WCFServiceURL) }); ConsoleOutputLogger.WriteLine("Starting YAPS WCF Service ..."); WSHttpBinding binding = new WSHttpBinding(); YAPSServiceHost.AddServiceEndpoint(typeof(YAPS.WCF.IYAPSService), binding, httpServer.Settings.WCFServiceURL); ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); smb.HttpGetEnabled = true; YAPSServiceHost.Description.Behaviors.Add(smb); YAPSServiceHost.AddServiceEndpoint(typeof(IMetadataExchange), binding, httpServer.Settings.WCFServiceURL+"/mex"); YAPSServiceHost.Open(); } #endregion #region XBMC Sync ConsoleOutputLogger.WriteLine("Starting XBMC Sync Processor..."); Thread xbmc_syncprocessor_thread = new Thread(new ThreadStart(SyncProcessor.SyncProcessor)); xbmc_syncprocessor_thread.Start(); #endregion #region VCR ConsoleOutputLogger.WriteLine("Starting VCR Scheduler..."); Thread vcr_scheduler_thread = new Thread(new ThreadStart(vcrScheduler.RecordingScheduler)); vcr_scheduler_thread.Start(); #endregion #region EPG multicastedEPGProcessor EPG_Processor = new multicastedEPGProcessor(httpServer); EPG_Processor.MulticastEPGSources = httpServer.Settings.MulticastEPGSources; EPG_Processor.setupDone(); Thread epg_processor_thread = new Thread(new ThreadStart(EPG_Processor.EPGProcessor)); epg_processor_thread.Start(); #endregion #region SAP / SDP if (httpServer.Settings.SAP_Enabled) { SAPProcessor sapProcessor = new SAPProcessor(httpServer.Settings.SAP_IPAdress, httpServer.Settings.SAP_Port); Thread sap_processor_thread = new Thread(new ThreadStart(sapProcessor.SAPProcessorThread)); sap_processor_thread.Start(); } #endregion #endregion }
/// <summary> /// Constructor of the Templace Processor /// </summary> /// <param name="vcrscheduler">the VCRScheduler...so we can get the </param> public TemplateProcessor(VCRScheduler vcrscheduler, HttpServer httpserver) { internal_vcrscheduler = vcrscheduler; internal_httpserver = httpserver; }