First commit
Этот коммит содержится в:
Коммит
6c887dea46
21
LICENSE.txt
Обычный файл
21
LICENSE.txt
Обычный файл
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Igor V Belousov
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
48
README.md
Обычный файл
48
README.md
Обычный файл
@ -0,0 +1,48 @@
|
||||
IP Checker
|
||||
==========
|
||||
|
||||
This program check modify IPv4 address and send notification.
|
||||
|
||||
Only windows platform.
|
||||
Only for me. ;-)
|
||||
|
||||
Build
|
||||
-----
|
||||
|
||||
```cmd
|
||||
go get github.com/akavel/rsrc
|
||||
|
||||
rsrc -manifest ip_checker.manifest.txt -ico icon.ico -o rsrc.syso
|
||||
|
||||
go build -ldflags="-H windowsgui -s -w"
|
||||
```
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
### Icon
|
||||
Icon made by <a href="http://www.freepik.com" title="Freepik">Freepik</a> from <a href="http://www.flaticon.com" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a>
|
||||
|
||||
### Program
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Igor V Belousov
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
Двоичные данные
icon.ico
Обычный файл
Двоичные данные
icon.ico
Обычный файл
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 114 KiB |
20
ip_checker.manifest.txt
Обычный файл
20
ip_checker.manifest.txt
Обычный файл
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
|
||||
<assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="ip_checker" type="win32"/>
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
<asmv3:application>
|
||||
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
|
||||
<dpiAware>true</dpiAware>
|
||||
</asmv3:windowsSettings>
|
||||
</asmv3:application>
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- Windows 10 -->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
||||
</application>
|
||||
</compatibility>
|
||||
</assembly>
|
106
main.go
Обычный файл
106
main.go
Обычный файл
@ -0,0 +1,106 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/lxn/walk"
|
||||
"github.com/marcsauter/single"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
func get_ip() (string, error) {
|
||||
resp, err := http.Get("https://4.ifcfg.me/ip")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
ip := fmt.Sprintf("%s", body)
|
||||
return ip, err
|
||||
}
|
||||
|
||||
var old_ip string
|
||||
|
||||
func main() {
|
||||
single_proc := single.New("name")
|
||||
single_proc.Lock()
|
||||
defer single_proc.Unlock()
|
||||
|
||||
mw, err := walk.NewMainWindow()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
icon, err := walk.NewIconFromResourceId(9)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
ni, err := walk.NewNotifyIcon()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer ni.Dispose()
|
||||
|
||||
if err := ni.SetIcon(icon); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
exitAction := walk.NewAction()
|
||||
if err := exitAction.SetText("E&xit"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
exitAction.Triggered().Attach(func() { walk.App().Exit(0) })
|
||||
if err := ni.ContextMenu().Actions().Add(exitAction); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if err := ni.SetVisible(true); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
go func() {
|
||||
first_loop := true
|
||||
for first_loop {
|
||||
ip, ip_err := get_ip()
|
||||
if ip_err == nil {
|
||||
first_loop = false
|
||||
old_ip = ip
|
||||
if err := ni.ShowCustom(
|
||||
"IP Checker",
|
||||
" Current IP is "+old_ip); err != nil {
|
||||
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
go func() {
|
||||
for {
|
||||
time.Sleep(time.Second * 60)
|
||||
ip, ip_err := get_ip()
|
||||
if ip_err == nil {
|
||||
if old_ip != ip {
|
||||
if err := ni.ShowCustom(
|
||||
"IP Checker",
|
||||
" Old IP - "+old_ip+" New IP - "+ip); err != nil {
|
||||
|
||||
log.Fatal(err)
|
||||
}
|
||||
old_ip = ip
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}()
|
||||
|
||||
mw.Run()
|
||||
}
|
Двоичные данные
rsrc.syso
Обычный файл
Двоичные данные
rsrc.syso
Обычный файл
Двоичный файл не отображается.
Загрузка…
Ссылка в новой задаче
Block a user