Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
myhjmzy
code-server
提交
df3089f3
C
code-server
项目概览
myhjmzy
/
code-server
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
df3089f3
编写于
10月 07, 2020
作者:
A
Anmol Sethi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
coder-cloud: Use consolidated bind command
上级
7cc16ceb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
9 addition
and
46 deletion
+9
-46
src/node/cli.ts
src/node/cli.ts
+2
-2
src/node/coder-cloud.ts
src/node/coder-cloud.ts
+5
-39
src/node/entry.ts
src/node/entry.ts
+2
-5
未找到文件。
src/node/cli.ts
浏览文件 @
df3089f3
...
...
@@ -48,7 +48,7 @@ export interface Args extends VsArgs {
readonly
"
reuse-window
"
?:
boolean
readonly
"
new-window
"
?:
boolean
readonly
"
coder-bind
"
?:
s
tring
readonly
"
coder-bind
"
?:
OptionalS
tring
}
interface
Option
<
T
>
{
...
...
@@ -160,7 +160,7 @@ const options: Options<Required<Args>> = {
verbose
:
{
type
:
"
boolean
"
,
short
:
"
vvv
"
,
description
:
"
Enable verbose logging.
"
},
"
coder-bind
"
:
{
type
:
"
string
"
,
type
:
OptionalString
,
description
:
`
Securely bind code-server via Coder Cloud with the passed name. You'll get a URL like
https://myname.coder-cloud.com at which you can easily access your code-server instance.
...
...
src/node/coder-cloud.ts
浏览文件 @
df3089f3
...
...
@@ -5,8 +5,8 @@ import split2 from "split2"
const
coderCloudAgent
=
path
.
resolve
(
__dirname
,
"
../../lib/coder-cloud-agent
"
)
export
async
function
coderCloudBind
(
serverName
:
string
):
Promise
<
void
>
{
const
agent
=
spawn
(
coderCloudAgent
,
[
"
link
"
,
serverName
]
,
{
function
runAgent
(...
args
:
string
[]
):
Promise
<
void
>
{
const
agent
=
spawn
(
coderCloudAgent
,
args
,
{
stdio
:
[
"
inherit
"
,
"
inherit
"
,
"
pipe
"
],
})
...
...
@@ -30,43 +30,9 @@ export async function coderCloudBind(serverName: string): Promise<void> {
})
}
export
function
coderCloud
Proxy
(
addr
:
string
)
{
export
function
coderCloud
Bind
(
csAddr
:
string
,
serverName
=
""
):
Promise
<
void
>
{
// addr needs to be in host:port format.
// So we trim the protocol.
addr
=
addr
.
replace
(
/^https
?
:
\/\/
/
,
""
)
const
_proxy
=
async
()
=>
{
const
agent
=
spawn
(
coderCloudAgent
,
[
"
proxy
"
,
"
--code-server-addr
"
,
addr
],
{
stdio
:
[
"
inherit
"
,
"
inherit
"
,
"
pipe
"
],
})
agent
.
stderr
.
pipe
(
split2
()).
on
(
"
data
"
,
(
line
)
=>
{
line
=
line
.
replace
(
/^
[
0-9-
]
+
[
0-9:
]
+
[^
]
+
\t
/
,
""
)
logger
.
info
(
line
)
})
return
new
Promise
((
res
,
rej
)
=>
{
agent
.
on
(
"
error
"
,
rej
)
agent
.
on
(
"
close
"
,
(
code
)
=>
{
if
(
code
!==
0
)
{
rej
({
message
:
`coder cloud agent exited with
${
code
}
`
,
})
return
}
res
()
})
})
}
const
proxy
=
async
()
=>
{
try
{
await
_proxy
()
}
catch
(
err
)
{
logger
.
error
(
err
.
message
)
}
setTimeout
(
proxy
,
3000
)
}
proxy
()
csAddr
=
csAddr
.
replace
(
/^https
?
:
\/\/
/
,
""
)
return
runAgent
(
"
bind
"
,
`--code-server-addr=
${
csAddr
}
`
,
serverName
)
}
src/node/entry.ts
浏览文件 @
df3089f3
...
...
@@ -12,7 +12,7 @@ import { StaticHttpProvider } from "./app/static"
import
{
UpdateHttpProvider
}
from
"
./app/update
"
import
{
VscodeHttpProvider
}
from
"
./app/vscode
"
import
{
Args
,
bindAddrFromAllSources
,
optionDescriptions
,
parse
,
readConfigFile
,
setDefaults
}
from
"
./cli
"
import
{
coderCloudBind
,
coderCloudProxy
}
from
"
./coder-cloud
"
import
{
coderCloudBind
}
from
"
./coder-cloud
"
import
{
AuthType
,
HttpServer
,
HttpServerOptions
}
from
"
./http
"
import
{
loadPlugins
}
from
"
./plugin
"
import
{
generateCertificate
,
hash
,
humanPath
,
open
}
from
"
./util
"
...
...
@@ -143,11 +143,8 @@ const main = async (args: Args, cliArgs: Args, configArgs: Args): Promise<void>
}
if
(
args
[
"
coder-bind
"
])
{
try
{
logger
.
info
(
`binding code-server to the cloud with name
${
args
[
"
coder-bind
"
]}
`
)
await
coderCloudBind
(
args
[
"
coder-bind
"
])
coderCloudProxy
(
serverAddress
!
)
await
coderCloudBind
(
serverAddress
!
,
args
[
"
coder-bind
"
].
value
)
}
catch
(
err
)
{
logger
.
error
(
err
.
message
)
ipcMain
().
exit
(
1
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录