Exemplo n.º 1
0
        public static void Stop()
        {
            Logger.Log.Info("Stopping WebServiceBackEnd");
            if (appServer != null)
            {
                appServer.Stop();
                appServer = null;
            }

            Process pr = new Process();

            pr.StartInfo.UseShellExecute = true;
            pr.StartInfo.FileName        = "rm";
            pr.StartInfo.Arguments       = " -rf  " + PathFinder.StorageDir + "/img/*";

            try {
                pr.Start();
                pr.WaitForExit();
                pr.Close();
                pr.Dispose();
            }
            catch (Exception e) { }

            WebBackEnd.cleanup();
            instance = null;
        }
Exemplo n.º 2
0
        public static void cleanup()
        {
            if (tch1 != null)
            {
                tch1.StopListening(null);
                ChannelServices.UnregisterChannel(tch1);
                tch1 = null;
            }

            instance = null;
        }
Exemplo n.º 3
0
        public static void init()
        {
            if (instance == null)
            {
                instance = new WebBackEnd();

                if (tch1 == null)
                {
                    tch1 = new TcpChannel(8347);

                    //Register TCP Channel Listener
                    ChannelServices.RegisterChannel(tch1);

                    WellKnownServiceTypeEntry WKSTE =
                        new WellKnownServiceTypeEntry(typeof(WebBackEnd),
                                                      "WebBackEnd.rem", WellKnownObjectMode.Singleton);
                    RemotingConfiguration.ApplicationName = "beagled";
                    RemotingConfiguration.RegisterWellKnownServiceType(WKSTE);
                }
            }
        }
Exemplo n.º 4
0
        public static void Start()
        {
            if (!web_start)
            {
                Logger.Log.Warn("Beagle running with WebServices DISABLED\n");
                return;
            }

            try {
                IPHostEntry hostInfo = Dns.GetHostByName(Dns.GetHostName());
                //Fully qualified DNS name of host:
                hostname = hostInfo.HostName;
                Logger.Log.Info("This Computer Hostname: " + hostname);
            }
            catch (Exception ex)
            {
                Logger.Log.Error("Caught exception {0} in Dns.GetHostName: ", ex.Message);
                Logger.Log.Error("Resetting hostname to \"localhost\"");
                hostname = "localhost";
            }

            if (!web_global)
            {
                web_global = Conf.WebServices.AllowGlobalAccess;
            }

            //start web-access server first
            Logger.Log.Debug("Starting WebBackEnd");
            WebBackEnd.init();

            //Next start web-service server
            Logger.Log.Info("Starting WebServiceBackEnd");
            WebServiceBackEnd.init();

            Logger.Log.Debug("Global WebServicesAccess {0}", web_global ? "Enabled" : "Disabled");

            xsp_param[1] = web_port;
            xsp_param[3] = web_rootDir;

            //Check if web_rootDir_changed:
            if (String.Compare(web_rootDir, DEFAULT_XSP_ROOT, true) != 0)
            {
                //Assuming "/beagle" exists as an explicit sub-folder under user specified xsp root directory:
                xsp_param[5] = "/:" + web_rootDir + ",/beagle:" + web_rootDir + "/beagle";
            }

            try {
                // Mapping /beagle/local to ExternalStringsHack.Prefix
                if (Directory.Exists(ExternalStringsHack.Prefix))
                {
                    xsp_param[5] += ",/beagle/local:" + ExternalStringsHack.Prefix;
                }

                //Mapping /beagle/gnome to ExternalStringsHack.GnomePrefix
                if (Directory.Exists(ExternalStringsHack.GnomePrefix))
                {
                    xsp_param[5] += ",/beagle/gnome:" + ExternalStringsHack.GnomePrefix;
                }

                //Mapping /beagle/kde3 to ExternalStringsHack.KdePrefix
                if (Directory.Exists(ExternalStringsHack.KdePrefix))
                {
                    xsp_param[5] += ",/beagle/kde3:" + ExternalStringsHack.KdePrefix;
                }

                string imgDir = PathFinder.StorageDir + "/img";
                if (!Directory.Exists(imgDir))
                {
                    Process pr = new Process();
                    pr.StartInfo.UseShellExecute = true;
                    pr.StartInfo.FileName        = "mkdir";
                    pr.StartInfo.Arguments       = imgDir;

                    try {
                        pr.Start();
                        pr.WaitForExit();
                        pr.Close();
                        pr.Dispose();
                    }
                    catch (Exception e) {
                        Logger.Log.Warn("Error creating ~/.beagle/img folder");
                    }
                }
                xsp_param[5] += ",/beagle/img:" + imgDir;

                //if (!hostname.Equals("localhost")) {

                reserved_suffixes = new string[] { "beagle", "local", "gnome", "kde3" };
                BeagleHttpUriBase = "http://" + hostname + ":" + xsp_param[1] + "/beagle/";

                AccessFilter = new ExternalAccessFilter(BeagleHttpUriBase, reserved_suffixes);

                ArrayList matchers = AccessFilter.Matchers;
                foreach (SimpleMatcher sm in matchers)
                {
                    xsp_param[5] += ",/beagle/" + sm.Rewrite + ":" + sm.Match;
                }

                AccessFilter.Initialize();
                //}
            }
            catch (Exception e)
            {
                xsp_param[5] = DEFAULT_APP_MAPPINGS;
            }

            Logger.Log.Debug("Starting Internal Web Server");

            int retVal = 0;

            try {
                //Start beagled internal web server (BeagleXsp)
                retVal = Mono.ASPNET.Server.initXSP(xsp_param, out appServer);
            }
            catch (ArgumentException e) {
                //Retry with default application mappings:
                xsp_param[5] = DEFAULT_APP_MAPPINGS;
                retVal       = Mono.ASPNET.Server.initXSP(xsp_param, out appServer);
            }
            catch (System.Net.Sockets.SocketException) {
                Logger.Log.Error("Error starting Internal Web Server (retVal={0})", retVal);
                Logger.Log.Error("There is probably another beagled instance running.  "
                                 + "Use --replace to replace the running service");
            }

            if (retVal == 0)
            {
                Logger.Log.Debug("BeagleXSP Applications list: " + xsp_param[5]);
            }
        }
