Skip to content

Commit

Permalink
Merge pull request #90 from mbolli/prep-php-82
Browse files Browse the repository at this point in the history
v0.3: PHP 8.1+, PSR4, bits/bytes switch, reverse dns, human-readable byte numbers, etc.
  • Loading branch information
mbolli authored Feb 28, 2024
2 parents 471d3df + ccf831c commit dea3416
Show file tree
Hide file tree
Showing 45 changed files with 5,369 additions and 2,211 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Drupal editor configuration normalization
# @see http://editorconfig.org/

# This is the top-most .editorconfig file; do not search in parent directories.
root = true

# All files.
[*]
end_of_line = LF
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ backend/datasources/data/
backend/cli/nfsen-ng.log
backend/cli/nfsen-ng.pid
profiles-data/
vendor/
*.cache
27 changes: 27 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/*
* This document has been generated with
* https://mlocati.github.io/php-cs-fixer-configurator/#version:2.18.1|configurator
* you can change this configuration by importing this file.
*/
return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' => true,
'@PHP80Migration:risky' => true,
'@PHP82Migration' => true,
'@Symfony' => true,
'@Symfony:risky' => true,
'concat_space' => ['spacing' => 'one'],
'control_structure_continuation_position' => ['position' => 'same_line'],
'curly_braces_position' => ['classes_opening_brace' => 'same_line', 'functions_opening_brace' => 'same_line'],
'declare_strict_types' => false,
'mb_str_functions' => true,
'operator_linebreak' => true,
'phpdoc_to_comment' => ['ignored_tags' => ['var']],
'single_line_empty_body' => true,
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
])
->setFinder(PhpCsFixer\Finder::create()->exclude('vendor')->in(__DIR__))
;
120 changes: 60 additions & 60 deletions API_ENDPOINTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,89 +3,89 @@
### /api/config
* **URL**
`/api/config`

* **Method:**
`GET`

* **URL Params**
none

* **Success Response:**
* **Code:** 200
**Content:**

* **Code:** 200
**Content:**
```json
{
"sources": [ "gate", "swi6" ],
"ports": [ 80, 22, 23 ],
"stored_output_formats": [],
"stored_output_formats": [],
"stored_filters": [],
"daemon_running": true
}
```

* **Error Response:**
* **Code:** 400 BAD REQUEST
**Content:**
```json

* **Code:** 400 BAD REQUEST
**Content:**
```json
{"code": 400, "error": "400 - Bad Request. Probably wrong or not enough arguments."}
```
OR
* **Code:** 404 NOT FOUND
**Content:**

* **Code:** 404 NOT FOUND
**Content:**
```json
{"code": 404, "error": "400 - Not found. "}
```

* **Sample Call:**
```sh
curl localhost/nfsen-ng/api/config
```

### /api/graph
* **URL**
`/api/graph?datestart=1490484000&dateend=1490652000&type=flows&sources[0]=gate&protocols[0]=tcp&protocols[1]=icmp&display=sources`

* **Method:**

`GET`

* **URL Params**
* `datestart=[integer]` Unix timestamp
* `dateend=[integer]` Unix timestamp
* `type=[string]` Type of data to show: flows/packets/bytes
* `sources=[array]`
* `type=[string]` Type of data to show: flows/packets/traffic
* `sources=[array]`
* `protocols=[array]`
* `ports=[array]`
* `display=[string]` can be `sources`, `protocols` or `ports`

There can't be multiple sources and multiple protocols both. Either one source and multiple protocols, or one protocol and multiple sources.
* **Success Response:**
* **Code:** 200
**Content:**
```json
**Content:**
```json
{"data": {
"1490562300":[2.1666666667,94.396666667],
"1490562600":[1.0466666667,72.976666667],...
},"start":1490562300,"end":1490590800,"step":300,"legend":["swi6_flows_tcp","gate_flows_tcp"]}
```
* **Error Response:**
* **Error Response:**
* **Code:** 400 BAD REQUEST <br />
**Content:**
**Content:**
```json
{"code": 400, "error": "400 - Bad Request. Probably wrong or not enough arguments."}
```
OR
* **Code:** 404 NOT FOUND <br />
**Content:**
```json
**Content:**
```json
{"code": 404, "error": "400 - Not found. "}
```
Expand All @@ -100,42 +100,42 @@
`/api/flows?datestart=1482828600&dateend=1490604300&sources[0]=gate&sources[1]=swi6&filter=&limit=100&aggregate=srcip&sort=&output[format]=auto`
* **Method:**
`GET`
* **URL Params**
* `datestart=[integer]` Unix timestamp
* `dateend=[integer]` Unix timestamp
* `sources=[array]`
* `sources=[array]`
* `filter=[string]` pcap-syntaxed filter
* `limit=[int]` max. returned rows
* `aggregate=[string]` can be `bidirectional` or a valid nfdump aggregation string (e.g. `srcip4/24, dstport`), but not both at the same time
* `sort=[string]` (will probably cease to exist, as ordering is done directly in aggregation) e.g. `tstart`
* `output=[array]` can contain `[format] = auto|line|long|extended` and `[IPv6]`
* `output=[array]` can contain `[format] = auto|line|long|extended` and `[IPv6]`
* **Success Response:**
* **Code:** 200
**Content:**
```json
**Content:**
```json
[["ts","td","sa","da","sp","dp","pr","ipkt","ibyt","opkt","obyt"],
["2017-03-27 10:40:46","0.000","85.105.45.96","0.0.0.0","0","0","","1","46","0","0"],
...
```
* **Error Response:**
* **Code:** 400 BAD REQUEST <br />
**Content:**
**Content:**
```json
{"code": 400, "error": "400 - Bad Request. Probably wrong or not enough arguments."}
```
OR
* **Code:** 404 NOT FOUND <br />
**Content:**
```json
**Content:**
```json
{"code": 404, "error": "400 - Not found. "}
```
Expand All @@ -150,45 +150,45 @@
`/api/stats?datestart=1482828600&dateend=1490604300&sources[0]=gate&sources[1]=swi6&for=dstip&filter=&top=10&limit=100&aggregate[]=srcip&sort=&output[format]=auto`
* **Method:**
`GET`
* **URL Params**
* `datestart=[integer]` Unix timestamp
* `dateend=[integer]` Unix timestamp
* `sources=[array]`
* `sources=[array]`
* `filter=[string]` pcap-syntaxed filter
* `top=[int]` return top N rows
* `for=[string]` field to get the statistics for. with optional ordering field as suffix, e.g. `ip/flows`
* `limit=[string]` limit output to records above or below of `limit` e.g. `500K`
* `output=[array]` can contain `[IPv6]`
* `output=[array]` can contain `[IPv6]`
* **Success Response:**
* **Code:** 200
**Content:**
```json
**Content:**
```json
[
["Packet limit: > 100 packets"],
["ts","te","td","pr","val","fl","flP","ipkt","ipktP","ibyt","ibytP","ipps","ipbs","ibpp"],
["2017-03-27 10:38:20","2017-03-27 10:47:58","577.973","any","193.5.80.180","673","2.7","676","2.5","56581","2.7","1","783","83"],
...
]
```
* **Error Response:**
* **Code:** 400 BAD REQUEST <br />
**Content:**
**Content:**
```json
{"code": 400, "error": "400 - Bad Request. Probably wrong or not enough arguments."}
```
OR
* **Code:** 404 NOT FOUND <br />
**Content:**
```json
**Content:**
```json
{"code": 404, "error": "400 - Not found. "}
```
Expand Down
Loading

0 comments on commit dea3416

Please sign in to comment.