Skip to content

Commit 0ec4b45

Browse files
committed
migrate to go
1 parent d6552e3 commit 0ec4b45

18 files changed

Lines changed: 649 additions & 109 deletions

File tree

.dockerignore

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,28 @@
1-
!app.py
1+
# Ignore all
2+
*
3+
4+
# env file
5+
*.env
6+
7+
# Exclude git folders
8+
.git*
9+
.github
10+
11+
# Ignore yml files
12+
*.yaml
13+
*.yml
14+
15+
# Markdown files
16+
*.md
17+
18+
# Include data/
19+
!data/*
20+
21+
# Ignore source files
22+
*.go
23+
go.mod
24+
go.sum
25+
26+
# Include build
27+
!app
28+
!dist/*

.github/templates/README.template.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ WoL Client is a Wake-on-LAN Docker Container, that wakes up queried Machines.
88
{{{ #://docker-compose.yaml }}}
99
```
1010

11-
Combine with [WoL-Redirect](https://github.com/codeshelldev/wol-redirect) for a graphical interface.
11+
Combine with [WoL-Redirect](https://github.com/codeshelldev/wol-redirect) for a web ui.
1212

1313
## Usage
1414

15-
Send Wakeup-Packtes to host at `192.168.1.1` [`00:00:00:00:00:00`]
15+
Send Wakeup-Packets to host at `192.168.1.1` [`00:00:00:00:00:00`]
1616

17-
```curl
17+
```bash
1818
curl -X POST "Content-Type: application/json" -d '{ "ip":"192.168.1.1", "mac": "00:00:00:00:00:00", "startupTime": 5 }' http://wol-client
1919
```
2020

@@ -23,8 +23,6 @@ curl -X POST "Content-Type: application/json" -d '{ "ip":"192.168.1.1", "mac": "
2323
Want to change something, have suggestions?
2424
Fell free to open up an issue or to create a Pull Request.
2525

26-
This project is rather small so there might not be many additions anytime soon.
27-
2826
## License
2927

3028
[MIT](https://choosealicense.com/licenses/mit/)

.github/workflows/docker-image-dev.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ on:
44
push:
55
branches:
66
- dev
7-
paths-ignore:
8-
- ".**"
7+
paths:
8+
- "**/*.go"
99

1010
jobs:
1111
update:
12-
uses: codeshelldev/gh-actions/.github/workflows/docker-image.yml@main
12+
uses: codeshelldev/gh-actions/.github/workflows/docker-image-go.yml@main
13+
name: Development Image
1314
with:
1415
registry: ghcr.io
1516
flavor: |

.github/workflows/docker-image.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ on:
66

77
jobs:
88
update:
9-
uses: codeshelldev/gh-actions/.github/workflows/docker-image.yml@main
9+
uses: codeshelldev/gh-actions/.github/workflows/docker-image-go.yml@main
10+
name: Stable Image
1011
with:
1112
registry: ghcr.io
1213
secrets:

