Removed overwriting -b flag, now launches to serveradd:port

This commit is contained in:
Rowan 2021-04-18 12:34:23 +01:00
parent df9e0bf18f
commit a6000b42f2

View file

@ -319,7 +319,6 @@ static bool terminated;
static bool uniprocess; static bool uniprocess;
static bool invalidated; static bool invalidated;
static bool logmessages; static bool logmessages;
static bool launchbrowser;
static bool checkedmethod; static bool checkedmethod;
static bool connectionclose; static bool connectionclose;
static bool keyboardinterrupt; static bool keyboardinterrupt;
@ -619,8 +618,7 @@ static void GetOpts(int argc, char *argv[]) {
logmessages = true; logmessages = true;
break; break;
case 'b': case 'b':
launchbrowser = true; logbodies = true;
// logbodies = true;
break; break;
case 'z': case 'z':
printport = true; printport = true;
@ -1473,8 +1471,10 @@ static void LaunchBrowser() {
} else { } else {
prog = "xdg-open"; prog = "xdg-open";
} }
snprintf(openbrowsercommand, sizeof(openbrowsercommand), struct in_addr addr = serveraddr.sin_addr;
"%s http://127.0.0.1:%d", prog, ntohs(serveraddr.sin_port)); if (addr.s_addr == INADDR_ANY) addr.s_addr = htonl(INADDR_LOOPBACK);
snprintf(openbrowsercommand, sizeof(openbrowsercommand), "%s http://%s:%d",
prog, inet_ntoa(addr), ntohs(serveraddr.sin_port));
DEBUGF("Opening browser with command %s\n", openbrowsercommand); DEBUGF("Opening browser with command %s\n", openbrowsercommand);
system(openbrowsercommand); system(openbrowsercommand);
} }
@ -2655,7 +2655,6 @@ void RedBean(int argc, char *argv[]) {
inbuf.p = xvalloc(inbuf.n); inbuf.p = xvalloc(inbuf.n);
hdrbuf.n = 4 * 1024; hdrbuf.n = 4 * 1024;
hdrbuf.p = xvalloc(hdrbuf.n); hdrbuf.p = xvalloc(hdrbuf.n);
if (launchbrowser) LaunchBrowser();
while (!terminated) { while (!terminated) {
if (zombied) { if (zombied) {
ReapZombies(); ReapZombies();