______ _
(____ \ | |
____ ___ ____) )_____ ____| | _
/ _ |/ _ \| __ ((____ |/ ___) |_/ )
( (_| | |_| | |__) ) ___ | | | _ (
\___ |\___/|______/\_____|_| |_| \_)
(_____|
goBark is a analyses udp message by regex tool . You can receive messages from the router and then define specific messages as events for subsequent actions.
-
Linux
-
MacOS
-
ARM Linux (Raspberry Pi, etc.)
-
Windows
-
MIPS32 platform
To compile binaries for MIPS (mips or mipsle), run:
GOOS=linux GOARCH=mips/mipsle GOMIPS=softfloat go build -a
The binary can run on routers as well.
Build goBark by running (from the root of the repository):
# get dependencies
go mod download
# build
go build cmd\goBark.go
# Or build for debug
go build -ldflags="-X 'main.Version=0.1.3' -X 'main.DebugMode=true'" cmd\goBark.go
You can also download a compiled binary from the releases.
Print usage/help by running:
$ ./gobark -h
Usage of ./gobark:
-c string
Specify a config file (default "./config.json")
-h Show help
overview
- Make a copy of config_sample.json and name it as
config.json
. - Configure your credentials, etc.
- Configure a notification medium (e.g. SMTP to receive emails) to get notified when your receive sepcial messages.
- Place the file in the same directory of goBark or use the
-c=path/to/your/config.json
option .
goBark supports 1 configuration file formats:
- JSON
disable_capture_message
- Just use the goBark as UdpServer when true.debug_info
- Whether to output debugging information.udpServer
- Set the UdpServer informationevent_message_ignore_keys
- Ignore those keys message.event_messages
- Capture the udp first expression caputred of array.
This is a simple default configuration.
Example
{
"debug_info": true,
"udpServer": {
"host": "0.0.0.0",
"port": 996,
"blockSize": 1024
},
"disable_capture_message": false,
"event_message_ignore_keys": ["dnsmasq-dhcp"],
"event_messages": [
{
"captureReg": "local IP address (?P<ipv4>((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?))",
"title": "PPoE dial success",
"content": "current WAN IPv4 is : $ipv4",
"value": "$ipv4"
}
],
"use_proxy": false,
"socks5_proxy": "",
"webhook": {
"enabled": false,
"url": "https://api.day.app/{change to your bark token}/{{.Title}}/{{.Content}}",
"request_body": ""
}
}
There are a few ways to run goBark.
Note: make sure to set the run_once
parameter in your config file so the program will quit after the first run (the default is false
).
Can be added to cron
or attached to other events on your system.
{
"...": "...",
"run_once": true
}
Then run
./gobark
nohup ./gobark &
Note: when the program stops, it will not be restarted.
-
Install
upstart
first (if not available already) -
Copy
./upstart/gobark.conf
to/etc/init
(and tweak it to your needs) -
Start the service:
sudo start gobark
-
Install
systemd
first (it not available already) -
Copy
./systemd/gobark.service
to/lib/systemd/system
(and tweak it to your needs) -
Start the service:
sudo systemctl enable gobark sudo systemctl start gobark
Available docker registries:
Visit https://hub.docker.com/repository/docker/aicrosoft/gobark# to fetch the latest docker image.
With /path/to/config.json
your local configuration file, run:
docker run \
-p 996:996/udp \
-d --name gobark --restart=always \
-v /path/to/config.json:/config.json \
aicrosoft/gobark:latest
-
Download the latest version of NSSM
-
In an administrative prompt, from the folder where NSSM was downloaded, e.g.
C:\Downloads\nssm\
win64, run:nssm install YOURSERVICENAME
-
Follow the interface to configure the service. In the "Application" tab just indicate where the
gobark.exe
file is. Optionally you can also define a description on the "Details" tab and define a log file on the "I/O" tab. Finish by clicking on the "Install service" button. -
The service will now start along Windows.
Note: you can uninstall the service by running:
nssm remove YOURSERVICENAME
gobark : good to learn golang example.