| | @@ -1890,10 +1890,11 @@ |
| 1890 | 1890 | int isUiCmd; /* True if command is "ui", not "server' */ |
| 1891 | 1891 | const char *zNotFound; /* The --notfound option or NULL */ |
| 1892 | 1892 | int flags = 0; /* Server flags */ |
| 1893 | 1893 | const char *zAltBase; /* Argument to the --baseurl option */ |
| 1894 | 1894 | const char *zFileGlob; /* Static content must match this */ |
| 1895 | + char *zIpAddr = 0; /* Bind to this IP address */ |
| 1895 | 1896 | |
| 1896 | 1897 | #if defined(_WIN32) |
| 1897 | 1898 | const char *zStopperFile; /* Name of file used to terminate server */ |
| 1898 | 1899 | zStopperFile = find_option("stopper", 0, 1); |
| 1899 | 1900 | #endif |
| | @@ -1916,10 +1917,16 @@ |
| 1916 | 1917 | flags |= HTTP_SERVER_LOCALHOST; |
| 1917 | 1918 | g.useLocalauth = 1; |
| 1918 | 1919 | } |
| 1919 | 1920 | find_server_repository(isUiCmd && zNotFound==0); |
| 1920 | 1921 | if( zPort ){ |
| 1922 | + int i; |
| 1923 | + for(i=strlen(zPort)-1; i>=0 && zPort[i]!=':'; i--){} |
| 1924 | + if( i>0 ){ |
| 1925 | + zIpAddr = mprintf("%.*s", i, zPort); |
| 1926 | + zPort += i+1; |
| 1927 | + } |
| 1921 | 1928 | iPort = mxPort = atoi(zPort); |
| 1922 | 1929 | }else{ |
| 1923 | 1930 | iPort = db_get_int("http-port", 8080); |
| 1924 | 1931 | mxPort = iPort+100; |
| 1925 | 1932 | } |
| | @@ -1941,14 +1948,18 @@ |
| 1941 | 1948 | } |
| 1942 | 1949 | } |
| 1943 | 1950 | #else |
| 1944 | 1951 | zBrowser = db_get("web-browser", "open"); |
| 1945 | 1952 | #endif |
| 1946 | | - zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser); |
| 1953 | + if( zIpAddr ){ |
| 1954 | + zBrowserCmd = mprintf("%s http://%s:%%d/ &", zBrowser, zIpAddr); |
| 1955 | + }else{ |
| 1956 | + zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser); |
| 1957 | + } |
| 1947 | 1958 | } |
| 1948 | 1959 | db_close(1); |
| 1949 | | - if( cgi_http_server(iPort, mxPort, zBrowserCmd, flags) ){ |
| 1960 | + if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){ |
| 1950 | 1961 | fossil_fatal("unable to listen on TCP socket %d", iPort); |
| 1951 | 1962 | } |
| 1952 | 1963 | g.sslNotAvailable = 1; |
| 1953 | 1964 | g.httpIn = stdin; |
| 1954 | 1965 | g.httpOut = stdout; |
| | @@ -1962,16 +1973,20 @@ |
| 1962 | 1973 | process_one_web_page(zNotFound, glob_create(zFileGlob)); |
| 1963 | 1974 | #else |
| 1964 | 1975 | /* Win32 implementation */ |
| 1965 | 1976 | if( isUiCmd ){ |
| 1966 | 1977 | zBrowser = db_get("web-browser", "start"); |
| 1967 | | - zBrowserCmd = mprintf("%s http://127.0.0.1:%%d/", zBrowser); |
| 1978 | + if( zIpAddr ){ |
| 1979 | + zBrowserCmd = mprintf("%s http://%s:%%d/ &", zBrowser, zIpAddr); |
| 1980 | + }else{ |
| 1981 | + zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser); |
| 1982 | + } |
| 1968 | 1983 | } |
| 1969 | 1984 | db_close(1); |
| 1970 | 1985 | if( win32_http_service(iPort, zNotFound, zFileGlob, flags) ){ |
| 1971 | 1986 | win32_http_server(iPort, mxPort, zBrowserCmd, |
| 1972 | | - zStopperFile, zNotFound, zFileGlob, flags); |
| 1987 | + zStopperFile, zNotFound, zFileGlob, zIpAddr, flags); |
| 1973 | 1988 | } |
| 1974 | 1989 | #endif |
| 1975 | 1990 | } |
| 1976 | 1991 | |
| 1977 | 1992 | /* |
| 1978 | 1993 | |