Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Coder
code-server
提交
4aa15401
C
code-server
项目概览
镜像
/
Coder
/
code-server
2022-09-21 03:15:05同步失败
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
code-server
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
4aa15401
编写于
2月 14, 2020
作者:
A
Anmol Sethi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Format and lint
上级
80b1b1b6
变更
31
隐藏空白更改
内联
并排
Showing
31 changed file
with
259 addition
and
140 deletion
+259
-140
.eslintrc.yaml
.eslintrc.yaml
+1
-1
.github/workflows/ci.yml
.github/workflows/ci.yml
+45
-3
README.md
README.md
+2
-0
ci/build.ts
ci/build.ts
+6
-6
ci/fmt.sh
ci/fmt.sh
+29
-9
ci/image/Dockerfile
ci/image/Dockerfile
+3
-0
ci/lint.sh
ci/lint.sh
+8
-2
ci/release.sh
ci/release.sh
+8
-8
ci/tsconfig.json
ci/tsconfig.json
+1
-3
ci/vscode.sh
ci/vscode.sh
+1
-1
package.json
package.json
+0
-3
src/browser/media/manifest.json
src/browser/media/manifest.json
+7
-5
src/browser/pages/app.html
src/browser/pages/app.html
+12
-5
src/browser/pages/error.html
src/browser/pages/error.html
+12
-5
src/browser/pages/global.css
src/browser/pages/global.css
+11
-1
src/browser/pages/home.html
src/browser/pages/home.html
+12
-5
src/browser/pages/login.html
src/browser/pages/login.html
+17
-6
src/browser/pages/vscode.html
src/browser/pages/vscode.html
+58
-48
src/browser/socket.ts
src/browser/socket.ts
+1
-1
src/node/app/api.ts
src/node/app/api.ts
+4
-4
src/node/app/app.ts
src/node/app/app.ts
+3
-3
src/node/app/login.ts
src/node/app/login.ts
+1
-1
src/node/app/vscode.ts
src/node/app/vscode.ts
+4
-4
src/node/cli.ts
src/node/cli.ts
+3
-3
src/node/entry.ts
src/node/entry.ts
+1
-1
src/node/http.ts
src/node/http.ts
+3
-3
src/node/util.ts
src/node/util.ts
+1
-1
src/node/wrapper.ts
src/node/wrapper.ts
+2
-2
test/cli.test.ts
test/cli.test.ts
+1
-1
tsconfig.json
tsconfig.json
+1
-4
typings/httpolyglot/index.d.ts
typings/httpolyglot/index.d.ts
+1
-1
未找到文件。
.eslintrc.yaml
浏览文件 @
4aa15401
parser
:
"
@typescript-eslint/parser"
env
:
browser
:
true
es6
:
true
# Map, etc.
es6
:
true
# Map, etc.
mocha
:
true
node
:
true
...
...
.github/workflows/ci.yml
浏览文件 @
4aa15401
name
:
ci
on
:
[
push
,
pull_request
]
on
:
[
push
,
pull_request
,
release
]
jobs
:
fmt
:
runs-on
:
ubuntu-latest
steps
:
-
uses
:
actions/checkout@v1
-
name
:
Get yarn cache directory path
id
:
yarn-cache-dir-path
run
:
echo "::set-output name=dir::$(yarn cache dir)"
-
uses
:
actions/cache@v1
id
:
yarn-cache
with
:
path
:
${{ steps.yarn-cache-dir-path.outputs.dir }}
key
:
${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys
:
|
${{ runner.os }}-yarn-
-
name
:
Run yarn fmt
uses
:
./ci/image
with
:
args
:
yarn && yarn fmt
lint
:
runs-on
:
ubuntu-latest
steps
:
-
uses
:
actions/checkout@v1
-
name
:
g
et yarn cache directory path
-
name
:
G
et yarn cache directory path
id
:
yarn-cache-dir-path
run
:
echo "::set-output name=dir::$(yarn cache dir)"
-
uses
:
actions/cache@v1
...
...
@@ -18,7 +39,28 @@ jobs:
restore-keys
:
|
${{ runner.os }}-yarn-
-
name
:
yarn lint
-
name
:
Run
yarn lint
uses
:
./ci/image
with
:
args
:
yarn && yarn lint
release-amd64
:
runs-on
:
ubuntu-latest
steps
:
-
uses
:
actions/checkout@v1
-
name
:
Get yarn cache directory path
id
:
yarn-cache-dir-path
run
:
echo "::set-output name=dir::$(yarn cache dir)"
-
uses
:
actions/cache@v1
id
:
yarn-cache
with
:
path
:
${{ steps.yarn-cache-dir-path.outputs.dir }}
key
:
${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys
:
|
${{ runner.os }}-yarn-
-
name
:
Run release.sh
uses
:
./ci/image
with
:
args
:
yarn && yarn vscode && ./ci/release.sh
README.md
浏览文件 @
4aa15401
...
...
@@ -74,6 +74,7 @@ reset VS Code then run `yarn patch:apply`.
## Security
### Authentication
By default
`code-server`
enables password authentication using a randomly
generated password. You can set the
`PASSWORD`
environment variable to use your
own instead or use
`--auth none`
to disable password authentication.
...
...
@@ -82,6 +83,7 @@ Do not expose `code-server` to the open internet without some form of
authentication.
### Encrypting traffic with HTTPS
If you aren't doing SSL termination elsewhere you can directly give
`code-server`
a certificate with
`code-server --cert`
followed by the path to
your certificate. Additionally, you can use certificate keys with
`--cert-key`
...
...
ci/build.ts
浏览文件 @
4aa15401
...
...
@@ -26,7 +26,7 @@ class Builder {
this
.
ensureArgument
(
"
rootPath
"
,
this
.
rootPath
)
this
.
codeServerVersion
=
this
.
ensureArgument
(
"
codeServerVersion
"
,
process
.
env
.
VERSION
||
require
(
path
.
join
(
this
.
rootPath
,
"
package.json
"
)).
version
process
.
env
.
VERSION
||
require
(
path
.
join
(
this
.
rootPath
,
"
package.json
"
)).
version
,
)
}
...
...
@@ -208,7 +208,7 @@ class Builder {
await
Promise
.
all
([
fs
.
move
(
path
.
join
(
this
.
vscodeSourcePath
,
`out-vscode
${
process
.
env
.
MINIFY
?
"
-min
"
:
""
}
`
),
path
.
join
(
vscodeBuildPath
,
"
out
"
)
path
.
join
(
vscodeBuildPath
,
"
out
"
)
,
),
fs
.
copy
(
path
.
join
(
this
.
vscodeSourcePath
,
"
.build/extensions
"
),
path
.
join
(
vscodeBuildPath
,
"
extensions
"
)),
])
...
...
@@ -225,7 +225,7 @@ class Builder {
return
Promise
.
all
(
[
"
node_modules
"
,
"
package.json
"
,
"
yarn.lock
"
].
map
((
fileName
)
=>
{
return
fs
.
copy
(
path
.
join
(
sourcePath
,
fileName
),
path
.
join
(
buildPath
,
fileName
))
})
})
,
)
})
...
...
@@ -240,8 +240,8 @@ class Builder {
...
merge
,
},
null
,
2
)
2
,
)
,
)
})
...
...
@@ -290,7 +290,7 @@ class Builder {
await
fs
.
copyFile
(
path
.
join
(
this
.
vscodeSourcePath
,
"
LICENSE.txt
"
),
path
.
join
(
archivePath
,
"
LICENSE.txt
"
))
await
fs
.
copyFile
(
path
.
join
(
this
.
vscodeSourcePath
,
"
ThirdPartyNotices.txt
"
),
path
.
join
(
archivePath
,
"
ThirdPartyNotices.txt
"
)
path
.
join
(
archivePath
,
"
ThirdPartyNotices.txt
"
)
,
)
if
((
await
this
.
target
())
===
"
darwin
"
)
{
...
...
ci/fmt.sh
浏览文件 @
4aa15401
...
...
@@ -3,15 +3,35 @@
set
-euo
pipefail
main
()
{
shfmt
-i
2
-w
-s
-sr
$$
(
git ls-files
"*.sh"
)
prettier
--write
--loglevel
=
warn
$$
(
git ls-files
"*.js"
"*.ts"
"*.tsx"
"*.html"
"*.json"
"*.css"
"*.md"
"*.toml"
"*.yaml"
"*.yml"
)
if
[[
"
$CI
"
!=
""
&&
$$
(
git ls-files
--other
--modified
--exclude-standard
)
!=
""
]]
;
then
echo
"Files need generation or are formatted incorrectly:"
git
-c
color.ui
=
always status |
grep
--color
=
no
'\[31m'
echo
"Please run the following locally:"
echo
" make fmt"
exit
1
fi
if
[[
${
CI
-
}
]]
;
then
cd
"
$(
dirname
"
$0
"
)
/.."
./ci/vscode.sh
fi
shfmt
-i
2
-w
-s
-sr
$(
git ls-files
"*.sh"
)
local
prettierExts
prettierExts
=(
"*.js"
"*.ts"
"*.tsx"
"*.html"
"*.json"
"*.css"
"*.md"
"*.toml"
"*.yaml"
"*.yml"
)
prettier
--write
--loglevel
=
warn
$(
git ls-files
"
${
prettierExts
[@]
}
"
)
if
[[
${
CI
-
}
&&
$(
git ls-files
--other
--modified
--exclude-standard
)
]]
;
then
echo
"Files need generation or are formatted incorrectly:"
git
-c
color.ui
=
always status |
grep
--color
=
no
'\[31m'
echo
"Please run the following locally:"
echo
" yarn fmt"
exit
1
fi
}
main
"
$@
"
ci/image/Dockerfile
浏览文件 @
4aa15401
...
...
@@ -9,4 +9,7 @@ RUN curl -L https://github.com/mvdan/sh/releases/download/v3.0.1/shfmt_v3.0.1_li
COPY
entrypoint.sh /bin/entrypoint.sh
ENV
PAGER=cat
ENV
CI=true
ENTRYPOINT
["dumb-init", "/bin/entrypoint.sh"]
ci/lint.sh
浏览文件 @
4aa15401
...
...
@@ -3,8 +3,14 @@
set
-euo
pipefail
main
()
{
eslint
--max-warnings
=
0
--fix
$$
(
git ls-files
"*.ts"
"*.tsx"
"*.js"
)
stylelint
--fix
$$
(
git ls-files
"*.css"
)
if
[[
${
CI
-
}
]]
;
then
cd
"
$(
dirname
"
$0
"
)
/.."
./ci/vscode.sh
fi
eslint
--max-warnings
=
0
--fix
$(
git ls-files
"*.ts"
"*.tsx"
"*.js"
)
stylelint
--fix
$(
git ls-files
"*.css"
)
tsc
--noEmit
}
main
"
$@
"
ci/release.
ba
sh
→
ci/release.sh
浏览文件 @
4aa15401
...
...
@@ -8,7 +8,7 @@ function main() {
cd
"
$(
dirname
"
${
0
}
"
)
/.."
local
code_server_version
=
${
VERSION
:-${
TRAVIS_TAG
:-${
DRONE_TAG
:-}}}
if
[[
-z
$code_server_version
]]
;
then
if
[[
-z
$code_server_version
]]
;
then
code_server_version
=
$(
grep
version ./package.json |
head
-1
|
awk
-F
:
'{ print $2 }'
|
sed
's/[",]//g'
|
tr
-d
'[:space:]'
)
fi
export
VERSION
=
$code_server_version
...
...
@@ -17,33 +17,33 @@ function main() {
export
YARN_CACHE_FOLDER
# Always minify and package on tags since that's when releases are pushed.
if
[[
-n
${
DRONE_TAG
:-}
||
-n
${
TRAVIS_TAG
:-}
]]
;
then
if
[[
-n
${
DRONE_TAG
:-}
||
-n
${
TRAVIS_TAG
:-}
]]
;
then
export
MINIFY
=
"true"
export
PACKAGE
=
"true"
fi
yarn build
yarn binary
if
[[
-n
${
PACKAGE
:-}
]]
;
then
if
[[
-n
${
PACKAGE
:-}
]]
;
then
yarn package
fi
cd
binaries
if
[[
-n
${
STRIP_BIN_TARGET
:-}
]]
;
then
if
[[
-n
${
STRIP_BIN_TARGET
:-}
]]
;
then
# In this case provide plainly named binaries.
for
binary
in
code-server
*
;
do
for
binary
in
code-server
*
;
do
echo
"Moving
$binary
to code-server"
mv
"
$binary
"
code-server
done
elif
[[
-n
${
DRONE_TAG
:-}
||
-n
${
TRAVIS_TAG
:-}
]]
;
then
elif
[[
-n
${
DRONE_TAG
:-}
||
-n
${
TRAVIS_TAG
:-}
]]
;
then
# Prepare directory for uploading binaries on release.
for
binary
in
code-server
*
;
do
for
binary
in
code-server
*
;
do
mkdir
-p
"../binary-upload"
local
prefix
=
"code-server-
$code_server_version
-"
local
target
=
"
${
binary
#
$prefix
}
"
if
[[
$target
==
"linux-x86_64"
]]
;
then
if
[[
$target
==
"linux-x86_64"
]]
;
then
echo
"Copying
$binary
to ../binary-upload/latest-linux"
cp
"
$binary
"
"../binary-upload/latest-linux"
fi
...
...
ci/tsconfig.json
浏览文件 @
4aa15401
{
"extends"
:
"../tsconfig.json"
,
"include"
:
[
"./**/*.ts"
]
"include"
:
[
"./**/*.ts"
]
}
ci/vscode.sh
浏览文件 @
4aa15401
...
...
@@ -10,7 +10,7 @@ main() {
git submodule update
--init
# If the patch fails to apply, then it's likely already applied
yarn vscode:patch &>/dev/null
||
true
yarn vscode:patch &>
/dev/null
||
true
# Install VS Code dependencies.
(
cd
lib/vscode
&&
yarn
)
...
...
package.json
浏览文件 @
4aa15401
...
...
@@ -7,12 +7,9 @@
"vscode"
:
"ci/vscode.sh"
,
"vscode:patch"
:
"cd ./lib/vscode && git apply ../../ci/vscode.patch"
,
"vscode:diff"
:
"cd ./lib/vscode && git diff HEAD > ../../ci/vscode.patch"
,
"test"
:
"mocha -r ts-node/register ./test/*.test.ts"
,
"lint"
:
"ci/lint.sh"
,
"fmt"
:
"ci/fmt.sh"
,
"runner"
:
"cd ./scripts && NODE_OPTIONS=--max_old_space_size=32384 ts-node ./build.ts"
,
"build"
:
"yarn runner build"
,
"watch"
:
"yarn runner watch"
,
...
...
src/browser/media/manifest.json
浏览文件 @
4aa15401
...
...
@@ -5,9 +5,11 @@
"display"
:
"fullscreen"
,
"background-color"
:
"#fff"
,
"description"
:
"Run editors on a remote server."
,
"icons"
:
[{
"src"
:
"./code-server.png"
,
"sizes"
:
"384x384"
,
"type"
:
"image/png"
}]
"icons"
:
[
{
"src"
:
"./code-server.png"
,
"sizes"
:
"384x384"
,
"type"
:
"image/png"
}
]
}
src/browser/pages/app.html
浏览文件 @
4aa15401
...
...
@@ -2,14 +2,21 @@
<html
lang=
"en"
>
<head>
<meta
charset=
"utf-8"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"
>
<meta
http-equiv=
"Content-Security-Policy"
content=
"style-src 'self'; manifest-src 'self'; img-src 'self' data:;"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"
/>
<meta
http-equiv=
"Content-Security-Policy"
content=
"style-src 'self'; manifest-src 'self'; img-src 'self' data:;"
/>
<title>
code-server — {{APP_NAME}}
</title>
<link
rel=
"icon"
href=
"{{BASE}}/static-{{COMMIT}}/src/browser/media/favicon.ico"
type=
"image/x-icon"
/>
<link
rel=
"manifest"
href=
"{{BASE}}/static-{{COMMIT}}/src/browser/media/manifest.json"
crossorigin=
"use-credentials"
>
<link
rel=
"manifest"
href=
"{{BASE}}/static-{{COMMIT}}/src/browser/media/manifest.json"
crossorigin=
"use-credentials"
/>
<link
rel=
"apple-touch-icon"
href=
"{{BASE}}/static-{{COMMIT}}/src/browser/media/code-server.png"
/>
<link
href=
"{{BASE}}/static-{{COMMIT}}/dist/app.css"
rel=
"stylesheet"
>
<meta
id=
"coder-options"
data-settings=
"{{OPTIONS}}"
>
<link
href=
"{{BASE}}/static-{{COMMIT}}/dist/app.css"
rel=
"stylesheet"
/
>
<meta
id=
"coder-options"
data-settings=
"{{OPTIONS}}"
/
>
</head>
<body>
<script
src=
"{{BASE}}/static-{{COMMIT}}/dist/app.js"
></script>
...
...
src/browser/pages/error.html
浏览文件 @
4aa15401
...
...
@@ -2,13 +2,20 @@
<html
lang=
"en"
>
<head>
<meta
charset=
"utf-8"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"
>
<meta
http-equiv=
"Content-Security-Policy"
content=
"style-src 'self'; manifest-src 'self'; img-src 'self' data:;"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"
/>
<meta
http-equiv=
"Content-Security-Policy"
content=
"style-src 'self'; manifest-src 'self'; img-src 'self' data:;"
/>
<title>
code-server {{ERROR_TITLE}}
</title>
<link
rel=
"icon"
href=
"{{BASE}}/static-{{COMMIT}}/src/browser/media/favicon.ico"
type=
"image/x-icon"
/>
<link
rel=
"manifest"
href=
"{{BASE}}/static-{{COMMIT}}/src/browser/media/manifest.json"
crossorigin=
"use-credentials"
>
<link
rel=
"manifest"
href=
"{{BASE}}/static-{{COMMIT}}/src/browser/media/manifest.json"
crossorigin=
"use-credentials"
/>
<link
rel=
"apple-touch-icon"
href=
"{{BASE}}/static-{{COMMIT}}/src/browser/media/code-server.png"
/>
<link
href=
"{{BASE}}/static-{{COMMIT}}/dist/app.css"
rel=
"stylesheet"
>
<link
href=
"{{BASE}}/static-{{COMMIT}}/dist/app.css"
rel=
"stylesheet"
/
>
</head>
<body>
<div
class=
"center-container"
>
...
...
@@ -18,7 +25,7 @@
{{ERROR_BODY}}
</div>
<div
class=
"links"
>
<a
class=
"link"
href=
"{{BASE}}"
>
go home
</a
<a
class=
"link"
href=
"{{BASE}}"
>
go home
</a
>
</div>
</div>
</div>
...
...
src/browser/pages/global.css
浏览文件 @
4aa15401
...
...
@@ -10,7 +10,17 @@ body {
background
:
#272727
;
color
:
#f4f4f4
;
margin
:
0
;
font-family
:
-apple-system
,
BlinkMacSystemFont
,
"Segoe UI"
,
Roboto
,
Helvetica
,
Arial
,
sans-serif
,
"Apple Color Emoji"
,
"Segoe UI Emoji"
,
"Segoe UI Symbol"
;
font-family
:
-apple-system
,
BlinkMacSystemFont
,
"Segoe UI"
,
Roboto
,
Helvetica
,
Arial
,
sans-serif
,
"Apple Color Emoji"
,
"Segoe UI Emoji"
,
"Segoe UI Symbol"
;
overflow
:
hidden
;
}
...
...
src/browser/pages/home.html
浏览文件 @
4aa15401
...
...
@@ -2,14 +2,21 @@
<html
lang=
"en"
>
<head>
<meta
charset=
"utf-8"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"
>
<meta
http-equiv=
"Content-Security-Policy"
content=
"style-src 'self'; manifest-src 'self'; img-src 'self' data:;"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"
/>
<meta
http-equiv=
"Content-Security-Policy"
content=
"style-src 'self'; manifest-src 'self'; img-src 'self' data:;"
/>
<title>
code-server
</title>
<link
rel=
"icon"
href=
"{{BASE}}/static-{{COMMIT}}/src/browser/media/favicon.ico"
type=
"image/x-icon"
/>
<link
rel=
"manifest"
href=
"{{BASE}}/static-{{COMMIT}}/src/browser/media/manifest.json"
crossorigin=
"use-credentials"
>
<link
rel=
"manifest"
href=
"{{BASE}}/static-{{COMMIT}}/src/browser/media/manifest.json"
crossorigin=
"use-credentials"
/>
<link
rel=
"apple-touch-icon"
href=
"{{BASE}}/static-{{COMMIT}}/src/browser/media/code-server.png"
/>
<link
href=
"{{BASE}}/static-{{COMMIT}}/dist/app.css"
rel=
"stylesheet"
>
<meta
id=
"coder-options"
data-settings=
"{{OPTIONS}}"
>
<link
href=
"{{BASE}}/static-{{COMMIT}}/dist/app.css"
rel=
"stylesheet"
/
>
<meta
id=
"coder-options"
data-settings=
"{{OPTIONS}}"
/
>
</head>
<body>
<div
class=
"center-container"
>
...
...
src/browser/pages/login.html
浏览文件 @
4aa15401
...
...
@@ -2,13 +2,23 @@
<html
lang=
"en"
>
<head>
<meta
charset=
"utf-8"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"
>
<meta
http-equiv=
"Content-Security-Policy"
content=
"style-src 'self'; script-src 'unsafe-inline'; manifest-src 'self'; img-src 'self' data:;"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"
/>
<meta
http-equiv=
"Content-Security-Policy"
content=
"style-src 'self'; script-src 'unsafe-inline'; manifest-src 'self'; img-src 'self' data:;"
/>
<title>
code-server login
</title>
<link
rel=
"icon"
href=
"{{BASE}}/static-{{COMMIT}}/src/browser/media/favicon.ico"
type=
"image/x-icon"
/>
<link
rel=
"manifest"
href=
"{{BASE}}/static-{{COMMIT}}/src/browser/media/manifest.json"
crossorigin=
"use-credentials"
>
<link
rel=
"manifest"
href=
"{{BASE}}/static-{{COMMIT}}/src/browser/media/manifest.json"
crossorigin=
"use-credentials"
/>
<link
rel=
"apple-touch-icon"
href=
"{{BASE}}/static-{{COMMIT}}/src/browser/media/code-server.png"
/>
<link
href=
"{{BASE}}/static-{{COMMIT}}/dist/app.css"
rel=
"stylesheet"
>
<link
href=
"{{BASE}}/static-{{COMMIT}}/dist/app.css"
rel=
"stylesheet"
/
>
</head>
<body>
<div
class=
"center-container"
>
...
...
@@ -22,7 +32,8 @@
<div
class=
"field"
>
<!-- The onfocus code places the cursor at the end of the value. -->
<input
required
autofocus
required
autofocus
value=
"{{VALUE}}"
onfocus=
"const value=this.value;this.value='';this.value=value;"
class=
"password"
...
...
@@ -30,7 +41,7 @@
placeholder=
"password"
name=
"password"
autocomplete=
"current-password"
/>
/>
<button
class=
"submit"
type=
"submit"
>
Log In
</button>
...
...
src/browser/pages/vscode.html
浏览文件 @
4aa15401
...
...
@@ -4,28 +4,38 @@
<head>
<meta
charset=
"utf-8"
/>
<meta
http-equiv=
"Content-Security-Policy"
content=
"font-src 'self'; connect-src 'self' https:; default-src ws: wss: 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; manifest-src 'self'; img-src 'self' data:;"
>
<meta
http-equiv=
"Content-Security-Policy"
content=
"font-src 'self'; connect-src 'self' https:; default-src ws: wss: 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; manifest-src 'self'; img-src 'self' data:;"
/>
<!-- Disable pinch zooming -->
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"
/>
<!-- Workbench Configuration -->
<meta
id=
"vscode-workbench-web-configuration"
data-settings=
"{{WORKBENCH_WEB_CONFIGURATION}}"
>
<meta
id=
"vscode-workbench-web-configuration"
data-settings=
"{{WORKBENCH_WEB_CONFIGURATION}}"
/
>
<!-- Workarounds/Hacks (remote user data uri) -->
<meta
id=
"vscode-remote-user-data-uri"
data-settings=
"{{REMOTE_USER_DATA_URI}}"
>
<meta
id=
"vscode-remote-commit"
data-settings=
"{{COMMIT}}"
>
<meta
id=
"vscode-remote-product-configuration"
data-settings=
"{{PRODUCT_CONFIGURATION}}"
>
<meta
id=
"vscode-remote-nls-configuration"
data-settings=
"{{NLS_CONFIGURATION}}"
>
<meta
id=
"vscode-remote-user-data-uri"
data-settings=
"{{REMOTE_USER_DATA_URI}}"
/
>
<meta
id=
"vscode-remote-commit"
data-settings=
"{{COMMIT}}"
/
>
<meta
id=
"vscode-remote-product-configuration"
data-settings=
"{{PRODUCT_CONFIGURATION}}"
/
>
<meta
id=
"vscode-remote-nls-configuration"
data-settings=
"{{NLS_CONFIGURATION}}"
/
>
<!-- Workbench Icon/Manifest/CSS -->
<link
rel=
"icon"
href=
"{{BASE}}/static-{{COMMIT}}/src/browser/media/favicon.ico"
type=
"image/x-icon"
/>
<link
rel=
"manifest"
href=
"{{BASE}}/static-{{COMMIT}}/src/browser/media/manifest.json"
crossorigin=
"use-credentials"
>
<link
rel=
"manifest"
href=
"{{BASE}}/static-{{COMMIT}}/src/browser/media/manifest.json"
crossorigin=
"use-credentials"
/>
<!-- PROD_ONLY
<link data-name="vs/workbench/workbench.web.api" rel="stylesheet" href="{{VS_BASE}}/static-{{COMMIT}}/out/vs/workbench/workbench.web.api.css">
END_PROD_ONLY -->
<link
rel=
"apple-touch-icon"
href=
"{{BASE}}/static-{{COMMIT}}/src/browser/media/code-server.png"
/>
<meta
name=
"apple-mobile-web-app-capable"
content=
"yes"
>
<meta
name=
"apple-mobile-web-app-capable"
content=
"yes"
/
>
<!-- Prefetch to avoid waterfall -->
<!-- PROD_ONLY
...
...
@@ -33,53 +43,53 @@
END_PROD_ONLY -->
</head>
<body
aria-label=
""
>
</body>
<body
aria-label=
""
></body>
<!-- Startup (do not modify order of script tags!) -->
<script>
const
parts
=
window
.
location
.
pathname
.
replace
(
/^
\/
/g
,
""
).
split
(
"
/
"
)
parts
[
parts
.
length
-
1
]
=
"
{{VS_BASE}}
"
const
url
=
new
URL
(
window
.
location
.
origin
+
"
/
"
+
parts
.
join
(
"
/
"
))
const
el
=
document
.
getElementById
(
'
vscode-remote-commit
'
);
const
commit
=
el
?
el
.
getAttribute
(
'
data-settings
'
)
:
""
;
const
staticBase
=
url
.
href
+
'
/static-
'
+
commit
;
let
nlsConfig
;
const
el
=
document
.
getElementById
(
"
vscode-remote-commit
"
)
const
commit
=
el
?
el
.
getAttribute
(
"
data-settings
"
)
:
""
const
staticBase
=
url
.
href
+
"
/static-
"
+
commit
let
nlsConfig
try
{
nlsConfig
=
JSON
.
parse
(
document
.
getElementById
(
'
vscode-remote-nls-configuration
'
).
getAttribute
(
'
data-settings
'
));
if
(
nlsConfig
.
_resolvedLanguagePackCoreLocation
)
{
const
bundles
=
Object
.
create
(
null
);
nlsConfig
.
loadBundle
=
(
bundle
,
language
,
cb
)
=>
{
let
result
=
bundles
[
bundle
];
if
(
result
)
{
return
cb
(
undefined
,
result
);
}
// FIXME: Only works if path separators are /.
const
path
=
nlsConfig
.
_resolvedLanguagePackCoreLocation
+
'
/
'
+
bundle
.
replace
(
/
\/
/g
,
'
!
'
)
+
'
.nls.json
'
;
fetch
(
`
${
url
.
href
}
/resource/?path=
${
encodeURIComponent
(
path
)}
`
)
.
then
((
response
)
=>
response
.
json
())
.
then
((
json
)
=>
{
bundles
[
bundle
]
=
json
;
cb
(
undefined
,
json
);
})
.
catch
(
cb
);
};
nlsConfig
=
JSON
.
parse
(
document
.
getElementById
(
"
vscode-remote-nls-configuration
"
).
getAttribute
(
"
data-settings
"
))
if
(
nlsConfig
.
_resolvedLanguagePackCoreLocation
)
{
const
bundles
=
Object
.
create
(
null
)
nlsConfig
.
loadBundle
=
(
bundle
,
language
,
cb
)
=>
{
let
result
=
bundles
[
bundle
]
if
(
result
)
{
return
cb
(
undefined
,
result
)
}
// FIXME: Only works if path separators are /.
const
path
=
nlsConfig
.
_resolvedLanguagePackCoreLocation
+
"
/
"
+
bundle
.
replace
(
/
\/
/g
,
"
!
"
)
+
"
.nls.json
"
fetch
(
`
${
url
.
href
}
/resource/?path=
${
encodeURIComponent
(
path
)}
`
)
.
then
((
response
)
=>
response
.
json
())
.
then
((
json
)
=>
{
bundles
[
bundle
]
=
json
cb
(
undefined
,
json
)
})
.
catch
(
cb
)
}
}
catch
(
error
)
{
/* Probably fine. */
}
}
}
catch
(
error
)
{
/* Probably fine. */
}
self
.
require
=
{
baseUrl
:
`
${
staticBase
}
/out`
,
paths
:
{
'
vscode-textmate
'
:
`
${
staticBase
}
/node_modules/vscode-textmate/release/main`
,
'
onigasm-umd
'
:
`
${
staticBase
}
/node_modules/onigasm-umd/release/main`
,
'
xterm
'
:
`
${
staticBase
}
/node_modules/xterm/lib/xterm.js`
,
'
xterm-addon-search
'
:
`
${
staticBase
}
/node_modules/xterm-addon-search/lib/xterm-addon-search.js`
,
'
xterm-addon-web-links
'
:
`
${
staticBase
}
/node_modules/xterm-addon-web-links/lib/xterm-addon-web-links.js`
,
'
xterm-addon-webgl
'
:
`
${
staticBase
}
/node_modules/xterm-addon-webgl/lib/xterm-addon-webgl.js`
,
'
semver-umd
'
:
`
${
staticBase
}
/node_modules/semver-umd/lib/semver-umd.js`
,
},
'
vs/nls
'
:
nlsConfig
,
}
;
baseUrl
:
`
${
staticBase
}
/out`
,
paths
:
{
"
vscode-textmate
"
:
`
${
staticBase
}
/node_modules/vscode-textmate/release/main`
,
"
onigasm-umd
"
:
`
${
staticBase
}
/node_modules/onigasm-umd/release/main`
,
xterm
:
`
${
staticBase
}
/node_modules/xterm/lib/xterm.js`
,
"
xterm-addon-search
"
:
`
${
staticBase
}
/node_modules/xterm-addon-search/lib/xterm-addon-search.js`
,
"
xterm-addon-web-links
"
:
`
${
staticBase
}
/node_modules/xterm-addon-web-links/lib/xterm-addon-web-links.js`
,
"
xterm-addon-webgl
"
:
`
${
staticBase
}
/node_modules/xterm-addon-webgl/lib/xterm-addon-webgl.js`
,
"
semver-umd
"
:
`
${
staticBase
}
/node_modules/semver-umd/lib/semver-umd.js`
,
},
"
vs/nls
"
:
nlsConfig
,
}
</script>
<script
src=
"{{VS_BASE}}/static-{{COMMIT}}/out/vs/loader.js"
></script>
<!-- PROD_ONLY
...
...
@@ -87,6 +97,6 @@
<script src="{{VS_BASE}}/static-{{COMMIT}}/out/vs/workbench/workbench.web.api.js"></script>
END_PROD_ONLY -->
<script>
require
([
'
vs/code/browser/workbench/workbench
'
],
function
()
{});
require
([
"
vs/code/browser/workbench/workbench
"
],
function
()
{})
</script>
</html>
src/browser/socket.ts
浏览文件 @
4aa15401
...
...
@@ -159,7 +159,7 @@ export class ReconnectingSocket {
const
socket
=
new
WebSocket
(
`
${
location
.
protocol
===
"
https:
"
?
"
wss
"
:
"
ws
"
}
://
${
location
.
host
}${
this
.
customPath
||
location
.
pathname
}${
location
.
search
?
`?
${
location
.
search
}
`
:
""
}
`
}
`
,
)
const
reject
=
():
void
=>
{
...
...
src/node/app/api.ts
浏览文件 @
4aa15401
...
...
@@ -68,7 +68,7 @@ export class ApiHttpProvider extends HttpProvider {
route
:
Route
,
request
:
http
.
IncomingMessage
,
socket
:
net
.
Socket
,
head
:
Buffer
head
:
Buffer
,
):
Promise
<
true
|
undefined
>
{
if
(
!
this
.
authenticated
(
request
))
{
throw
new
Error
(
"
not authenticated
"
)
...
...
@@ -120,7 +120,7 @@ export class ApiHttpProvider extends HttpProvider {
route
:
Route
,
request
:
http
.
IncomingMessage
,
socket
:
net
.
Socket
,
head
:
Buffer
head
:
Buffer
,
):
Promise
<
true
>
{
const
sessionId
=
route
.
requestPath
.
replace
(
/^
\/
/
,
""
)
logger
.
debug
(
"
connecting session
"
,
field
(
"
sessionId
"
,
sessionId
))
...
...
@@ -149,8 +149,8 @@ export class ApiHttpProvider extends HttpProvider {
Buffer
.
from
(
JSON
.
stringify
({
protocol
:
"
TODO
"
,
})
)
})
,
)
,
)
return
true
...
...
src/node/app/app.ts
浏览文件 @
4aa15401
...
...
@@ -63,7 +63,7 @@ export class MainHttpProvider extends HttpProvider {
base
:
this
.
base
(
route
),
logLevel
:
logger
.
level
,
},
(
app
&&
app
.
name
)
||
""
(
app
&&
app
.
name
)
||
""
,
)
}
...
...
@@ -80,11 +80,11 @@ export class MainHttpProvider extends HttpProvider {
.
replace
(
/{{APP_LIST:RUNNING}}/g
,
this
.
getAppRows
(
recent
.
running
))
.
replace
(
/{{APP_LIST:EDITORS}}/g
,
this
.
getAppRows
(
apps
.
filter
((
app
)
=>
app
.
categories
&&
app
.
categories
.
includes
(
"
Editor
"
)))
this
.
getAppRows
(
apps
.
filter
((
app
)
=>
app
.
categories
&&
app
.
categories
.
includes
(
"
Editor
"
)))
,
)
.
replace
(
/{{APP_LIST:OTHER}}/g
,
this
.
getAppRows
(
apps
.
filter
((
app
)
=>
!
app
.
categories
||
!
app
.
categories
.
includes
(
"
Editor
"
)))
this
.
getAppRows
(
apps
.
filter
((
app
)
=>
!
app
.
categories
||
!
app
.
categories
.
includes
(
"
Editor
"
)))
,
)
return
response
}
...
...
src/node/app/login.ts
浏览文件 @
4aa15401
...
...
@@ -109,7 +109,7 @@ export class LoginHttpProvider extends HttpProvider {
remoteAddress
:
request
.
connection
.
remoteAddress
,
userAgent
:
request
.
headers
[
"
user-agent
"
],
timestamp
:
Math
.
floor
(
new
Date
().
getTime
()
/
1000
),
})
})
,
)
throw
new
Error
(
"
Incorrect password
"
)
...
...
src/node/app/vscode.ts
浏览文件 @
4aa15401
...
...
@@ -102,7 +102,7 @@ export class VscodeHttpProvider extends HttpProvider {
"
Upgrade: websocket
"
,
"
Connection: Upgrade
"
,
`Sec-WebSocket-Accept:
${
reply
}
`
,
].
join
(
"
\r\n
"
)
+
"
\r\n\r\n
"
].
join
(
"
\r\n
"
)
+
"
\r\n\r\n
"
,
)
const
vscode
=
await
this
.
_vscode
...
...
@@ -146,7 +146,7 @@ export class VscodeHttpProvider extends HttpProvider {
const
response
=
await
this
.
getUtf8Resource
(
this
.
vsRootPath
,
route
.
requestPath
)
response
.
content
=
response
.
content
.
replace
(
/{{COMMIT}}/g
,
this
.
workbenchOptions
?
this
.
workbenchOptions
.
commit
:
""
this
.
workbenchOptions
?
this
.
workbenchOptions
.
commit
:
""
,
)
response
.
cache
=
true
return
response
...
...
@@ -186,7 +186,7 @@ export class VscodeHttpProvider extends HttpProvider {
settings
.
lastVisited
,
this
.
args
.
_
&&
this
.
args
.
_
.
length
>
0
?
{
url
:
this
.
args
.
_
[
0
]
}
:
undefined
,
],
remoteAuthority
remoteAuthority
,
)
const
[
response
,
options
]
=
await
Promise
.
all
([
await
this
.
getUtf8Resource
(
this
.
rootPath
,
"
src/browser/pages/vscode.html
"
),
...
...
@@ -229,7 +229,7 @@ export class VscodeHttpProvider extends HttpProvider {
*/
private
async
getFirstValidPath
(
startPaths
:
Array
<
{
url
?:
string
|
string
[];
workspace
?:
boolean
}
|
undefined
>
,
remoteAuthority
:
string
remoteAuthority
:
string
,
):
Promise
<
StartPath
|
undefined
>
{
for
(
let
i
=
0
;
i
<
startPaths
.
length
;
++
i
)
{
const
startPath
=
startPaths
[
i
]
...
...
src/node/cli.ts
浏览文件 @
4aa15401
...
...
@@ -92,13 +92,13 @@ export const optionDescriptions = (): string[] => {
long
:
k
.
length
>
prev
.
long
?
k
.
length
:
prev
.
long
,
short
:
v
.
short
&&
v
.
short
.
length
>
prev
.
short
?
v
.
short
.
length
:
prev
.
short
,
}),
{
short
:
0
,
long
:
0
}
{
short
:
0
,
long
:
0
}
,
)
return
entries
.
map
(
([
k
,
v
])
=>
`
${
"
"
.
repeat
(
widths
.
short
-
(
v
.
short
?
v
.
short
.
length
:
0
))}${
v
.
short
?
`-
${
v
.
short
}
`
:
"
"
}
--
${
k
}${
"
"
.
repeat
(
widths
.
long
-
k
.
length
)}
${
v
.
description
}${
typeof
v
.
type
===
"
object
"
?
` [
${
Object
.
values
(
v
.
type
).
join
(
"
,
"
)}
]`
:
""
}
`
widths
.
long
-
k
.
length
,
)}
${
v
.
description
}${
typeof
v
.
type
===
"
object
"
?
` [
${
Object
.
values
(
v
.
type
).
join
(
"
,
"
)}
]`
:
""
}
`
,
)
}
...
...
src/node/entry.ts
浏览文件 @
4aa15401
...
...
@@ -66,7 +66,7 @@ const main = async (args: Args): Promise<void> => {
logger
.
info
(
typeof
args
.
cert
===
"
string
"
?
` - Using provided certificate
${
args
[
"
cert-key
"
]
?
"
and key
"
:
""
}
for HTTPS`
:
` - Using generated certificate and key for HTTPS`
:
` - Using generated certificate and key for HTTPS`
,
)
}
else
{
logger
.
info
(
"
- Not serving HTTPS
"
)
...
...
src/node/http.ts
浏览文件 @
4aa15401
...
...
@@ -142,7 +142,7 @@ export abstract class HttpProvider {
route
:
Route
,
request
:
http
.
IncomingMessage
,
socket
:
net
.
Socket
,
head
:
Buffer
head
:
Buffer
,
):
Promise
<
true
|
undefined
>
/**
...
...
@@ -380,7 +380,7 @@ export class HttpServer {
cert
:
this
.
options
.
cert
&&
fs
.
readFileSync
(
this
.
options
.
cert
),
key
:
this
.
options
.
certKey
&&
fs
.
readFileSync
(
this
.
options
.
certKey
),
},
this
.
onRequest
this
.
onRequest
,
)
}
else
{
this
.
server
=
http
.
createServer
(
this
.
onRequest
)
...
...
@@ -420,7 +420,7 @@ export class HttpServer {
commit
:
this
.
options
.
commit
,
password
:
this
.
options
.
password
,
},
a1
a1
,
)
this
.
providers
.
set
(
`/
${
endpoint
}
`
,
p
)
return
p
...
...
src/node/util.ts
浏览文件 @
4aa15401
...
...
@@ -14,7 +14,7 @@ const getXdgDataDir = (): string => {
case
"
darwin
"
:
return
path
.
join
(
process
.
env
.
XDG_DATA_HOME
||
path
.
join
(
os
.
homedir
(),
"
Library/Application Support
"
),
"
code-server
"
"
code-server
"
,
)
default
:
return
path
.
join
(
process
.
env
.
XDG_DATA_HOME
||
path
.
join
(
os
.
homedir
(),
"
.local/share
"
),
"
code-server
"
)
...
...
src/node/wrapper.ts
浏览文件 @
4aa15401
...
...
@@ -76,7 +76,7 @@ export class IpcMain {
`
${
child
?
"
wrapper
"
:
"
inner process
"
}
${
process
.
pid
}
received message from
${
child
?
child
.
pid
:
this
.
parentPid
}
`
,
field
(
"
message
"
,
message
)
field
(
"
message
"
,
message
)
,
)
if
(
message
.
type
===
"
handshake
"
)
{
target
.
removeListener
(
"
message
"
,
onMessage
)
...
...
@@ -122,7 +122,7 @@ export const ipcMain = (): IpcMain => {
_ipcMain
=
new
IpcMain
(
typeof
process
.
env
.
CODE_SERVER_PARENT_PID
!==
"
undefined
"
?
parseInt
(
process
.
env
.
CODE_SERVER_PARENT_PID
)
:
undefined
:
undefined
,
)
}
return
_ipcMain
...
...
test/cli.test.ts
浏览文件 @
4aa15401
...
...
@@ -73,7 +73,7 @@ describe("cli", () => {
"
user-data-dir
"
:
path
.
resolve
(
"
bar
"
),
verbose
:
true
,
version
:
true
,
}
}
,
)
})
...
...
tsconfig.json
浏览文件 @
4aa15401
...
...
@@ -20,8 +20,5 @@
"rootDir"
:
"./src"
,
"typeRoots"
:
[
"./node_modules/@types"
,
"./typings"
]
},
"include"
:
[
"./src/**/*.ts"
,
"./src/**/*.tsx"
]
"include"
:
[
"./src/**/*.ts"
,
"./src/**/*.tsx"
]
}
typings/httpolyglot/index.d.ts
浏览文件 @
4aa15401
...
...
@@ -5,6 +5,6 @@ declare module "httpolyglot" {
function
createServer
(
requestListener
?:
(
req
:
http
.
IncomingMessage
,
res
:
http
.
ServerResponse
)
=>
void
):
http
.
Server
function
createServer
(
options
:
https
.
ServerOptions
,
requestListener
?:
(
req
:
http
.
IncomingMessage
,
res
:
http
.
ServerResponse
)
=>
void
requestListener
?:
(
req
:
http
.
IncomingMessage
,
res
:
http
.
ServerResponse
)
=>
void
,
):
https
.
Server
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录