]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Bug 474: adds the '-l bindaddr' option to hfaxd
authorLee Howard <faxguy@howardsilvan.com>
Sun, 9 May 2004 04:56:00 +0000 (04:56 +0000)
committerLee Howard <faxguy@howardsilvan.com>
Sun, 9 May 2004 04:56:00 +0000 (04:56 +0000)
hfaxd/InetFaxServer.c++
hfaxd/InetFaxServer.h
hfaxd/main.c++
man/hfaxd.1m

index 96baca9489e9e992838329e9b8a3ae2dbc060a5c..43f3d35b162f80a140dd1954d5349eafe1e8643e 100644 (file)
@@ -46,6 +46,12 @@ InetSuperServer::InetSuperServer(const char* p, int bl)
 {}
 InetSuperServer::~InetSuperServer() {}
 
+void
+InetSuperServer::setBindAddress(const char *bindaddress)
+{
+    this->bindaddress = bindaddress;
+}
+
 bool
 InetSuperServer::startServer(void)
 {
@@ -63,6 +69,10 @@ InetSuperServer::startServer(void)
                sin.sin_port = htons(FAX_DEFPORT);
        } else
            sin.sin_port = sp->s_port;
+
+       if (bindaddress)
+               sin.sin_addr.s_addr = inet_addr(bindaddress);
+
        { int on = 1;
            if (Socket::setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) >= 0) {
                if (Socket::bind(s, &sin, sizeof (sin)) >= 0) {
index d70b876d2822a40aaf6129423a3763cce0b0281a..6772249a932d31ff341b7986d0c41bf071d0d3ac 100644 (file)
@@ -85,11 +85,18 @@ public:
 class InetSuperServer : public SuperServer {
 private:
     fxStr port;
+
+    /*
+     * The address to bind the port on.
+     */
+    const char *bindaddress;
+
 protected:
     bool startServer(void);
     HylaFAXServer* newChild(void);
 public:
     InetSuperServer(const char* port, int backlog = 5);
     ~InetSuperServer();
+    void setBindAddress(const char *bindaddress = NULL);
 };
 #endif /* _InetFaxServer_ */
index d0c34f004fe7c64dec323a256ce4bc2afdc0a359..9dcbba6a7c3cffba49ea3e23595204c7443dceaa 100644 (file)
@@ -174,7 +174,7 @@ detachFromTTY(void)
 static void
 usage(const char* appName)
 {
-    fatal("usage: %s [-o port] [-h port] [-i port] [-u socket] [-q queue-directory]",
+    fatal("usage: %s [-o port] [-h port] [-l bindaddress] [-i port] [-u socket] [-q queue-directory]",
        appName);
 }
 
@@ -193,6 +193,8 @@ newInetServer(void)
 int
 main(int argc, char** argv, char** envp)
 {
+    const char *bindaddress = NULL;
+
     HylaFAXServer::setLogFacility(LOG_FAX);
     HylaFAXServer::setupLogging("HylaFAX");
     HylaFAXServer::setupPermissions();
@@ -204,7 +206,7 @@ main(int argc, char** argv, char** envp)
     optind = 1;
     opterr = 0;
     int c;
-    const char* opts = "dHh:Ii:Oo:q:Ss:u:";
+    const char* opts = "dHh:Ii:Oo:q:Ss:u:l:";
     /*
      * Deduce the spooling directory and whether or not to
      * detach the process from the controlling tty.  The
@@ -277,7 +279,16 @@ main(int argc, char** argv, char** envp)
            fatal("No HTTP suport");
            /*NOTREACHED*/
 #endif
-       case 'i': handlers.append(new InetSuperServer(optarg)); break;
+       case 'l':
+           bindaddress = strdup(optarg); break;
+       case 'i': {
+               InetSuperServer* iss;
+               iss = new InetSuperServer(optarg);
+               handlers.append(iss);
+               if ((iss!=NULL) && (bindaddress!=NULL))
+                   iss->setBindAddress(bindaddress);
+               }
+               break;
        case 'I': newInetServer(); break;
 #ifdef SNPP_SUPPORT
        case 's': handlers.append(new SNPPSuperServer(optarg)); break;
index 1eeadedc3799ca1ecf526cdbe245d3e7e012aad8..a3e9b63b64fa8c96083027c658b53eac3ed12ea6 100644 (file)
@@ -44,6 +44,9 @@ hfaxd \- \*(Fx client-server protocol server
 ] [
 .B \-O
 ] [
+.B \-l
+.I bindaddress
+] [
 .B \-i
 .I port
 ] [
@@ -796,6 +799,14 @@ is started up from the
 .IR inetd (${MANNUM1_8})
 process.
 .TP 10
+.BI \-l " bindaddress"
+Bind to the specified 
+.I bindaddress
+the tcp port. Please note that this argument need to be specified before
+the 
+.BI \-i
+otherwise it will be ignored.
+.TP 10
 .BI \-i " port"
 Listen on the specified 
 .I port