{}
InetSuperServer::~InetSuperServer() {}
+void
+InetSuperServer::setBindAddress(const char *bindaddress)
+{
+ this->bindaddress = bindaddress;
+}
+
bool
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) {
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_ */
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);
}
int
main(int argc, char** argv, char** envp)
{
+ const char *bindaddress = NULL;
+
HylaFAXServer::setLogFacility(LOG_FAX);
HylaFAXServer::setupLogging("HylaFAX");
HylaFAXServer::setupPermissions();
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
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;