Skip to content

Commit

Permalink
Add redbean -I flag for launching browser
Browse files Browse the repository at this point in the history
It's now possible with any redbean (including redbean-original) to
launch the system web browser without having to use the Lua API. For
example, you can create an args file:

    echo -I/ >.args
    zip redbean-original.com .args

That will white-label redbean so it launches a specific page when you
double-click on the executable.

See #472
  • Loading branch information
jart committed Jul 17, 2022
1 parent 4d25f8c commit 5b11033
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions third_party/mbedtls/ssl_srv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,7 @@ static int ssl_parse_client_hello_v2( mbedtls_ssl_context *ssl )
/* [jart] grab some client ciphers for error messages */
bzero(ssl->client_ciphers, sizeof(ssl->client_ciphers));
for( i = j = 0, p = buf + 6; j < ciph_len; j += 3, p += 3 )
if( !p[0] && i < ARRAYLEN( ssl->client_ciphers ) )
if( !p[0] && i+1 < ARRAYLEN( ssl->client_ciphers ) )
ssl->client_ciphers[i++] = p[1] << 8 | p[2];

#if defined(MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE)
Expand Down Expand Up @@ -2208,7 +2208,7 @@ static int ssl_parse_client_hello( mbedtls_ssl_context *ssl )
/* [jart] grab some client ciphers for error messages */
bzero(ssl->client_ciphers, sizeof(ssl->client_ciphers));
for( i = j = 0, p = buf + ciph_offset + 2; j < ciph_len; j += 2, p += 2 )
if( i < ARRAYLEN( ssl->client_ciphers ) )
if( i+1 < ARRAYLEN( ssl->client_ciphers ) )
ssl->client_ciphers[i++] = p[0] << 8 | p[1];

/*
Expand Down
1 change: 1 addition & 0 deletions tool/net/help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ FLAGS
-P PATH pid file location
-U INT daemon set user id
-G INT daemon set group id
-w PATH launch browser on startup
--strace enables system call tracing (see also -Z)
--ftrace enables function call tracing (see also -f)

Expand Down
6 changes: 4 additions & 2 deletions tool/net/redbean.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,11 @@ STATIC_YOINK("ShowCrashReportsEarly");
} \
} while (0)

// letters not used: EINOQYnoqwxy
// letters not used: INOQYnoqwxy
// digits not used: 0123456789
// puncts not used: !"#$&'()+,-./;<=>@[\]^_`{|}~
#define GETOPTS "*%BJSVXZabdfghijkmsuvzA:C:D:F:G:H:K:L:M:P:R:T:U:W:c:e:l:p:r:t:"
#define GETOPTS \
"*%BEJSVXZabdfghijkmsuvzA:C:D:F:G:H:K:L:M:P:R:T:U:W:c:e:l:p:r:t:w:"

static const uint8_t kGzipHeader[] = {
0x1F, // MAGNUM
Expand Down Expand Up @@ -7174,6 +7175,7 @@ static void GetOpts(int argc, char *argv[]) {
CASE('u', uniprocess = true);
CASE('g', loglatency = true);
CASE('m', logmessages = true);
CASE('w', launchbrowser = strdup(optarg));
CASE('l', ProgramAddr(optarg));
CASE('H', ProgramHeader(optarg));
CASE('L', ProgramLogPath(optarg));
Expand Down

2 comments on commit 5b11033

@yapcheahshen
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit description said the argument is -I , but the code said -w .

@jart
Copy link
Owner Author

@jart jart commented on 5b11033 Jul 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoopsie

Please sign in to comment.