@@ -12,7 +12,7 @@ import { StaticHttpProvider } from "./app/static"
12
12
import { UpdateHttpProvider } from "./app/update"
13
13
import { VscodeHttpProvider } from "./app/vscode"
14
14
import { Args , bindAddrFromAllSources , optionDescriptions , parse , readConfigFile , setDefaults } from "./cli"
15
- import { coderCloudLink , coderCloudProxy } from "./coder-cloud"
15
+ import { coderCloudBind , coderCloudProxy } from "./coder-cloud"
16
16
import { AuthType , HttpServer , HttpServerOptions } from "./http"
17
17
import { loadPlugins } from "./plugin"
18
18
import { generateCertificate , hash , humanPath , open } from "./util"
@@ -36,13 +36,15 @@ const version = pkg.version || "development"
36
36
const commit = pkg . commit || "development"
37
37
38
38
const main = async ( args : Args , cliArgs : Args , configArgs : Args ) : Promise < void > => {
39
- if ( args [ "coder-link " ] ) {
40
- // If we're being exposed to the cloud, we listen on a random address.
39
+ if ( args [ "coder-bind " ] ) {
40
+ // If we're being exposed to the cloud, we listen on a random address and disable auth .
41
41
args = {
42
42
...args ,
43
43
host : "localhost" ,
44
44
port : 0 ,
45
+ auth : AuthType . None ,
45
46
}
47
+ logger . info ( "coder-bind: disabling auth and listening on random localhost port" )
46
48
}
47
49
48
50
if ( ! args . auth ) {
@@ -132,25 +134,19 @@ const main = async (args: Args, cliArgs: Args, configArgs: Args): Promise<void>
132
134
httpServer . proxyDomains . forEach ( ( domain ) => logger . info ( ` - *.${ domain } ` ) )
133
135
}
134
136
135
- coderCloudProxy ( serverAddress ! )
136
-
137
137
if ( serverAddress && ! options . socket && args . open ) {
138
138
// The web socket doesn't seem to work if browsing with 0.0.0.0.
139
139
const openAddress = serverAddress . replace ( / : \/ \/ 0 .0 .0 .0 / , "://localhost" )
140
140
await open ( openAddress ) . catch ( console . error )
141
141
logger . info ( `Opened ${ openAddress } ` )
142
142
}
143
143
144
- if ( args [ "coder-link" ] ) {
145
- if ( ! args [ "coder-link" ] . value ) {
146
- logger . error ( "You must pass a name to link with coder cloud. See --help" )
147
- process . exit ( 1 )
148
- }
149
-
150
- logger . info ( `linking code-server to the cloud with name ${ args [ "coder-link" ] . value } ` )
144
+ if ( args [ "coder-bind" ] ) {
145
+ logger . info ( `linking code-server to the cloud with name ${ args [ "coder-bind" ] } ` )
151
146
152
147
try {
153
- await coderCloudLink ( args [ "coder-link" ] . value )
148
+ await coderCloudBind ( args [ "coder-bind" ] )
149
+ coderCloudProxy ( serverAddress ! )
154
150
} catch ( err ) {
155
151
logger . error ( err . message )
156
152
process . exit ( 1 )
0 commit comments