From 0e1f5f15de7b69f5ae74e8144661e57af0de1166 Mon Sep 17 00:00:00 2001 From: Melora Hugues Date: Thu, 5 Jan 2023 18:51:39 +0100 Subject: [PATCH 1/3] Write initial README file --- README.md | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dc48501..aecbdde 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,29 @@ -# public-ip-tracker +# Public IP tracker -Simple Go project to track current public IP and notify changes to a telegram bot \ No newline at end of file +[![Build Status](https://drone.faercol.me/api/badges/faercol/public-ip-tracker/status.svg)](https://drone.faercol.me/faercol/public-ip-tracker) + + +Telegram bot that detects changes to the device's public IP. This is particularily useful when +the device is handled by an ISP that does not provide a static public IP, such as a home device. + +## Features + +### Automatic public IP detection and monitoring + +Upon startup, the current public IP is detected, and a status message is sent to a specific Telegram +channel with the relevant information. + +> Insert example message here + +When running as a daemon, the program automatically monitors the current public IP adress for changes. +If the IP changes for some reason, then the new updated adress is sent to the specific Telegram +channel. + +> Insert example message here + +### On-demand public IP + +The relevant channel is monitored during the program execution. This allows the user to send a +command to the bot in order to get the current public IP on-demand. + +> Insert example here -- 2.45.2 From bd9bba54ba435850624e8549f31ad7cbdcf75e13 Mon Sep 17 00:00:00 2001 From: Melora Hugues Date: Thu, 5 Jan 2023 18:51:53 +0100 Subject: [PATCH 2/3] Create initial Go module Ref #1 Create an initial Go module with a simple unit test and a makefile. This can be tested using a CI pipeline, which will ensure that the following commits don't break anything. --- .gitignore | 3 +++ tracker/Makefile | 7 +++++++ tracker/go.mod | 3 +++ tracker/main.go | 11 +++++++++++ tracker/main_test.go | 9 +++++++++ 5 files changed, 33 insertions(+) create mode 100644 tracker/Makefile create mode 100644 tracker/go.mod create mode 100644 tracker/main.go create mode 100644 tracker/main_test.go diff --git a/.gitignore b/.gitignore index adf8f72..8da22dc 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,9 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out +# build directory +tracker/build + # Dependency directories (remove the comment below to include it) # vendor/ diff --git a/tracker/Makefile b/tracker/Makefile new file mode 100644 index 0000000..a39e6c4 --- /dev/null +++ b/tracker/Makefile @@ -0,0 +1,7 @@ +.PHONY: build test + +build: + go build -o build/ + +test: + go test -v ./... diff --git a/tracker/go.mod b/tracker/go.mod new file mode 100644 index 0000000..54b9f30 --- /dev/null +++ b/tracker/go.mod @@ -0,0 +1,3 @@ +module git.faercol.me/faercol/public-ip-tracker/tracker + +go 1.16 diff --git a/tracker/main.go b/tracker/main.go new file mode 100644 index 0000000..bfe65b2 --- /dev/null +++ b/tracker/main.go @@ -0,0 +1,11 @@ +package main + +import "fmt" + +func testMethod(a int) int { + return a + 2 +} + +func main() { + fmt.Println("public ip tracker") +} diff --git a/tracker/main_test.go b/tracker/main_test.go new file mode 100644 index 0000000..3fefe71 --- /dev/null +++ b/tracker/main_test.go @@ -0,0 +1,9 @@ +package main + +import "testing" + +func TestTestMethod(t *testing.T) { + if testMethod(12) != 14 { + t.Fatalf("Unexpected result %d", testMethod((12))) + } +} -- 2.45.2 From 56f909d2296d3130a8ba830e7d7353a8fa104ccc Mon Sep 17 00:00:00 2001 From: Melora Hugues Date: Thu, 5 Jan 2023 19:01:53 +0100 Subject: [PATCH 3/3] Add .drone-ci file Ref #1 Add the configuration file for the CI --- .drone.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..087a749 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,16 @@ +kind: pipeline +type: docker +name: Tests + +steps: +- name: test + image: golang + commands: + - cd tracker + - make build + - make test + +trigger: + event: + - push + - tag -- 2.45.2