Compare commits
No commits in common. "10c80effcebb8adbe4a2a9928dbb0a7da1d76853" and "7b06c1b7821d766f375f3fedb87ad981ae92dac7" have entirely different histories.
10c80effce
...
7b06c1b782
4
Makefile
4
Makefile
|
@ -17,10 +17,6 @@ build:
|
||||||
rm -rf ${BINARY_DIR}
|
rm -rf ${BINARY_DIR}
|
||||||
mkdir ${BINARY_DIR}
|
mkdir ${BINARY_DIR}
|
||||||
env GOOS=linux CGO_ENABLED=0 GOARCH=amd64 go build -o ./${BINARY_DIR}/${BINARY_NAME} main.go
|
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:
|
build_freebsd:
|
||||||
rm -rf ${BINARY_DIR}
|
rm -rf ${BINARY_DIR}
|
||||||
mkdir ${BINARY_DIR}
|
mkdir ${BINARY_DIR}
|
||||||
|
|
|
@ -25,14 +25,14 @@ var (
|
||||||
wlanEnableID = "#wlanEnable"
|
wlanEnableID = "#wlanEnable"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewSwitcher(remoteControlBrowserUrl string, config *cfg.Config) switcher {
|
func NewSwitcher(remoteControlBrowserUrl string, config *cfg.Config) *switcher {
|
||||||
return switcher{
|
return &switcher{
|
||||||
remoteControlBrowserUrl: remoteControlBrowserUrl,
|
remoteControlBrowserUrl: remoteControlBrowserUrl,
|
||||||
config: config,
|
config: config,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s switcher) SwitchWIFI() error {
|
func (s *switcher) SwitchWIFI() error {
|
||||||
browser := rod.New().
|
browser := rod.New().
|
||||||
ControlURL(s.remoteControlBrowserUrl).
|
ControlURL(s.remoteControlBrowserUrl).
|
||||||
MustConnect().
|
MustConnect().
|
||||||
|
@ -56,7 +56,7 @@ func (s switcher) SwitchWIFI() error {
|
||||||
userpassword.MustInput(s.config.Password)
|
userpassword.MustInput(s.config.Password)
|
||||||
log.Println(userpasswordID, "DONE")
|
log.Println(userpasswordID, "DONE")
|
||||||
|
|
||||||
login, err := page.Element(`input[value="` + loginText + `"]`)
|
login, err := page.Element(`input[value=` + loginText + `"]`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("page.Element %s: %s", loginText, err)
|
return fmt.Errorf("page.Element %s: %s", loginText, err)
|
||||||
}
|
}
|
||||||
|
|
6
main.go
6
main.go
|
@ -15,7 +15,7 @@ import (
|
||||||
"github.com/ysmood/leakless"
|
"github.com/ysmood/leakless"
|
||||||
)
|
)
|
||||||
|
|
||||||
var sw pkgswitcher.SwitcherIface
|
var switcherIface pkgswitcher.SwitcherIface
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
envFile := ""
|
envFile := ""
|
||||||
|
@ -40,7 +40,6 @@ func main() {
|
||||||
var lc *launcher.Launcher
|
var lc *launcher.Launcher
|
||||||
var remoteControlBrowserURL string
|
var remoteControlBrowserURL string
|
||||||
|
|
||||||
config.Bin = ""
|
|
||||||
if config.Bin != "" {
|
if config.Bin != "" {
|
||||||
lc = launcher.New().Bin(config.Bin)
|
lc = launcher.New().Bin(config.Bin)
|
||||||
remoteControlBrowserURL = lc.MustLaunch()
|
remoteControlBrowserURL = lc.MustLaunch()
|
||||||
|
@ -58,9 +57,8 @@ func main() {
|
||||||
remoteControlBrowserURL = launcher.MustResolveURL(<-parser.URL)
|
remoteControlBrowserURL = launcher.MustResolveURL(<-parser.URL)
|
||||||
}
|
}
|
||||||
|
|
||||||
sw = switcher.NewSwitcher(remoteControlBrowserURL, config)
|
sw := switcher.NewSwitcher(remoteControlBrowserURL, config)
|
||||||
if err := sw.SwitchWIFI(); err != nil {
|
if err := sw.SwitchWIFI(); err != nil {
|
||||||
log.Println("sw.SwitchWIFI", err)
|
|
||||||
err := retry(5, time.Second*5, sw.SwitchWIFI)
|
err := retry(5, time.Second*5, sw.SwitchWIFI)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln("couldn't retry:", err)
|
log.Fatalln("couldn't retry:", err)
|
||||||
|
|
Loading…
Reference in New Issue