.github/workflows/readme-update.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ on:
44
push:
55
paths:
66
- docker-compose.yaml
7+
- examples/**
78
- .github/templates/README.template.md
89

910
jobs:
1011
update:
1112
uses: codeshelldev/gh-actions/.github/workflows/readme-update.yml@main
13+
name: Update
1214
secrets:
1315
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,33 @@
1-
.env
2-
.venv
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
8+
# Test binary, built with `go test -c`
9+
*.test
10+
11+
# Code coverage profiles and other test artifacts
12+
*.out
13+
coverage.*
14+
*.coverprofile
15+
profile.cov
16+
17+
# Dependency directories (remove the comment below to include it)
18+
# vendor/
19+
20+
# Go workspace file
21+
go.work
22+
go.work.sum
23+
24+
# env file
25+
*.env
26+
27+
# Editor/IDE
28+
# .idea/
29+
.vscode/
30+
31+
# Exclude git folders
32+
.git*
33+
!.github

app.py

Lines changed: 0 additions & 97 deletions
This file was deleted.

go.mod

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module github.com/codeshelldev/wol-client
2+
3+
go 1.25.5
4+
5+
require github.com/codeshelldev/gotl v0.0.4
6+
7+
require (
8+
github.com/google/uuid v1.6.0 // indirect
9+
github.com/josharian/native v1.0.0 // indirect
10+
github.com/mdlayher/ethernet v0.0.0-20190313224307-5b5fc417d966 // indirect
11+
github.com/mdlayher/packet v1.0.0 // indirect
12+
github.com/mdlayher/socket v0.2.1 // indirect
13+
golang.org/x/net v0.38.0 // indirect
14+
golang.org/x/sync v0.13.0 // indirect
15+
golang.org/x/sys v0.38.0 // indirect
16+
)
17+
18+
require (
19+
github.com/gorilla/websocket v1.5.3
20+
github.com/mdlayher/wol v0.0.0-20220221231636-b763a792253a
21+
github.com/prometheus-community/pro-bing v0.7.0
22+
go.uber.org/multierr v1.11.0 // indirect
23+
go.uber.org/zap v1.27.1 // indirect
24+
)

go.sum

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
github.com/codeshelldev/gotl v0.0.4 h1:W2cup8Pw9LzFLxmS5QUzY+NSE3ZgiRSUM7FiGd6qJrI=
2+
github.com/codeshelldev/gotl v0.0.4/go.mod h1:Mfb+Lb+DV3DUXdA1sixJb2pLawaJGGFFeC29gUZQLcg=
3+
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
4+
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
5+
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
6+
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
7+
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
8+
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
9+
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
10+
github.com/josharian/native v1.0.0 h1:Ts/E8zCSEsG17dUqv7joXJFybuMLjQfWE04tsBODTxk=
11+
github.com/josharian/native v1.0.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
12+
github.com/mdlayher/ethernet v0.0.0-20190313224307-5b5fc417d966 h1:O3p5UmisBhl3V6lgs4Vdfg8HpjzbWJPyOfGLdwVJSmI=
13+
github.com/mdlayher/ethernet v0.0.0-20190313224307-5b5fc417d966/go.mod h1:5s5p/sMJ6sNsFl6uCh85lkFGV8kLuIYJCRJLavVJwvg=
14+
github.com/mdlayher/packet v1.0.0 h1:InhZJbdShQYt6XV2GPj5XHxChzOfhJJOMbvnGAmOfQ8=
15+
github.com/mdlayher/packet v1.0.0/go.mod h1:eE7/ctqDhoiRhQ44ko5JZU2zxB88g+JH/6jmnjzPjOU=
16+
github.com/mdlayher/raw v0.0.0-20190313224157-43dbcdd7739d/go.mod h1:r1fbeITl2xL/zLbVnNHFyOzQJTgr/3fpf1lJX/cjzR8=
17+
github.com/mdlayher/socket v0.2.1 h1:F2aaOwb53VsBE+ebRS9bLd7yPOfYUMC8lOODdCBDY6w=
18+
github.com/mdlayher/socket v0.2.1/go.mod h1:QLlNPkFR88mRUNQIzRBMfXxwKal8H7u1h3bL1CV+f0E=
19+
github.com/mdlayher/wol v0.0.0-20220221231636-b763a792253a h1:fpQi42PM6HzbHwNg6a7OvLbh5l49Rgr7GCARozjHwio=
20+
github.com/mdlayher/wol v0.0.0-20220221231636-b763a792253a/go.mod h1:XX6nvyQpGc8E4KaQm62FyexOYd36ilpyfYf8wjgMDV8=
21+
github.com/prometheus-community/pro-bing v0.7.0 h1:KFYFbxC2f2Fp6c+TyxbCOEarf7rbnzr9Gw8eIb0RfZA=
22+
github.com/prometheus-community/pro-bing v0.7.0/go.mod h1:Moob9dvlY50Bfq6i88xIwfyw7xLFHH69LUgx9n5zqCE=
23+
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
24+
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
25+
go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc=
26+
go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
27+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
28+
golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
29+
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c h1:uOCk1iQW6Vc18bnC13MfzScl+wdKBmM9Y9kU7Z83/lw=
30+
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
31+
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
32+
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
33+
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
34+
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
35+
golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610=
36+
golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
37+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
38+
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
39+
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
40+
golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
41+
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
42+
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
43+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
44+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

internals/config/config.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package config
2+
3+
import (
4+
"os"
5+
"strconv"
6+
7+
"github.com/codeshelldev/gotl/pkg/logger"
8+
"github.com/codeshelldev/wol-client/internals/config/structure"
9+
)
10+
11+
var ENV = &structure.ENV{
12+
LOG_LEVEL: "info",
13+
PORT: "5555",
14+
}
15+
16+
func Load() {
17+
ENV.LOG_LEVEL = os.Getenv("LOG_LEVEL")
18+
19+
ENV.PORT = os.Getenv("PORT")
20+
21+
pingInterval := os.Getenv("PING_INTERVAL")
22+
23+
if pingInterval != "" {
24+
interval, err := strconv.Atoi(pingInterval)
25+
26+
if err != nil {
27+
logger.Error("Invalid ping interval: ", err.Error())
28+
} else {
29+
ENV.PING_INTERVAL = interval
30+
}
31+
}
32+
33+
pingRetries := os.Getenv("PING_RETRIES")
34+
35+
if pingRetries != "" {
36+
retries, err := strconv.Atoi(pingRetries)
37+
38+
if err != nil {
39+
logger.Error("Invalid ping retries: ", err.Error())
40+
} else {
41+
ENV.PING_RETRIES = retries
42+
}
43+
}
44+
}
45+
46+
func Log() {
47+
logger.Dev("Loaded Environment:", ENV)
48+
}

0 commit comments

Comments
 (0)