Fossil

Check-in [f8f2c8d2]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Improved parsing of the --port option on the "fossil server" command.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:f8f2c8d2595020ea5d860f3271f37a75cd4346d652bb30c48c9037e8a5da79d5
User & Date: drh 2018-01-05 13:37:00
Context
2018-01-05
14:34
Improved support for both IPv4 and IPv6 on "fossil server" on Windows. Patches from Olivier Mascia. check-in: e506ebb7 user: drh tags: trunk
13:37
Improved parsing of the --port option on the "fossil server" command. check-in: f8f2c8d2 user: drh tags: trunk
2018-01-03
23:55
In the "fossil ui" and "fossil server" commands on Windows, use IPv6 for loopback. check-in: 696e1481 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/main.c.

  2492   2492       if( isUiCmd && g.localOpen ){
  2493   2493         zInitPage = "timeline?c=current";
  2494   2494       }else{
  2495   2495         zInitPage = "";
  2496   2496       }
  2497   2497     }
  2498   2498     if( zPort ){
  2499         -    int i;
  2500         -    for(i=strlen(zPort)-1; i>=0 && zPort[i]!=':'; i--){}
  2501         -    if( i>0 ){
  2502         -      zIpAddr = mprintf("%.*s", i, zPort);
  2503         -      zPort += i+1;
         2499  +    if( strchr(zPort,'.') || zPort[0]=='[' ){
         2500  +      int i;
         2501  +      for(i=strlen(zPort)-1; i>=0 && zPort[i]!=':'; i--){}
         2502  +      if( i>0 ){
         2503  +        if( zPort[0]=='[' && zPort[i-1]==']' ){
         2504  +          zIpAddr = mprintf("%.*s", i-2, zPort+1);
         2505  +        }else{
         2506  +          zIpAddr = mprintf("%.*s", i, zPort);
         2507  +        }
         2508  +        zPort += i+1;
         2509  +      }
  2504   2510       }
  2505   2511       iPort = mxPort = atoi(zPort);
  2506   2512     }else{
  2507   2513       iPort = db_get_int("http-port", 8080);
  2508   2514       mxPort = iPort+100;
  2509   2515     }
  2510   2516   #if !defined(_WIN32)
................................................................................
  2523   2529             break;
  2524   2530           }
  2525   2531         }
  2526   2532       }
  2527   2533   #else
  2528   2534       zBrowser = db_get("web-browser", "open");
  2529   2535   #endif
  2530         -    if( zIpAddr ){
  2531         -      zBrowserCmd = mprintf("%s \"http://%s:%%d/%s\" &",
         2536  +    if( zIpAddr==0 ){
         2537  +      zBrowserCmd = mprintf("%s http://localhost:%%d/%s &",
         2538  +                            zBrowser, zInitPage);
         2539  +    }else if( strchr(zIpAddr,':') ){
         2540  +      zBrowserCmd = mprintf("%s http://[%s]:%%d/%s &",
  2532   2541                               zBrowser, zIpAddr, zInitPage);
  2533   2542       }else{
  2534         -      zBrowserCmd = mprintf("%s \"http://localhost:%%d/%s\" &",
  2535         -                            zBrowser, zInitPage);
         2543  +      zBrowserCmd = mprintf("%s http://%s:%%d/%s &",
         2544  +                            zBrowser, zIpAddr, zInitPage);
  2536   2545       }
  2537   2546     }
  2538   2547     if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
  2539   2548     if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
  2540   2549     db_close(1);
  2541   2550     if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
  2542   2551       fossil_fatal("unable to listen on TCP socket %d", iPort);
................................................................................
  2563   2572       cgi_handle_http_request(0);
  2564   2573     }
  2565   2574     process_one_web_page(zNotFound, glob_create(zFileGlob), allowRepoList);
  2566   2575   #else
  2567   2576     /* Win32 implementation */
  2568   2577     if( isUiCmd ){
  2569   2578       zBrowser = db_get("web-browser", "start");
  2570         -    if( zIpAddr ){
  2571         -      zBrowserCmd = mprintf("%s http://%s:%%d/%s &",
         2579  +    if( zIpAddr==0 ){
         2580  +      zBrowserCmd = mprintf("%s http://localhost:%%d/%s &",
         2581  +                            zBrowser, zInitPage);
         2582  +    }else if( strchr(zIpAddr,':') ){
         2583  +      zBrowserCmd = mprintf("%s http://[%s]:%%d/%s &",
  2572   2584                               zBrowser, zIpAddr, zInitPage);
  2573   2585       }else{
  2574         -      zBrowserCmd = mprintf("%s http://[::1]:%%d/%s &",
  2575         -                            zBrowser, zInitPage);
         2586  +      zBrowserCmd = mprintf("%s http://%s:%%d/%s &",
         2587  +                            zBrowser, zIpAddr, zInitPage);
  2576   2588       }
  2577   2589     }
  2578   2590     if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
  2579   2591     if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
  2580   2592     db_close(1);
  2581   2593     if( allowRepoList ){
  2582   2594       flags |= HTTP_SERVER_REPOLIST;