Skip to content

Commit

Permalink
help windows user to open the browser
Browse files Browse the repository at this point in the history
  • Loading branch information
zyxkad committed Mar 5, 2024
1 parent 37c1405 commit 4bfa831
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 4 additions & 4 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,19 @@ func (cr *Cluster) GetHandler() http.Handler {
}
if host != "" && len(cr.publicHosts) > 0 {
host = strings.ToLower(host)
ok := false
needRed := true
for _, h := range cr.publicHosts { // cr.publicHosts are already lower case
if h, ok := strings.CutPrefix(h, "*."); ok {
if strings.HasSuffix(host, h) {
ok = true
needRed = false
break
}
} else if host == h {
ok = true
needRed = false
break
}
}
if !ok {
if needRed {
host := ""
for _, h := range cr.publicHosts {
if !strings.HasSuffix(h, "*.") {
Expand Down
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"strings"
"syscall"
"time"
"os/exec"

"runtime/pprof"

Expand Down Expand Up @@ -115,6 +116,8 @@ func main() {
log.Errorf("Program exiting with code %d", exitCode)
log.Error("Please read https://github.com/LiterMC/go-openbmclapi?tab=readme-ov-file#faq before report your issue")
if runtime.GOOS == "windows" {
log.Warnf("Detected that you are in windows environment, we are helping you to open the browser")
exec.Command("explorer", "https://github.com/LiterMC/go-openbmclapi?tab=readme-ov-file#faq").Start()
time.Sleep(time.Hour)
}
}
Expand Down

0 comments on commit 4bfa831

Please sign in to comment.