Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gzupanda
code-server
提交
13534fa0
C
code-server
项目概览
gzupanda
/
code-server
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
code-server
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
13534fa0
编写于
3月 23, 2020
作者:
A
Asher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add proxy-domain flag
This will be used for proxying ports.
上级
37299abc
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
37 addition
and
0 deletion
+37
-0
src/node/cli.ts
src/node/cli.ts
+2
-0
src/node/entry.ts
src/node/entry.ts
+18
-0
src/node/http.ts
src/node/http.ts
+1
-0
test/cli.test.ts
test/cli.test.ts
+16
-0
未找到文件。
src/node/cli.ts
浏览文件 @
13534fa0
...
...
@@ -39,6 +39,7 @@ export interface Args extends VsArgs {
readonly
"
install-extension
"
?:
string
[]
readonly
"
show-versions
"
?:
boolean
readonly
"
uninstall-extension
"
?:
string
[]
readonly
"
proxy-domain
"
?:
string
[]
readonly
locale
?:
string
readonly
_
:
string
[]
}
...
...
@@ -111,6 +112,7 @@ const options: Options<Required<Args>> = {
"
install-extension
"
:
{
type
:
"
string[]
"
,
description
:
"
Install or update a VS Code extension by id or vsix.
"
},
"
uninstall-extension
"
:
{
type
:
"
string[]
"
,
description
:
"
Uninstall a VS Code extension by id.
"
},
"
show-versions
"
:
{
type
:
"
boolean
"
,
description
:
"
Show VS Code extension versions.
"
},
"
proxy-domain
"
:
{
type
:
"
string[]
"
,
description
:
"
Domain used for proxying ports.
"
},
locale
:
{
type
:
"
string
"
},
log
:
{
type
:
LogLevel
},
...
...
src/node/entry.ts
浏览文件 @
13534fa0
...
...
@@ -35,6 +35,14 @@ const main = async (args: Args): Promise<void> => {
const
auth
=
args
.
auth
||
AuthType
.
Password
const
originalPassword
=
auth
===
AuthType
.
Password
&&
(
process
.
env
.
PASSWORD
||
(
await
generatePassword
()))
/**
* Domains can be in the form `coder.com` or `*.coder.com`. Either way,
* `[number].coder.com` will be proxied to `number`.
*/
const
normalizeProxyDomains
=
(
domains
?:
string
[]):
string
[]
=>
{
return
domains
?
domains
.
map
((
d
)
=>
d
.
replace
(
/^
\*\.
/
,
""
)).
filter
((
d
,
i
)
=>
domains
.
indexOf
(
d
)
===
i
)
:
[]
}
// Spawn the main HTTP server.
const
options
:
HttpServerOptions
=
{
auth
,
...
...
@@ -42,6 +50,7 @@ const main = async (args: Args): Promise<void> => {
host
:
args
.
host
||
(
args
.
auth
===
AuthType
.
Password
&&
typeof
args
.
cert
!==
"
undefined
"
?
"
0.0.0.0
"
:
"
localhost
"
),
password
:
originalPassword
?
hash
(
originalPassword
)
:
undefined
,
port
:
typeof
args
.
port
!==
"
undefined
"
?
args
.
port
:
process
.
env
.
PORT
?
parseInt
(
process
.
env
.
PORT
,
10
)
:
8080
,
proxyDomains
:
normalizeProxyDomains
(
args
[
"
proxy-domain
"
]),
socket
:
args
.
socket
,
...(
args
.
cert
&&
!
args
.
cert
.
value
?
await
generateCertificate
()
...
...
@@ -91,6 +100,15 @@ const main = async (args: Args): Promise<void> => {
logger
.
info
(
"
- Not serving HTTPS
"
)
}
if
(
options
.
proxyDomains
&&
options
.
proxyDomains
.
length
===
1
)
{
logger
.
info
(
` - Proxying *.
${
options
.
proxyDomains
[
0
]}
`
)
}
else
if
(
options
.
proxyDomains
&&
options
.
proxyDomains
.
length
>
1
)
{
logger
.
info
(
"
- Proxying the following domains:
"
)
options
.
proxyDomains
.
forEach
((
domain
)
=>
{
logger
.
info
(
` - *.
${
domain
}
`
)
})
}
logger
.
info
(
`Automatic updates are
${
update
.
enabled
?
"
enabled
"
:
"
disabled
"
}
`
)
let
sshHostKey
=
args
[
"
ssh-host-key
"
]
...
...
src/node/http.ts
浏览文件 @
13534fa0
...
...
@@ -99,6 +99,7 @@ export interface HttpServerOptions {
readonly
commit
?:
string
readonly
host
?:
string
readonly
password
?:
string
readonly
proxyDomains
?:
string
[]
readonly
port
?:
number
readonly
socket
?:
string
}
...
...
test/cli.test.ts
浏览文件 @
13534fa0
...
...
@@ -117,6 +117,7 @@ describe("cli", () => {
assert
.
throws
(()
=>
parse
([
"
--auth=
"
,
"
--log=debug
"
]),
/--auth requires a value/
)
assert
.
throws
(()
=>
parse
([
"
--auth
"
,
"
--log
"
]),
/--auth requires a value/
)
assert
.
throws
(()
=>
parse
([
"
--auth
"
,
"
--invalid
"
]),
/--auth requires a value/
)
assert
.
throws
(()
=>
parse
([
"
--ssh-host-key
"
]),
/--ssh-host-key requires a value/
)
})
it
(
"
should error if value is invalid
"
,
()
=>
{
...
...
@@ -160,4 +161,19 @@ describe("cli", () => {
auth
:
"
none
"
,
})
})
it
(
"
should support repeatable flags
"
,
()
=>
{
assert
.
deepEqual
(
parse
([
"
--proxy-domain
"
,
"
*.coder.com
"
]),
{
_
:
[],
"
extensions-dir
"
:
path
.
join
(
xdgLocalDir
,
"
extensions
"
),
"
user-data-dir
"
:
xdgLocalDir
,
"
proxy-domain
"
:
[
"
*.coder.com
"
],
})
assert
.
deepEqual
(
parse
([
"
--proxy-domain
"
,
"
*.coder.com
"
,
"
--proxy-domain
"
,
"
test.com
"
]),
{
_
:
[],
"
extensions-dir
"
:
path
.
join
(
xdgLocalDir
,
"
extensions
"
),
"
user-data-dir
"
:
xdgLocalDir
,
"
proxy-domain
"
:
[
"
*.coder.com
"
,
"
test.com
"
],
})
})
})
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录