Compare commits

..

2 Commits

Author SHA1 Message Date
Urko 10c80effce feat: add build for raspi 2023-03-07 23:07:29 +01:00
Urko b86fc071ec fix bug missing " 2023-03-07 23:07:20 +01:00
3 changed files with 12 additions and 6 deletions

View File

@ -17,6 +17,10 @@ build:
rm -rf ${BINARY_DIR}
mkdir ${BINARY_DIR}
env GOOS=linux CGO_ENABLED=0 GOARCH=amd64 go build -o ./${BINARY_DIR}/${BINARY_NAME} main.go
build_raspi:
rm -rf ${BINARY_DIR}
mkdir ${BINARY_DIR}
env GOOS=linux CGO_ENABLED=0 GOARCH=arm64 go build -o ./${BINARY_DIR}/${BINARY_NAME} main.go
build_freebsd:
rm -rf ${BINARY_DIR}
mkdir ${BINARY_DIR}

View File

@ -25,14 +25,14 @@ var (
wlanEnableID = "#wlanEnable"
)
func NewSwitcher(remoteControlBrowserUrl string, config *cfg.Config) *switcher {
return &switcher{
func NewSwitcher(remoteControlBrowserUrl string, config *cfg.Config) switcher {
return switcher{
remoteControlBrowserUrl: remoteControlBrowserUrl,
config: config,
}
}
func (s *switcher) SwitchWIFI() error {
func (s switcher) SwitchWIFI() error {
browser := rod.New().
ControlURL(s.remoteControlBrowserUrl).
MustConnect().
@ -56,7 +56,7 @@ func (s *switcher) SwitchWIFI() error {
userpassword.MustInput(s.config.Password)
log.Println(userpasswordID, "DONE")
login, err := page.Element(`input[value=` + loginText + `"]`)
login, err := page.Element(`input[value="` + loginText + `"]`)
if err != nil {
return fmt.Errorf("page.Element %s: %s", loginText, err)
}

View File

@ -15,7 +15,7 @@ import (
"github.com/ysmood/leakless"
)
var switcherIface pkgswitcher.SwitcherIface
var sw pkgswitcher.SwitcherIface
func main() {
envFile := ""
@ -40,6 +40,7 @@ func main() {
var lc *launcher.Launcher
var remoteControlBrowserURL string
config.Bin = ""
if config.Bin != "" {
lc = launcher.New().Bin(config.Bin)
remoteControlBrowserURL = lc.MustLaunch()
@ -57,8 +58,9 @@ func main() {
remoteControlBrowserURL = launcher.MustResolveURL(<-parser.URL)
}
sw := switcher.NewSwitcher(remoteControlBrowserURL, config)
sw = switcher.NewSwitcher(remoteControlBrowserURL, config)
if err := sw.SwitchWIFI(); err != nil {
log.Println("sw.SwitchWIFI", err)
err := retry(5, time.Second*5, sw.SwitchWIFI)
if err != nil {
log.Fatalln("couldn't retry:", err)