myserver-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myserver-commit] [SCM] GNU MyServer branch, master, updated. 0_9_2-53-g


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. 0_9_2-53-g2e5cce1
Date: Fri, 26 Feb 2010 16:02:57 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU MyServer".

The branch, master has been updated
       via  2e5cce1fc0d883b89d271a4fcc57286d4db68783 (commit)
       via  741b6f7377a1cfaf13cf05fb5db9a40a791628e2 (commit)
       via  0f905335055db36e363c60a424dc66e8a2b3e327 (commit)
       via  addab1aa6a83ea508117aa3b756d9342602a9ec9 (commit)
      from  debb961a39cbf34b3bd382234e0726752efa6fbd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------


commit 2e5cce1fc0d883b89d271a4fcc57286d4db68783
Author: Giuseppe Scrivano <address@hidden>
Date:   Fri Feb 26 17:01:07 2010 +0100

    The `guile_conf' plugin handles virtual hosts.

diff --git a/plugins/src/guile_conf/README b/plugins/src/guile_conf/README
index 7c93035..cc9bf8a 100644
--- a/plugins/src/guile_conf/README
+++ b/plugins/src/guile_conf/README
@@ -18,3 +18,20 @@ contain the children of the node or the value.
     '(((name . "foo") (bar . "baz")
        ("value1" "value2" "value3" "value4"))
       ((name . "foo") "10")))
+
+
+it is possible to use Scheme for virtual hosts definitions too:
+
+having these values in the main configuration file:
+
+  ((name . "server.vhost_handler")
+   "guile")
+  ((name . "server.vhost_location")
+   "virtualhosts.sch")
+
+
+And a new file "virtualhosts.sch" is read, containing for example this
+data:
+
+(define vhosts
+  '(("example" "8080" "web" "system" "http")))
diff --git a/plugins/src/guile_conf/guile_conf.cpp 
b/plugins/src/guile_conf/guile_conf.cpp
index 52befbd..5e5c9e7 100644
--- a/plugins/src/guile_conf/guile_conf.cpp
+++ b/plugins/src/guile_conf/guile_conf.cpp
@@ -122,6 +122,110 @@ GuileConfiguration::readData (list<NodeTree<string>*> 
*hashedDataTrees,
     }
 }
 
+class GuileVhostManagerHandler : public VhostManagerHandler
+{
+  vector<Vhost*> vhosts;
+  ListenThreads* lt;
+  LogManager* lm;
+public:
+  GuileVhostManagerHandler (ListenThreads* lt, LogManager* lm)
+  {
+    this->lm = lm;
+    this->lt = lt;
+  }
+
+  virtual Vhost* getVHost (const char *host, const char *ip, u_short port)
+  {
+    vector<Vhost*>::iterator it;
+
+      try
+        {
+          it = vhosts.begin ();
+
+          /*Do a linear search here. We have to use the first full-matching
+           *virtual host.
+           */
+          for (; it != vhosts.end (); it++)
+            {
+              Vhost* vh = *it;
+              /* Control if the host port is the correct one.  */
+              if (vh->getPort () != port)
+                continue;
+              /* If ip is defined check that it is allowed to connect to the 
host.  */
+              if (ip && !vh->isIPAllowed (ip))
+                continue;
+              /* If host is defined check if it is allowed to connect to the 
host.  */
+              if (host && !vh->isHostAllowed (host))
+                continue;
+              /* We find a valid host.  */
+              /* Add a reference.  */
+              vh->addRef ();
+              return vh;
+            }
+          return 0;
+        }
+      catch (...)
+        {
+          return 0;
+        };
+    }
+
+  virtual Vhost* getVHostByNumber (int n)
+  {
+    return vhosts[n];
+  }
+
+  virtual int load (const char *resource)
+  {
+    gh_eval_file (serverInstance->getData ("server.vhost_location",
+                                           "virtualhosts.sch"));
+    SCM list = gh_lookup ("vhosts");
+
+    while (! gh_null_p (list))
+      {
+        size_t len;
+        SCM v = gh_car (list);
+        Vhost *vh = new Vhost (lm);
+        char *name = gh_scm2newstr (gh_car (v), &len);
+        vh->setName (name);
+        free (name);
+
+        char *portS = gh_scm2newstr (gh_cadr (v), &len);
+        u_short port = atoi (portS);
+        vh->setPort (port);
+        free (portS);
+
+        char *docroot = gh_scm2newstr (gh_caddr (v), &len);
+        vh->setDocumentRoot (docroot);
+        free (docroot);
+
+        char *sysroot = gh_scm2newstr (gh_caddr (gh_cdr (v)), &len);
+        vh->setSystemRoot (sysroot);
+        free (sysroot);
+
+        char *protocol = gh_scm2newstr (gh_caddr (gh_cddr (v)), &len);
+        vh->setProtocolName (protocol);
+        free (protocol);
+
+        list = gh_cdr (list);
+
+
+        /* TODO: read other information!!!  */
+        lt->addListeningThread (port);
+        vhosts.push_back (vh);
+      }
+    return 0;
+  }
+};
+
+
+static VhostManagerHandler* guile_vhost_builder (ListenThreads* lt,
+                                                 LogManager* lm)
+{
+
+  return new GuileVhostManagerHandler (lt, lm);
+}
+
 EXPORTABLE(int) load (void* server)
 {
   /* TODO: This plugin can be loaded only with --plugins.  Fail otherwise.  */
@@ -134,6 +238,10 @@ EXPORTABLE(int) load (void* server)
                            _("GuileConf: cannot find file %s"), 
CONF_FILE_NAME);
       return 1;
     }
+  VhostManager *vhostManager = serverInstance->getVhosts ();
+
+  vhostManager->registerBuilder ("guile", guile_vhost_builder);
+
 
   genMainConf = &genGuileMainConf;
   return 0;



commit 741b6f7377a1cfaf13cf05fb5db9a40a791628e2
Author: Giuseppe Scrivano <address@hidden>
Date:   Fri Feb 26 17:00:32 2010 +0100

    If not specified, use a 102400 bytes threads buffer size.

diff --git a/myserver/src/server/server.cpp b/myserver/src/server/server.cpp
index 5643d20..ac522a7 100644
--- a/myserver/src/server/server.cpp
+++ b/myserver/src/server/server.cpp
@@ -868,7 +868,7 @@ int Server::initialize ()
 
   initLogManager ();
 
-  data = getData ("server.buffer_size");
+  data = getData ("server.buffer_size", "102400");
   if (data)
     buffersize = (atol (data) > 81920) ?  atol (data) :  81920 ;
 



commit 0f905335055db36e363c60a424dc66e8a2b3e327
Author: Giuseppe Scrivano <address@hidden>
Date:   Fri Feb 26 15:23:56 2010 +0100

    The `server.vhost_location' variable overrides virtual hosts conf resource.

