Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alanEG committed May 8, 2022
0 parents commit 0ea0c37
Show file tree
Hide file tree
Showing 15 changed files with 1,107 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 alaneg

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.
162 changes: 162 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# Gosna - Monitor Url

A Mointor url for change

- [Requirements](https://github.com/alanEG/Gosna#Requirements)
- [Installation](https://github.com/alanEG/Gosna#installation)
- [Configuration file](https://github.com/alanEG/Gosna#configuration-file)
- [Example usage](https://github.com/alanEG/Gosna#example-usage)
- [Normal_Usage](https://github.com/alanEG/Gosna#normal-Usage)
- [Dynamic_Usage](https://github.com/alanEG/Gosna#dynamic-Usage)

## Requirements

- [diff2html-cli](https://github.com/rtfpessoa/diff2html-cli)
- [js-beautify](https://www.npmjs.com/package/js-beautify)

## Installation

- [Download](https://github.com/alaneg/gosna/releases/latest) a prebuilt binary from [releases page](https://github.com/alaneg/gosna/releases/latest), unpack and run!

_or_
- If you have recent go compiler installed: `go install github.com/alanEG/Gosna` (the same command works for updating)

_or_
- `git clone https://github.com/alaneg/gosna ; cd gosna ; go build`

Gosna depends on Go go1.18.1 or greater.


## Configuration file

Gosna doesn't work if you don't setup config file for save the urls and file names and other config

There are three ways the Gosna tool take config file from them

1 - `gosna_config` env

2 - `~/.gosna_config.json`

3 - `-config` option

The defualt config file will be

```json
{
"Config": {
"Is_first": false,
"Directory_work": "~/work/",
"Directory_result": "~/result/",
"Channel_use": "None",
"Channel": {
"Slack": null,
"Mail": {
"Tls": true,
"From": null,
"To": null,
"Host": null,
"Port": null,
"Email": null,
"Password": null
}
}
},
"Target": []
}
```

`Is_first` Don't edit this will edit by the tool

`Directory_work` Edit this for the directory the tool will add the content of urls in it

`Directory_result` Edit this for the directory the tool will save html result in it

`Channel_use` Edit this for the channel the tool will use if it found change or use `None` if you need print the result in stdout channel available `[slack,mail]`

- `channel`

- `Slack` slack webhook

- `Mail` Mail config

## Example usage

The usage examples below show just the simplest tasks you can accomplish using `gosna -h`.

```
Enter Valid run type [check,add]
Usage: ./change [options]
-run Run type [add,check]
-timeout Requests timeout (default 5)
-thread Requests thread
-header Requests header
-dynamic Check dynamic (default false)
-config Config file (default ~/.gosna_config.json)
-no-color Disable color
```

### Normal Usage

There are two run type
- add
- check

##### Example: `add`
Add for add the url to check it later

`cat url.txt | gosna -run add`

Gosna will gets the url content then format it

Then save the content in directory work file

And add it to config file in Target json object


##### Example: `check`
Chcek for check the url if there change

`gosna -run check`

Gosna will gets the urls from config file then get the new content

And save it in the work directory then diff the new content with new conten

### Dynamic Usage

Here simply how check dynamic works when add

1 - Send 5 request and save them responses in `tmp` directory

2 - Get the the dynamic lines from the responses in the `tmp` directory

3 - Save the bigest response length

4 - Remove the dynamic lines from the file saved

5 - Add `true` in object is `Target[n].Status` for knowing the tool it is dynamic url

Here simply how check dynamic works when Check

1 - Check the url is dynamic or not by `Target[n].Status`

2 - Send request and remove the dynamic lines then save it in the file in work directory

3 - Diff the old content with new contnet


##### Example
`cat urls.txt | gosna -run add -dynamic`

##### Note
Some time Dynamic option not working well

Let's imagen we need to monitor the `https://www.youtube.com/`

Because the it printing diffrent line number in each request

The tool will printed this url in each check

## License

Gosna is released under MIT license. See [LICENSE](https://github.com/alanEG/Gosna/blob/main/LICENSE).
44 changes: 44 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package main

import (
"encoding/json"
"fmt"
"io/ioutil"
)

func config_handling(action string) error {
var err error
var json_data []byte
if action == "load" {
config_data, err := ioutil.ReadFile(configFile)

logger("error", "[Error]", err, err, 1)

err = json.Unmarshal(config_data, &data)

logger("error", "[Error]", err, err, 1)

} else if action == "save" {
json_data, err = json.MarshalIndent(data, "", " ")

ioutil.WriteFile(configFile, json_data, 0644)

Execute_command("cd " + data.Config.Directory_work + ";git add .")

}

return err
}

//this for setup the config file and folder result and work directory
func setupFirst() {
if data.Config.Is_first == true {
Execute_command(fmt.Sprintf("mkdir %s;mkdir %s;cd %s;git init",
data.Config.Directory_result,
data.Config.Directory_work,
data.Config.Directory_work,
),
)
data.Config.Is_first = false
}
}
Loading

0 comments on commit 0ea0c37

Please sign in to comment.