@@ -21,6 +21,8 @@ import (
2121 "strings"
2222 "time"
2323
24+ "github.com/Sirupsen/logrus"
25+ "github.com/moul/gotty-client"
2426 "github.com/scaleway/scaleway-cli/pkg/sshcommand"
2527 log "github.com/scaleway/scaleway-cli/vendor/github.com/Sirupsen/logrus"
2628)
@@ -179,38 +181,17 @@ func RemoveDuplicates(elements []string) []string {
179181 return result
180182}
181183
182- const termjsBin string = "termjs-cli"
183-
184- // AttachToSerial tries to connect to server serial using 'term.js-cli' and fallback with a help message
184+ // AttachToSerial tries to connect to server serial using 'gotty-client' and fallback with a help message
185185func AttachToSerial (serverID string , apiToken string , attachStdin bool ) error {
186- termjsURL := fmt .Sprintf ("https://tty.cloud.online.net?server_id =%s&type=serial&auth_token= %s" , serverID , apiToken )
186+ URL := fmt .Sprintf ("https://tty.scaleway.com/v2/?arg =%s&arg= %s" , apiToken , serverID )
187187
188- args := []string {}
189- if ! attachStdin {
190- args = append (args , "--no-stdin" )
191- }
192- args = append (args , termjsURL )
193- log .Debugf ("Executing: %s %v" , termjsBin , args )
194- // FIXME: check if termjs-cli is installed
195- spawn := exec .Command (termjsBin , args ... )
196- spawn .Stdout = os .Stdout
197- spawn .Stdin = os .Stdin
198- spawn .Stderr = os .Stderr
199- err := spawn .Run ()
188+ logrus .Debug ("Connection to " , URL )
189+ gottycli , err := gottyclient .NewClient (URL )
200190 if err != nil {
201- log .Warnf (`
202- You need to install '%s' from https://github.com/moul/term.js-cli
203-
204- npm install -g term.js-cli
205-
206- However, you can access your serial using a web browser:
207-
208- %s
209-
210- ` , termjsBin , termjsURL )
211191 return err
212192 }
213- return nil
193+ fmt .Println ("You are connected, type 'Ctrl+q' to quit." )
194+ return gottycli .Loop ()
214195}
215196
216197func SSHGetFingerprint (key string ) (string , error ) {
0 commit comments