diff --git a/myserver/src/server/server.cpp b/myserver/src/server/server.cpp
index 001dd16..5643d20 100644
--- a/myserver/src/server/server.cpp
+++ b/myserver/src/server/server.cpp
@@ -360,8 +360,11 @@ int Server::loadVHostConf ()
 
   vhostManager.setHandler (vhostHandler);
 
+  const char *vhostLocation = getData ("server.vhost_location",
+                                       vhostConfigurationFile.c_str ());
+
   /* Load the virtual hosts configuration.  */
-  if (vhostHandler->load (vhostConfigurationFile.c_str ()))
+  if (vhostHandler->load (vhostLocation))
     {
       log (MYSERVER_LOG_MSG_ERROR,
            _("Error loading the vhost configuration file %s"),



commit addab1aa6a83ea508117aa3b756d9342602a9ec9
Author: Giuseppe Scrivano <address@hidden>
Date:   Fri Feb 26 13:30:24 2010 +0100

    Refactoring, change some signatures.

diff --git a/myserver/include/conf/vhost/vhost_manager.h 
b/myserver/include/conf/vhost/vhost_manager.h
index 15b64d5..e138994 100644
--- a/myserver/include/conf/vhost/vhost_manager.h
+++ b/myserver/include/conf/vhost/vhost_manager.h
@@ -30,7 +30,6 @@ public:
   virtual ~VhostManagerHandler ();
   virtual Vhost* getVHost (const char*, const char*, u_short);
   virtual Vhost* getVHostByNumber (int n);
-  virtual int addVHost (Vhost*);
   virtual int load (const char *resource){return 0;}
 };
 
@@ -49,8 +48,8 @@ public:
   /*! Get a pointer to a vhost.  */
   Vhost* getVHost (const char*,const char*, u_short);
   Vhost* getVHostByNumber (int n);
-  void registerBuilder (string &name, MAKE_HANDLER builder);
-  VhostManagerHandler *buildHandler (string &name, ListenThreads *lt,
+  void registerBuilder (const string &name, MAKE_HANDLER builder);
+  VhostManagerHandler *buildHandler (const string &name, ListenThreads *lt,
                                      LogManager *lm);
 
 protected:
diff --git a/myserver/src/conf/vhost/vhost_manager.cpp 
b/myserver/src/conf/vhost/vhost_manager.cpp
index 6f68445..7c1e82f 100644
--- a/myserver/src/conf/vhost/vhost_manager.cpp
+++ b/myserver/src/conf/vhost/vhost_manager.cpp
@@ -44,11 +44,6 @@ Vhost* VhostManagerHandler::getVHostByNumber (int n)
   return 0;
 }
 
-int VhostManagerHandler::addVHost (Vhost*)
-{
-  return 0;
-}
-
 /*!
  * C'tor.
  */
@@ -101,9 +96,10 @@ Vhost* VhostManager::getVHostByNumber (int n)
  * \param name manager name.
  * \param builder Builder routine.
  */
-void VhostManager::registerBuilder (string &name, MAKE_HANDLER builder)
+void VhostManager::registerBuilder (const string &name, MAKE_HANDLER builder)
 {
-  builders.put (name, builder);
+  string nameStr (name);
+  builders.put (nameStr, builder);
 }
 
 /*!
@@ -112,7 +108,7 @@ void VhostManager::registerBuilder (string &name, 
MAKE_HANDLER builder)
  * \param name handler name.
  * \return an instance of the requested handler type.
  */
-VhostManagerHandler *VhostManager::buildHandler (string &name,
+VhostManagerHandler *VhostManager::buildHandler (const string &name,
                                                  ListenThreads *lt,
                                                  LogManager *lm)
 {

-----------------------------------------------------------------------

Summary of changes:
 myserver/include/conf/vhost/vhost_manager.h |    5 +-
 myserver/src/conf/vhost/vhost_manager.cpp   |   12 +--
 myserver/src/server/server.cpp              |    7 +-
 plugins/src/guile_conf/README               |   17 ++++
 plugins/src/guile_conf/guile_conf.cpp       |  108 +++++++++++++++++++++++++++
 5 files changed, 136 insertions(+), 13 deletions(-)


hooks/post-receive
-- 
GNU MyServer




reply via email to

[Prev in Thread] Current Thread [Next in Thread]