Exemplo n.º 5
0
	protected void Search_Click(object o, EventArgs e) {
		
		//if (IsPostBack && Session.IsNewSession) 
		if (Session["InitialReqUrl"] == null) {
			Output.Text = enableSessionMsg;
			Back.Visible = Forward.Visible = GlobalSearchCheckBox.Visible = false;
			return;
		} 

		if (SearchBox.Text.Trim() == "") {		
			Output.Text = HeaderMsg + NO_RESULTS;
			Back.Visible = Forward.Visible = false;
			
			Session["SearchString"] = SearchBox.Text;
			Session["ResultsOnDisplay"] = Output.Text;
			Session["GlobalCheckBox"] = GlobalSearchCheckBox.Checked;			
			return;
		}
		
		string searchSrc = sourceList.SelectedItem.Value;
		if (searchSrc.Equals("Anywhere"))
			searchSrc = null;
	
		remoteChannel.Register(); 
		
		WebBackEnd remoteObj = (WebBackEnd) Session["RemObj"];
		if (remoteObj == null) {
			 remoteObj = new WebBackEnd();
		}
			 
		if ( (remoteObj == null) || !(remoteObj.allowGlobalAccess || isLocalReq())) {

			Output.Text = localReqOnlyMsg;
			Back.Visible = Forward.Visible = GlobalSearchCheckBox.Visible = false;
			sourceList.Enabled = SearchBox.Enabled = Search.Enabled = false;
			return;
		} 
		
		if (!isLocalReq() && (((string)TitleLabel.Text).IndexOf("host") < 0))
			 	TitleLabel.Text += "  from host: " + remoteObj.HostName;

		//Show check-box only if we have one or more NetworkedBeagle nodes configured:
		bool showGlobalCheckBox = (remoteObj.NetworkBeagleActive) && (searchSrc == null);

		//Setup arguments for WebBackEnd:doQuery()
		webArgs wargs = new webArgs();
		wargs.sessId = Session.SessionID;
		wargs.searchString = SearchBox.Text;
		wargs.searchSource = searchSrc;
		wargs.isLocalReq = isLocalReq();
		wargs.globalSearch = showGlobalCheckBox?GlobalSearchCheckBox.Checked:false;
		
		string response = "";		
		try {
			response = remoteObj.doQuery(wargs);		
		}
		catch (Exception ex) 
		{
			response = "Exception in WebBackEnd:doQuery method\n";
			Console.WriteLine("WebFrontEnd: Caught Exception in WebBackEnd:doQuery()\n" + ex.Message);			
		}	
				
		if (response.StartsWith(NO_RESULTS))  {
				Output.Text = HeaderMsg + response;
				Back.Visible = Forward.Visible = false;
		}
		else {
				Output.Text = HeaderMsg + convertUrls(response);
				Back.Enabled = remoteObj.canBack(Session.SessionID);
				Forward.Enabled = remoteObj.canForward(Session.SessionID);
		}
		
		GlobalSearchCheckBox.Visible = showGlobalCheckBox;
		Session["GlobalCheckBox"] = GlobalSearchCheckBox.Checked;			
		Session["RemObj"] = remoteObj;
		Session["ResultsOnDisplay"] = Output.Text;
		Session["SearchString"] = SearchBox.Text;
		Session["Source"] = searchSrc;		
	}
Exemplo n.º 6
0
		public static void init() 
		{		   
		   if (instance == null) {
			  instance = new WebBackEnd();

			  if (tch1 == null) {
			  	
			  	tch1 = new TcpChannel(8347);

			  	//Register TCP Channel Listener
		  	  	ChannelServices.RegisterChannel(tch1);	

			  	WellKnownServiceTypeEntry WKSTE = 
			  		new WellKnownServiceTypeEntry(typeof(WebBackEnd),
				 		"WebBackEnd.rem", WellKnownObjectMode.Singleton);
			  	RemotingConfiguration.ApplicationName="beagled";
			  	RemotingConfiguration.RegisterWellKnownServiceType(WKSTE);
			  }
		   }
		}
Exemplo n.º 7
0
		public static void cleanup() 
		{
			if (tch1 != null) {
				tch1.StopListening(null);
				ChannelServices.UnregisterChannel(tch1);
				tch1 = null;
			}

			instance = null;
		}