frontend: also print whois client output on error

This commit is contained in:
Lan Tian 2023-09-08 18:22:31 -07:00
parent f999d47d9f
commit 09405cdb38
No known key found for this signature in database
GPG Key ID: 04E66B6B25A0862B

View File

@ -25,13 +25,14 @@ func whois(s string) string {
cmd := exec.Command(args[0], args[1:]...) cmd := exec.Command(args[0], args[1:]...)
output, err := cmd.CombinedOutput() output, err := cmd.CombinedOutput()
if err != nil {
return err.Error()
}
if len(output) > 65535 { if len(output) > 65535 {
output = output[:65535] output = output[:65535]
} }
return string(output) if err != nil {
return err.Error() + "\n" + string(output)
} else {
return string(output)
}
} else { } else {
buf := make([]byte, 65536) buf := make([]byte, 65536)
@ -50,7 +51,7 @@ func whois(s string) string {
n, err := io.ReadFull(conn, buf) n, err := io.ReadFull(conn, buf)
if err != nil && err != io.EOF && err != io.ErrUnexpectedEOF { if err != nil && err != io.EOF && err != io.ErrUnexpectedEOF {
return err.Error() return err.Error() + "\n" + string(buf[:n])
} }
return string(buf[:n]) return string(buf[:n])
} }