mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
parent
7ab48aff70
commit
cd9c7f58d8
14
src/runtime/http/connection.go
Normal file
14
src/runtime/http/connection.go
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
package http
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// if we can connect to google within 200ms, we are connected
|
||||||
|
// otherwise, let's consider being offline
|
||||||
|
func IsConnected() bool {
|
||||||
|
timeout := 200 * time.Millisecond
|
||||||
|
_, err := net.DialTimeout("tcp", "google.com:80", timeout)
|
||||||
|
return err == nil
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/jandedobbeleer/oh-my-posh/src/build"
|
"github.com/jandedobbeleer/oh-my-posh/src/build"
|
||||||
"github.com/jandedobbeleer/oh-my-posh/src/runtime"
|
"github.com/jandedobbeleer/oh-my-posh/src/runtime"
|
||||||
|
"github.com/jandedobbeleer/oh-my-posh/src/runtime/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
type release struct {
|
type release struct {
|
||||||
|
@ -67,6 +68,10 @@ func Notice(env runtime.Environment, force bool) (string, bool) {
|
||||||
return "", false
|
return "", false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !http.IsConnected() {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
|
||||||
// never validate when we install using the Windows Store
|
// never validate when we install using the Windows Store
|
||||||
if env.Getenv("POSH_INSTALLER") == "ws" {
|
if env.Getenv("POSH_INSTALLER") == "ws" {
|
||||||
return "", false
|
return "", false
|
||||||
|
|
Loading…
Reference in a new issue