Commit Graph

499 Commits

Author SHA1 Message Date
Asher f7076247f9
Move domain proxy to routes
This matches better with the other routes.

Also add a missing authentication check to the path proxy web socket.
2020-11-05 17:07:32 -06:00
Asher f6c4434191
Tweak proxy fallthrough behavior
It will now redirect all HTML requests. Also it avoids req.accepts since
that's always truthy.
2020-11-05 16:49:30 -06:00
Asher cb991a9143
Handle errors for JSON requests
Previously it would have just given them the error HTML.
2020-11-05 15:19:56 -06:00
Asher 3f1750cf83
Fix destroying response in update again
I added another reject that doesn't destroy the response.
2020-11-05 15:08:10 -06:00
Asher 7b2752a62c
Move websocket routes into a separate app
This is mostly so we don't have to do any wacky patching but it also
makes it so we don't have to keep checking if the request is a web
socket request every time we add middleware.
2020-11-05 15:08:09 -06:00
Asher 9e09c1f92b
Upgrade to Express 5
Now async routes are handled!
2020-11-05 15:08:08 -06:00
Asher 8252c372af
Provide a way to tell when event handlers are finished
This lets us actually wait for disposal before a graceful exit.
2020-11-05 15:08:07 -06:00
Asher 396af23842
Kill VS Code when process exits
This is to ensure it doesn't hang around.
2020-11-04 17:07:41 -06:00
Asher 34225e2bdf
Use ensureAuthenticated as middleware 2020-11-04 17:07:40 -06:00
Asher 476379a77e
Fix cookie domain
Had double Domain=
2020-11-04 17:07:39 -06:00
Asher 210fc049c4
Document VS Code endpoints 2020-11-04 17:07:39 -06:00
Asher e5c8e0aad1
Remove useless || 2020-11-04 17:07:38 -06:00
Asher c5ce365482
Use query variable to force update check 2020-11-04 17:07:37 -06:00
Asher a653b93ce2
Include protocol on printed address
This makes it clickable from the terminal.
2020-11-04 17:07:36 -06:00
Asher e2c35facdb
Remove invalid comment on maybeProxy
It no longer handles authentication.
2020-11-04 17:07:35 -06:00
Asher 75b93f9dc5
Fix bind address priority
Broke when converting to a loop.
2020-11-04 17:07:24 -06:00
Asher 8066da12fe
Remove unused Locals interface 2020-11-03 15:37:22 -06:00
Asher 03e0013112
Unbind error/exit events once handshakes resolve 2020-11-03 15:27:21 -06:00
Asher e243f6e369
Return early when forking to reduce indentation 2020-11-03 15:27:21 -06:00
Asher c10450c4c5
Move isFile into util
That allows its use in entry.ts as well.
2020-11-03 15:27:20 -06:00
Asher c72c53f64d
Fix not being able to dispose vscode after failed disposal 2020-11-03 14:36:27 -06:00
Asher f4e5855318
Simplify update request 2020-11-03 14:35:23 -06:00
Asher 3a074fd844
Skip unnecessary auth type check when using --link 2020-11-03 14:30:34 -06:00
Asher 8a9e61defb
Use Addr interface everywhere and loop over arg sources 2020-11-03 14:28:49 -06:00
Asher 1067507c41
Proxy to 0.0.0.0 instead of localhost 2020-11-03 14:28:48 -06:00
Anmol Sethi f9e0990594
Merge pull request #2255 from cdr/self-signed-3b2c
Fix self signed certificate for iPad
2020-11-03 14:04:47 -05:00
Asher 9ad7d0b7a3
Fix potential 500 when loading in parallel 2020-10-30 16:16:46 -05:00
Asher 07e7c38ea2
Immediately pause web socket
This will buffer any data sent to it until something is ready to listen
on it.
2020-10-30 16:16:46 -05:00
Anmol Sethi a1b61d1659
src/node/util.ts: Mark generated certificates as CA
Required for access under iPad.
2020-10-30 13:36:53 -04:00
Anmol Sethi bae28727bd
src/node/cli.ts: Add --cert-host to configure generated certificate hostname 2020-10-30 13:36:53 -04:00
Anmol Sethi 8b85006996
src/node/util.ts: Make certificate generation "modern"
Now we add a subject alt name, set extendedKeyUsage and use the
correct certificate extension.

The above allow it to be properly trusted by iOS.

See https://support.apple.com/en-us/HT210176

*.cert isn't a real extension for certificates, *.crt is correct
for it to be recognized by e.g. keychain or when importing as a profile
into iOS.

