fix port scanner, add banner

This commit is contained in:
kayos@tcp.direct 2023-01-15 04:56:04 -08:00
parent e0cb7c11b3
commit 4f3e770e17
Signed by: kayos
GPG Key ID: 4B841471B4BEE979
4 changed files with 22 additions and 6 deletions

View File

@ -93,6 +93,7 @@ func executor(cmd string) {
}
bcmd, ok := Commands[args[0]]
if !ok {
log.Error().Msg("invalid command: " + args[0])
return
}
br, ok := ziggy.Lucifer.Bridges[sel.Bridge]

View File

@ -127,7 +127,7 @@ func GetControllers(bridges []config.KnownBridge) (br []*Bridge) {
log.Error().Str("caller", lightConfig.Hostname).Err(err).Msg("unsuccessful connection")
continue
}
c.Log().Info().Msg("successful connection")
c.Log().Info().Str("caller", strings.Split(lightConfig.Hostname, "http://")[1]).Msg("connected")
br = append(br, c)
}
return

View File

@ -80,7 +80,7 @@ func enumerateBridge(a net.Addr, ctx context.Context) interface{} {
log.Warn().Err(err).Msg("failed to read response")
return nil
}
if !strings.Contains(string(ret), "Philips hue") || !strings.Contains(string(ret), "bridgeid") {
if !strings.Contains(string(ret), "factorynew") || !strings.Contains(string(ret), "bridgeid") {
log.Debug().Msgf("%s does not appear to be a hue bridge", a.String())
return nil
}

23
main.go
View File

@ -3,16 +3,19 @@ package main
import (
"context"
"fmt"
"io"
"os"
"strings"
"time"
"git.tcp.direct/kayos/common/squish"
"github.com/amimof/huego"
"github.com/manifoldco/promptui"
"github.com/rs/zerolog"
"git.tcp.direct/kayos/ziggs/internal/cli"
"git.tcp.direct/kayos/ziggs/internal/common"
config2 "git.tcp.direct/kayos/ziggs/internal/config"
"git.tcp.direct/kayos/ziggs/internal/config"
"git.tcp.direct/kayos/ziggs/internal/data"
"git.tcp.direct/kayos/ziggs/internal/ziggy"
)
@ -21,10 +24,22 @@ var (
log *zerolog.Logger
)
const banner = "H4sIAAAAAAACA+OSjjY2tjYxyH00pefRlAYwmiAdbZALwgookmtwyjRQLmOQyyUdbYnukhmoeg2NwSyYsiagoDmIqYCkDFkSQ8caShROwe5oqGaYPHZXg2W34JZqoIYU0DkA2WCqGc8BAAA="
func init() {
config2.Init()
log = config2.StartLogger()
log.Info().Msg("Logger started")
bnr, _ := squish.UnpackStr(banner)
_, _ = io.Copy(os.Stdout, strings.NewReader(bnr))
compileTime, Version := common.Version()
if Version == "" {
Version = "DEVEL"
}
if compileTime == "" {
compileTime = time.Now().Format(time.RFC3339)
}
config.Init()
log = config.StartLogger()
log.Trace().Msg("Logger started")
log.Info().Str("version", Version).Str("compileTime", compileTime).Send()
if len(os.Args) < 1 {
return
}