Skip to content

Commit

Permalink
Update gigantoConfig to respond full configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
BLYKIM committed Sep 6, 2024
1 parent 0745a7e commit cda491b
Show file tree
Hide file tree
Showing 13 changed files with 385 additions and 218 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ Versioning](https://semver.org/spec/v2.0.0.html).
integers beyond `i32`.
- Changed the `from_key_value` macro to additionally receive `str_num_field`
for `StringNumber` conversion.
- Changed to support command line interface.
- Changed command line interface.
- Removed `cert`, `key`, `root` fields from config file.
- Changed `set_giganto_config` to receive toml-string with full configuration.
- Added cli options `-c`, `--cert`, `--key` and `--ca-certs`.
- Changed `setGigantoConfig` to receive toml-string with full configuration.
- Updated `gigantoConfig` to respond full configuration.

## [0.20.0] - 2024-05-17

Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ directories = "5.0"
futures-util = "0.3"
giganto-client = { git = "https://github.com/aicers/giganto-client.git", rev = "cc83f71" }
graphql_client = "0.14"
humantime = "2.1"
humantime-serde = "1"
libc = "0.2"
num_enum = "0.7"
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ processing and real-time analytics.
You can run giganto by invoking the following command:

```sh
giganto --cert <CERT_PATH> --key <KEY_PATH> --ca <CA_PATH> <CENTRAL_SERVER>
giganto --cert <CERT_PATH> --key <KEY_PATH> --ca-certs <CA_CERT_PATH> \
--ca-certs <CA_CERT_PATH>
```

If you want to run giganto with local configuration file,

```sh
giganto -c <CONFIG_PATH> --cert <CERT_PATH> --key <KEY_PATH> --ca <CA_PATH> <CENTRAL_SERVER>
giganto -c <CONFIG_PATH> --cert <CERT_PATH> --key <KEY_PATH> --ca-certs \
<CA_CERT_PATH> --ca-certs <CA_CERT_PATH>
```

In the config file, you can specify the following options:
Expand Down Expand Up @@ -76,8 +78,8 @@ Run giganto with the prepared configuration file. (Settings to use the
certificate/key from the tests folder.)

```sh
cargo run -- -c tests/node1/config.toml --cert tests/node1/cert.pem \
--key tests/node1/key.pem --root tests/root.pem hostname@address
cargo run -- -c tests/config.toml --cert tests/certs/node1/cert.pem \
--key tests/certs/node1/key.pem --ca-certs tests/certs/ca_cert.pem
```

## License
Expand Down
24 changes: 20 additions & 4 deletions src/graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1543,7 +1543,11 @@ mod tests {
}

impl TestSchema {
fn setup(ingest_sources: IngestSources, peers: Peers) -> Self {
fn setup(
ingest_sources: IngestSources,
peers: Peers,
config_file_path: Option<String>,
) -> Self {
let db_dir = tempfile::tempdir().unwrap();
let db = Database::open(db_dir.path(), &DbOptions::default()).unwrap();
let pcap_sources = new_pcap_sources();
Expand All @@ -1565,7 +1569,7 @@ mod tests {
notify_reboot,
notify_power_off,
notify_terminate,
"file_path".to_string(),
config_file_path.unwrap_or("file_path".to_string()),
Arc::new(RwLock::new(1024)),
);

Expand All @@ -1585,7 +1589,7 @@ mod tests {
));

let peers = Arc::new(tokio::sync::RwLock::new(HashMap::new()));
Self::setup(ingest_sources, peers)
Self::setup(ingest_sources, peers, None)
}

pub fn new_with_graphql_peer(port: u16) -> Self {
Expand All @@ -1608,7 +1612,19 @@ mod tests {
},
)])));

Self::setup(ingest_sources, peers)
Self::setup(ingest_sources, peers, None)
}

pub fn new_with_config_file_path(path: String) -> Self {
let ingest_sources = Arc::new(tokio::sync::RwLock::new(
CURRENT_GIGANTO_INGEST_SOURCES
.into_iter()
.map(|source| source.to_string())
.collect::<HashSet<String>>(),
));

let peers = Arc::new(tokio::sync::RwLock::new(HashMap::new()));
Self::setup(ingest_sources, peers, Some(path))
}

pub async fn execute(&self, query: &str) -> async_graphql::Response {
Expand Down
Loading

0 comments on commit cda491b

Please sign in to comment.