[FIX] Support for ftp_server_host for setting the FTP interface for DMS server,
authorJoël Grand-Guillaume (modified by ~odo) <>
Tue, 13 Apr 2010 21:50:03 +0000 (23:50 +0200)
committerOlivier Dony <odo@openerp.com>
Tue, 13 Apr 2010 21:50:03 +0000 (23:50 +0200)
      to override auto-detection, e.g. when auto-detection selects the wrong
      one or fails.
      Kept 0.0.0.0 as the default for backwards compatibility in 5.0, changed to
      the more conservative 127.0.0.1 for 6.0 (trunk).

lp bug: https://launchpad.net/bugs/515507 fixed

bzr revid: odo@openerp.com-20100413215003-czi6jegplo9clv1g

addons/document/ftpserver/__init__.py

index 7a68a7e..47c4056 100644 (file)
@@ -27,7 +27,9 @@ import abstracted_fs
 import netsvc
 
 from tools import config
-HOST = ''
+
+DEFAULT_HOST = '0.0.0.0' # all interfaces
+HOST = config.get('ftp_server_host')
 PORT = int(config.get('ftp_server_port', 8021))
 PASSIVE_PORTS = None
 pps = config.get('ftp_server_passive_ports', '').split(':')
@@ -70,7 +72,7 @@ class ftp_server(threading.Thread):
         try:
             ip_addr = _detect_ip_addr()
         except:
-            ip_addr = ''
+            ip_addr = DEFAULT_HOST
         return ip_addr
 
 
@@ -87,8 +89,7 @@ class ftp_server(threading.Thread):
         ftpserver.logline = lambda msg: None
         ftpserver.logerror = lambda msg: self.log(netsvc.LOG_ERROR, msg)
 
-        HOST = self.detect_ip_addr()
-        address = (HOST, PORT)
+        address = (HOST or self.detect_ip_addr(), PORT)
         ftpd = ftpserver.FTPServer(address, ftpserver.FTPHandler)
         ftpd.serve_forever()
 ds = ftp_server()