]> git.llucax.com Git - software/pymin.git/commitdiff
Move ip_forward activation to a function.
authorLeandro Lucarella <llucax@gmail.com>
Thu, 19 Jun 2008 01:39:29 +0000 (22:39 -0300)
committerLeandro Lucarella <llucax@gmail.com>
Thu, 19 Jun 2008 03:32:03 +0000 (00:32 -0300)
This has to go away, but for now put it in a function and evaluate it just
before we start serving requests.

pymind

diff --git a/pymind b/pymind
index 29d296bd2f5ec06fd862c31457e2eb2014aa5603..7922afa148a38fc894ff0f7ec84238b154a678a3 100755 (executable)
--- a/pymind
+++ b/pymind
@@ -70,13 +70,14 @@ options.init('pymind', 'Pymin daemon global options', [
 ])
 
 
-# FIXME
-try:
-    f = file("/proc/sys/net/ipv4/ip_forward","w")
-    f.write("1")
-    f.close()
-except (IOError, OSError), e:
-    log.warning("Can't set ip_forward: %s", e)
+# FIXME: move to IpHandler or someplace else
+def activate_ip_forward():
+    try:
+        f = file("/proc/sys/net/ipv4/ip_forward","w")
+        f.write("1")
+        f.close()
+    except (IOError, OSError), e:
+        log.warning("Can't set ip_forward: %s", e)
 
 
 def get_config(paths, version, desc, add_options, defaults):
@@ -131,6 +132,7 @@ def main():
                                 'Router services administration daemon',
                                 services.add_config_options, config_defaults)
     root_handler = build_root(config, args, services.services)
+    activate_ip_forward()
     PyminDaemon(root_handler, (config.bind_addr, config.bind_port)).run()
 
 if __name__ == '__main__':