structure updated, config-file parser added
structure updated, config-file parser added
diff --git a/centrixd/centrixd.ini b/centrixd/centrixd.ini
new file mode 100644
index 0000000..e0cc02c
--- /dev/null
+++ b/centrixd/centrixd.ini
@@ -0,0 +1,18 @@
+[Centrix]
+Network Name = Test Centrix Network
+Node Name = Main Centrix Server
+
+Mode = Master
+# Mode = Relay
+# Master = centrix.local
+
+[Network]
+Bind To = 0.0.0.0
+
+SSL = True
+Node Key = cert/server.key
+Node Cert = cert/server.cert
+
+# ZeroConf options (uses avahi)
+ZC Announce = True
+ZC Discover = True
diff --git a/centrixd/centrixd.py b/centrixd/centrixd.py
new file mode 100755
index 0000000..80e5d33
--- /dev/null
+++ b/centrixd/centrixd.py
@@ -0,0 +1,2 @@
+#!/usr/bin/python
+import cxcore
\ No newline at end of file
diff --git a/centrixd/cxconfig.py b/centrixd/cxconfig.py
new file mode 100644
index 0000000..a372133
--- /dev/null
+++ b/centrixd/cxconfig.py
@@ -0,0 +1,18 @@
+from configobj import ConfigObj
+from louie import dispatcher
+from cxutils import log
+
+class CXConfig(ConfigObj):
+ def _load(self,infile,configspec):
+ ConfigObj._load(self,infile,configspec)
+ dispatcher.send("reconfig")
+
+ def reload(self):
+ ConfigObj.reload(self)
+ dispatcher.send("reconfig")
+
+try:
+ config
+except NameError:
+ config = CXConfig("./centrixd.ini")
+
diff --git a/centrixd/cxcore.py b/centrixd/cxcore.py
new file mode 100644
index 0000000..5e2768a
--- /dev/null
+++ b/centrixd/cxcore.py
@@ -0,0 +1,31 @@
+# centrixd core
+# author: Sergey Shakshin
+# jid: rigid_mgn@jabber.ru
+
+
+from cxutils import log
+from cxlogger import CXLogger
+from cxconfig import config
+
+from louie import dispatcher
+from time import sleep
+
+
+def on_shutdown():
+ mCycle = False
+
+
+dispatcher.connect(on_shutdown,"shutdown")
+
+logger = CXLogger()
+logger.start()
+
+mCycle = True
+try:
+ while(mCycle):
+ sleep(1)
+
+except KeyboardInterrupt:
+ log("Ctrl-C pressed at console - exiting")
+ print "\nCtrl-C pressed at console - exiting\n"
+ dispatcher.send("shutdown")
diff --git a/centrixd/cxlogger.py b/centrixd/cxlogger.py
new file mode 100644
index 0000000..7a27a1c
--- /dev/null
+++ b/centrixd/cxlogger.py
@@ -0,0 +1,38 @@
+# centrixd logger
+# author: Sergey Shakshin
+# jid: rigid_mgn@jabber.ru
+
+from Queue import Queue, Empty
+from louie import dispatcher
+from threading import Thread
+from syslog import *
+from cxconfig import config
+
+class CXLogger(Thread):
+ __pool = Queue()
+ __active = True
+
+ def on_shutdown(self):
+ self.__active = False
+
+ def on_log(self, message):
+ self.__pool.put(message)
+
+ def on_reconfig(self):
+ syslog("configuration read complete")
+
+ def run(self):
+ dispatcher.connect(self.on_shutdown,"shutdown")
+ dispatcher.connect(self.on_log,"log")
+ dispatcher.connect(self.on_reconfig,"reconfig")
+ openlog("centrixd")
+ while (self.__active):
+ msg='';
+ try:
+ msg=self.__pool.get(block=True, timeout=1)
+ syslog(msg)
+ except Empty:
+ msg=''
+
+ closelog()
+
diff --git a/centrixd/cxutils.py b/centrixd/cxutils.py
new file mode 100644
index 0000000..0528b38
--- /dev/null
+++ b/centrixd/cxutils.py
@@ -0,0 +1,5 @@
+from louie import dispatcher
+
+def log(msg):
+ dispatcher.send("log",message=msg)
+
diff --git a/cxconfig.py b/cxconfig.py
deleted file mode 100644
index e69de29..0000000
diff --git a/cxcore.py b/cxcore.py
deleted file mode 100644
index 79242bc..0000000
--- a/cxcore.py
+++ /dev/null
@@ -1,27 +0,0 @@
-# centrixd core
-# author: Sergey Shakshin
-# jid: rigid_mgn@jabber.ru
-
-
-from cxutils import log
-from cxlogger import CXLogger
-from pydispatch import dispatcher
-from time import sleep
-
-mCycle = True
-def on_shutdown():
- mCycle = False
-
-dispatcher.connect(on_shutdown,"shutdown")
-
-logger = CXLogger()
-logger.start()
-
-try:
- while(mCycle):
- sleep(1)
-
-except KeyboardInterrupt:
- log("Ctrl-C pressed at console - exiting")
- print "\nCtrl-C pressed at console - exiting\n"
- dispatcher.send("shutdown")
diff --git a/cxlogger.py b/cxlogger.py
deleted file mode 100644
index fabe2e6..0000000
--- a/cxlogger.py
+++ /dev/null
@@ -1,33 +0,0 @@
-# centrixd logger
-# author: Sergey Shakshin
-# jid: rigid_mgn@jabber.ru
-
-from Queue import Queue, Empty
-from pydispatch import dispatcher
-from threading import Thread
-from syslog import *
-
-class CXLogger(Thread):
- __pool = Queue()
- __active = True
-
- def on_shutdown(self):
- self.__active = False
-
- def on_log(self, message):
- self.__pool.put(message)
-
- def run(self):
- dispatcher.connect(self.on_shutdown,"shutdown")
- dispatcher.connect(self.on_log,"log")
- openlog("centrixd")
- while (self.__active):
- msg='';
- try:
- msg=self.__pool.get(block=True, timeout=1)
- syslog(msg)
- except Empty:
- msg=''
-
- closelog()
-
diff --git a/cxutils.py b/cxutils.py
deleted file mode 100644
index 84931da..0000000
--- a/cxutils.py
+++ /dev/null
@@ -1,5 +0,0 @@
-from pydispatch import dispatcher
-
-def log(msg):
- dispatcher.send("log",message=msg)
-