Skip to content

Commit

Permalink
fixed few issue
Browse files Browse the repository at this point in the history
  • Loading branch information
rudSarkar committed Aug 21, 2022
1 parent f492dac commit 3e77935
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## PortMonitor

It requires HackerTarget API and monitor port using [cron library](github.com/robfig/cron/v3), and it requires mongodb to store data and slack webhook.
It requires HackerTarget API and monitor port using cronjob, and it requires mongodb to store data and slack webhook.

### MongoDB Compose file

Expand Down Expand Up @@ -34,16 +34,11 @@ services:
### Environment
Change HackerTarget API also mongodb URI and finally slack webhook.
Change HackerTarget API also mongodb URI and finally slack webhook. Create folder on `mkdir $HOME/.portmonitor/` and
then create a file `touch $HOME/.portmonitor/.env` follow the example env and change with yours.

```dotenv
HACKERTARGET_API=7xxxxxsomerandomstringsd1c
MONGODB_URI=mongodb://root:example@localhost:27017/
SLACK_WEBHOOK=https://hooks.slack.com/services/xxxx/xxx/xxxxx
```


### Todo

- [ ] Add cronjob to add monitoring system
- [ ] Add a env item for specify the cron time
3 changes: 2 additions & 1 deletion checkenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package main
import (
"github.com/joho/godotenv"
"github.com/thep0y/go-logger/log"
"os"
)

func checkDotEnv() bool {
if err := godotenv.Load(".env"); err != nil {
if err := godotenv.Load(os.ExpandEnv("$HOME/.portmonitor/.env")); err != nil {
log.Fatal("No .env file found")
}

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
)

func main() {
URI := os.Getenv("MONGODB_URI")
if checkDotEnv() {
log.Fatal("environment file not found")
} else {
URI := os.Getenv("MONGODB_URI")
defer config.IsConnected(URI).Disconnect(context.TODO())
output.GetOutput()
}
Expand Down

0 comments on commit 3e77935

Please sign in to comment.