Adds comments and alternate case for errors

This commit is contained in:
sloumdrone 2019-09-09 21:21:29 -07:00
parent fea430485f
commit 450e73f76c
2 changed files with 9 additions and 3 deletions

View File

@ -100,12 +100,18 @@ func Visit(addr, openhttp string) (View, error) {
return View{}, fmt.Errorf("")
}
} else if u.Gophertype == "8" || u.Gophertype == "T" {
// Case for telnet links
c := exec.Command("telnet", u.Host, u.Port)
c.Stdin = os.Stdin
c.Stdout = os.Stdout
c.Stderr = os.Stderr
// Clear the screen and position the cursor at the top left
fmt.Print("\033[2J\033[0;0H")
c.Run()
err := c.Run()
if err != nil {
return View{}, fmt.Errorf("Telnet connection error")
}
return View{}, fmt.Errorf("Telnet session terminated")
}

View File

@ -164,7 +164,7 @@ func goToURL(u string) error {
v, err := gopher.Visit(u, options["openhttp"])
if err != nil {
quickMessage("Loading...", true)
if err.Error() == "Telnet session terminated" {
if err.Error() == "Telnet session terminated" || err.Error() == "Telnet connection error" {
screen.ReflashScreen(true)
}
return err
@ -197,7 +197,7 @@ func goToLink(l string) error {
v, err := gopher.Visit(linkurl, options["openhttp"])
if err != nil {
quickMessage("Loading...", true)
if err.Error() == "Telnet session terminated" {
if err.Error() == "Telnet session terminated" || err.Error() == "Telnet connection error" {
screen.ReflashScreen(true)
}
return err