Updates #1566

I've been able to successfully connect from my iPad Pro now to my
code-server instance with a self signed certificate! Next commit
will be docs.
2020-10-30 13:36:53 -04:00
Anmol Sethi 10b3028196
util: Generate self signed certificate into data directory
Closes #1778
2020-10-30 13:36:53 -04:00
Asher f2f1fee6f1
Short-circuit heartbeat when alive 2020-10-27 17:48:37 -05:00
Asher 504d89638b
Fix open line being printed when open fails
Opening the URL can fail if the user doesn't have something appropriate
installed to handle it.
2020-10-27 17:43:11 -05:00
Asher dc177ab505
Unambiguify address replacement
Co-authored-by: Teffen Ellis <TeffenEllis@users.noreply.github.com>
2020-10-27 17:38:54 -05:00
Asher cde94d5ed4
Remove redundant serverAddress check
We now guarantee there is an address.
2020-10-27 17:35:42 -05:00
Asher 305348f0ac
Improve proxy fallthrough logic
- Use accept header.
- Match /login and /login/ exactly.
- Match /static/ (trailing slash).
- Use req.path. Same result but feels more accurate to me.
2020-10-27 17:31:37 -05:00
Asher 6ab6cb4f07
Fix error handler types 2020-10-27 17:20:13 -05:00
Asher 6422a8d74b
Fix webview resource path 2020-10-27 17:17:05 -05:00
Asher 257d9a4fa4
Make authentication work with sub-domain proxy 2020-10-26 17:56:14 -05:00
Asher 112eda4605
Convert routes to Express 2020-10-26 17:56:13 -05:00
Asher 4b6cbacbad
Add file for global constants 2020-10-26 17:56:12 -05:00
Asher 71dc5c7542
Switch to Express
It doesn't do anything yet.
2020-10-26 17:56:11 -05:00
Asher 8e93e28162
Strip config file password from debug log 2020-10-20 16:18:28 -05:00
Asher 9f25cc6d5d
Move providers from `app` to `routes` 2020-10-20 16:18:27 -05:00
Asher 2928d362fa
Move heart and AuthType out of http
This file is going to get blasted in favor of Express.
2020-10-20 16:18:24 -05:00
Asher dcb303a437
Move argument defaults into setDefaults 2020-10-20 16:15:13 -05:00
Asher a7c43a8eb6
Remove CSP tag from VS Code html
This matches with the html in the VS Code repo and also fixes a problem
with the worker which loads HTML using data: and then can't load any
scripts because 'self' doesn't work.
2020-10-14 17:11:24 -05:00
Asher 30d05aeb4b
Update require base URL for VS Code loader
It needs to have the scheme otherwise when resolving these modules the
loader will default to the file scheme and fail to fetch.
2020-10-14 17:11:24 -05:00
Asher 07580e1fcb
Add path to loader for tas-client-umd
It's a new module used by 1.50.0.
2020-10-14 17:11:23 -05:00
Anmol Sethi 00383b79b9
Merge pull request #2099 from cdr/open-in
Make opening in an existing instance work outside code-server
2020-10-12 01:14:15 -04:00
Asher c6ba12942c
Filter blank plugin directories (#2187)
I neglected to realize that "".split(":") is an array with "" in it.
2020-10-11 02:14:43 -04:00
Asher 26c735b434
Remove tryParse
Now that the exception handling happens further up there doesn't seem to
be an advantage in having this in a separate method.
2020-10-09 17:05:21 -05:00
Asher 466a04f874
Remove pointless use of openInFlagCount
It'll always be zero here.
2020-10-09 16:57:45 -05:00
Asher e0769dc13a
Move config file info log
Otherwise it outputs when trying to open a file in an existing instance
externally. Externally there isn't an environment variable to branch on
to skip this line so instead output it with the other info lines in the
child process.
2020-10-09 16:57:44 -05:00
Asher fe19391c03
Read most recent socket path from file 2020-10-09 16:57:43 -05:00
Asher 021c084e43
Move log level defaults into setDefaults
This will allow cliArgs to be only the actual arguments the user passed
which will be used for some logic around opening in existing instances.
2020-10-09 16:57:42 -05:00
Asher 1902296702
Remove references to --open-in flag 2020-10-09 16:57:41 -05:00
Asher bb1bf88439
Fix wrapper.start not actually waiting for anything 2020-10-09 16:57:41 -05:00
Asher 0a8e71c647
Refactor wrapper
- Immediately create ipcMain so it doesn't have to be a function which I
  think feels cleaner.
  - Move exit handling to a separate function to compensate (otherwise
    the VS Code CLI for example won't be able to exit on its own).
- New isChild prop that is clearer than checking for parentPid (IMO).
- Skip all the checks that aren't necessary for the child process (like
  --help, --version, etc).
  - Since we check if we're the child in entry go ahead and move the
    wrap code into entry as well since that's basically what it does.
- Use a single catch at the end of the entry.
- Split out the VS Code CLI and existing instance code into separate
  functions.
2020-10-09 16:57:40 -05:00
Asher 6bdaada689
Move uncaught exception handler to wrapper
Feels more appropriate there to me.
2020-10-09 16:50:24 -05:00
Anmol Sethi 1e4e72aa5b
Merge pull request #2184 from nhooyr/link-flag-1547
cloud: Rename --coder-bind to --link
2020-10-09 13:53:55 -04:00
Anmol Sethi fcfb03382a
cloud: Add mention of cloud repo 2020-10-09 12:57:48 -04:00
Anmol Sethi d67bd3f604
cloud: Rename --coder-bind to --link 2020-10-09 12:57:20 -04:00
Anmol Sethi 2d1de749f4
Unlink socket before using (#2181)
See https://stackoverflow.com/a/34881585/4283659

Closes #1538
2020-10-09 12:34:52 -04:00
Asher c6c293d53a
Merge pull request #2147 from cdr/multi-plugin 2020-10-09 11:02:25 -05:00
Anmol Sethi a5b6d080bd
Add CS_BETA and note --coder-bind is in beta 2020-10-09 07:50:51 -04:00
Anmol Sethi 9ff37977a8
Make --coder-bind disable HTTPS 2020-10-09 07:39:10 -04:00
Anmol Sethi f5489cd3a0
Hide -coder-bind for now 2020-10-09 07:38:38 -04:00
Asher c86d7398ab
Use system data directory for plugins 2020-10-08 16:18:31 -05:00
Anmol Sethi 3e28ab85a0
Add debug log for options passed to the agent 2020-10-07 17:40:19 -04:00
Anmol Sethi 85b0804be5
Remove cliArgs from main
No purpose when all the args are in the args parameter.

We only need configArgs for bindAddrFromAllSources.
2020-10-07 17:40:19 -04:00
Anmol Sethi df3089f3ad
coder-cloud: Use consolidated bind command 2020-10-07 17:40:19 -04:00
Anmol Sethi bfe731f4f3
Ensure socket is undefined with --coder-bind 2020-10-07 16:16:01 -04:00
Anmol Sethi c4f1c053bf
Show valid values for --auth in --help
See https://github.com/nhooyr/code-server/pull/1/files#r485847134
2020-10-07 15:58:30 -04:00
Anmol Sethi 4b3c089630
Remove dead code 2020-10-07 15:58:30 -04:00
Anmol Sethi 1c16814a89
Update coder-bind docs 2020-10-07 15:58:30 -04:00
Anmol Sethi c3c24fe4d2
Fixes for @ammarb 2020-10-07 15:58:30 -04:00
Anmol Sethi 22c4a7e10f
Make linking and starting code-server to the cloud a single command 2020-10-07 15:58:30 -04:00
Anmol Sethi 0aa98279d6
Fixes for CI 2020-10-07 15:58:30 -04:00
Anmol Sethi 55a7e8b56f
Implement automatic cloud proxying 2020-10-07 15:58:30 -04:00
Anmol Sethi 916e24e109
Add support for multiline descriptions 2020-10-07 15:58:30 -04:00
Anmol Sethi c7c62daa67
Remove unused code in optionDescriptions 2020-10-07 15:58:30 -04:00
Anmol Sethi 579bb94a6c
Add coder cloud expose command 2020-10-07 15:58:30 -04:00
Asher a44b4455f5
Read plugin name from package.json 2020-10-07 12:54:48 -05:00
Asher c2ac126a50
Log all plugin errors as errors 2020-10-07 12:25:42 -05:00
Asher ddda280df4
Rename plugin vars and make both colon-separated
Only one was colon separated but now they both are.
2020-10-07 12:18:57 -05:00
Asher 7a982555a8
Add version to plugin load log 2020-09-30 15:52:40 -05:00
Asher e64b186527
Add variables to better customize plugin directories 2020-09-30 15:52:39 -05:00
Asher 11eaf0b470
Fix being unable to use [::] for the host
Fixes #1582.
2020-09-30 12:49:36 -05:00
Asher 8b5deac92b
Fix 80 getting dropped from bind-addr 2020-09-30 11:57:23 -05:00
Asher 9d87c5328c
Add robots.txt (#2080)
Closes #1886.
2020-09-14 17:34:48 -05:00
Anmol Sethi cc5ed1eb57
Allow installing extensions from the CLI while $VSCODE_IPC_HOOK_CLI
Closes #2083
2020-09-11 11:49:22 -04:00
Asher ffe6a663aa
Add /vscode to nls fetch
A plugin may modify the root endpoint which will make /resource no
longer work so always use /vscode/resource instead.
2020-09-09 12:05:44 -05:00
Asher 938b460685
Add trailing slash to service worker scope
This will ensure it always matches or is underneath the allowed service
worker scope.

Fixes #2076.
2020-09-09 12:05:04 -05:00
Asher fef619aef8
Fix incorrect login script src path 2020-09-08 14:06:41 -05:00
Asher 0a2328c1f6
Don't require auth for healthz (#2055)
* Don't require authentication for healthz endpoint

* Add FAQ entry for /healthz
2020-09-08 13:59:01 -05:00
Asher e44e574ce1
Fix language packs (#2058)
* Fix incorrect nls.json fetch

When moving this out of the HTML I didn't remove {{BASE}}.

* Fix language package installation

Updates #2046.
2020-09-04 10:10:40 -05:00
Asher 617cd38c71
Fix my bad conflict resolution from the github ui 2020-08-31 11:10:12 -05:00
Jacob Goldman 75c8fdeed2
Added /healthz JSON response for heartbeat data. #1940 (#1984) 2020-08-31 10:29:12 -05:00
Asher ce8577b1c3
Remove open-in flag (#2013) 2020-08-27 15:04:37 -05:00
shayne ceb2265b14
Allow opening files, folders, and workspaces in existing code-server from CLI (#1994)
Add initial support for opening files / folders in running code-server instance.

Current limitations:

- unable to open a file in a new window, only folders
- unable to use addMode feature
- others...
2020-08-27 13:06:21 -05:00
Anmol Sethi 864a9e7bd6
Merge pull request #1999 from cdr/update
Update dependencies in package.json
2020-08-27 13:17:18 -04:00
Asher a839da34d7
Remove custom offline text (#2007)
We need the handler to be recognized as a PWA but we can just let the
original offline browser message show instead of our own message.

See #1925 and #1979.
2020-08-27 11:33:34 -05:00
Asher eebb8bb314
Add proposed API flag (#2002)
Co-authored-by: giddyuptiger <65830808+giddyuptiger@users.noreply.github.com>
2020-08-26 14:18:40 -05:00
Anmol Sethi ebbb1187da
Update remaining dependencies 2020-08-26 14:27:30 -04:00
Anmol Sethi c8f63b61c4
Fix fmt and lint 2020-08-26 14:21:37 -04:00
Asher e237589f2e
Update VS Code to 1.48.0 (#1982) 2020-08-25 13:06:41 -05:00
Asher 74910ffcdf
Hotswap on SIGUSR1 (#1970) 2020-08-17 14:17:55 -05:00
Asher 3c90b1e327
Merge pull request #1969 from cdr/qol
qol changes
2020-08-17 14:17:29 -05:00
Asher 0dcf469725
Add @version information to --help
This mimics a recent change in VS Code's help. See #1965.
2020-08-13 18:08:35 -05:00
Asher d8568ebaa9
Enforce import order 2020-08-13 17:11:35 -05:00
Asher f7790c9719
Remove unused deep merge code 2020-08-13 17:11:34 -05:00
Asher 150d37868a
Enforce strict equals 2020-08-13 17:11:33 -05:00
Asher d6d24966be
Move vscode JS to a separate file
Mostly to match everything else.
2020-08-13 17:10:59 -05:00
Asher 751a5ea3ad
Move login JS to a separate file
Mostly so the base URL resolution code can be shared.
2020-08-13 17:10:54 -05:00
Asher de568d446b
Add cookie domain debug logs
To help debug login issues.
2020-08-13 17:06:32 -05:00
Asher 7d02f34f71
Merge pull request #1934 from cdr/plugin
Add plugin system for adding http endpoints
2020-08-13 16:59:44 -05:00
G r e y a0ff2014c3
Add Callback type
Adds a reusable Callback type that is applied to emitter.ts for improved
readability/simplicity.
2020-08-10 21:41:46 -05:00
G r e y 6e27869c09
Add str param to plural util
Adds a str param to common/util::plural for pluralizing a string.
Applies plural to entry.ts.
2020-08-09 00:06:18 -05:00
Asher 9b979ac869
Document code-server injection 2020-08-05 13:00:37 -05:00
Asher 3badf6bf7b
Use ?? for base default 2020-08-05 13:00:36 -05:00
Asher 10c2b956ac
Remove leading slash trim in base resolver
It's not necessary since we return early if the path starts with a
slash.
2020-08-05 13:00:35 -05:00
Asher 543d64268d
Simplify valid path check 2020-08-05 13:00:34 -05:00
Asher fd36f8c168
Use error log level for plugin load failure 2020-08-05 13:00:33 -05:00
Asher 361e7103ea
Enable loading external plugins 2020-07-31 17:42:48 -05:00
Asher bac948ea6f
Add plugin system 2020-07-31 15:08:02 -05:00
Asher 5370f7876d
Merge pull request #1927 from cdr/dead-code
Remove dead code
2020-07-31 12:25:56 -05:00
futengda ecb9bb2428 refactor: write `lastVisited` and `query` at the same time
In addition, the `settings.write` method now uses shallow merge by default
2020-07-31 12:25:20 +08:00
Asher e86c066438
Add helper functions to make some code clearer 2020-07-30 12:14:31 -05:00
futengda b6e791f7d0 refactor: write route.query via settings.write
I added a shallow parameter, because the query should not be extends, but should be replaced directly.
2020-07-30 16:54:02 +08:00
Asher 2fa5037859
Log output to disk 2020-07-29 18:48:07 -05:00
Asher 7c2ca7d03e
Add the ability to prepend to the proxy path
This is for applications like Jupyter that aren't base path agnostic.
2020-07-29 18:48:06 -05:00
Asher c67d31580f
Include details if any in JSON requests 2020-07-29 18:48:05 -05:00
Asher 58bd7008b4
Make dispose async 2020-07-29 18:48:04 -05:00
Asher 554b6d6fcf
Remove apply portion of update endpoint
It can still be used to check for updates but will not apply them.

For now also remove the update check loop in VS Code since it's
currently unused (update check is hardcoded off right now) and won't
work anyway since it also applies the update which now won't work. In
the future we should integrate the check into the browser update
service.
2020-07-29 18:48:02 -05:00
fxxjdedd 5ba650bb6f
feat: persist route query to local
Provide a way for the shell script running in the docker container to get the url query.
2020-07-28 20:14:52 +08:00
Asher e8f6d30055
Make providers endpoint-agnostic
A provider can now be registered on multiple endpoints (or potentially
moved if needed).
2020-07-27 12:00:48 -05:00
Asher 2819fd51e2
Remove unused endpoints
- dashboard
- app api
2020-07-27 12:00:42 -05:00
Asher de8e9804ad
Update to VS Code 1.47.2 2020-07-21 13:16:44 -05:00
Anmol Sethi c00f931500
Remove zip library dependency 2020-06-03 18:24:59 -04:00
Anmol Sethi 85ad7e4fb4
Remove duplicate log
Also confirmed that #1750 is fixed.
2020-06-03 15:45:17 -04:00
Anmol Sethi 11d7932968
Stop bundling libraries in release
- Instead we now use CentOS 7 for the static build to guarantee
  that we only depend on libc v2.17

- For macOS we now pull in a static node binary and bundle that instead.
2020-06-03 15:45:16 -04:00
Anmol Sethi 2c2a6498af
Parse config file in entry
This way setting --data-dir and --extension-dir in the config file
will work for --install--extension and whatnot.
2020-06-03 15:45:16 -04:00
Anmol Sethi 7ab47b3d83
Trim LD_LIBRARY_PATH on startup 2020-06-03 15:45:16 -04:00
Anmol Sethi 9d0dcf3c44
Fix extension install path for CLI
Closes #1713
2020-05-27 14:28:40 -04:00
Anmol Sethi 8053ec6872
Allow user-data-dir and extension-dir in config.yaml
Closes #1676
2020-05-19 00:41:27 -04:00
Asher f7f11ad6c2
Fix paths from Windows client to non-Windows server
Fixes #1659
Fixes #1642
2020-05-18 15:06:11 -05:00
Anmol Sethi 6a25b3bfa0
Document structure better
Closes #1648
2020-05-17 16:53:08 -04:00
Anmol Sethi 73b2ff0945
$PORT should always override port in --bind-addr 2020-05-14 22:33:12 -04:00