Skip to content

Commit cc8a6d2

Browse files
authored
Merge pull request #55 from CoLearn-Dev/pom-updates
POM: support docker, allow external source
2 parents 40e3693 + 3e52bc6 commit cc8a6d2

14 files changed

+728
-572
lines changed

Cargo.lock

+211-200
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "colink-server"
3-
version = "0.3.4"
3+
version = "0.3.5"
44
edition = "2021"
55

66
[dependencies]

proto

Submodule proto updated 1 file

rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
stable-2023-01-10
1+
stable-2023-03-09

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ pub mod subscription;
77
pub mod colink_proto {
88
tonic::include_proto!("colink");
99
}
10+
pub mod params;
1011
pub mod utils;

src/main.rs

+3-114
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,14 @@
11
use clap::Parser;
2+
use colink_server::params::CoLinkServerParams;
23
use colink_server::server::init_and_run_server;
3-
use std::path::PathBuf;
4-
5-
#[derive(Debug, Parser)]
6-
#[command(name = "CoLink", about = "CoLink", version)]
7-
struct CommandLineArgs {
8-
/// Address of CoLink server
9-
// short and long flags (-d, --debug) will be deduced from the field's name
10-
#[arg(
11-
short,
12-
long,
13-
env = "COLINK_SERVER_ADDRESS",
14-
default_value = "127.0.0.1"
15-
)]
16-
address: String,
17-
18-
/// Port of CoLink server
19-
#[arg(short, long, env = "COLINK_SERVER_PORT", default_value = "2021")]
20-
port: u16,
21-
22-
/// URI of MQ (AMQP or Redis)
23-
#[arg(long, env = "COLINK_SERVER_MQ_URI")]
24-
mq_uri: Option<String>,
25-
26-
/// Management API of MQ, only required by RabbitMQ
27-
#[arg(long, env = "COLINK_SERVER_MQ_API")]
28-
mq_api: Option<String>,
29-
30-
/// Prefix of MQ
31-
#[arg(long, env = "COLINK_SERVER_MQ_PREFIX", default_value = "colink")]
32-
mq_prefix: String,
33-
34-
/// URI of CoLink server
35-
#[arg(
36-
long,
37-
env = "COLINK_SERVER_CORE_URI",
38-
default_value = "http://127.0.0.1:2021"
39-
)]
40-
core_uri: Option<String>,
41-
42-
/// Path to server certificate.
43-
/// If not supplied, TLS and MTLS will not be enabled
44-
#[arg(long, env = "COLINK_SERVER_CERT")]
45-
cert: Option<PathBuf>,
46-
47-
/// Path to private key.
48-
/// If not supplied, TLS and MTLS will not be enabled
49-
#[arg(long, env = "COLINK_SERVER_KEY")]
50-
key: Option<PathBuf>,
51-
52-
/// Path to client CA certificate.
53-
/// If not supplied and both cert and key are supplied, then TLS is enabled.
54-
/// If all of cert, key, and ca are supplied, then MTLS is enabled.
55-
#[arg(long, env = "COLINK_SERVER_CA")]
56-
ca: Option<PathBuf>,
57-
58-
/// Path to CA certificate you want to trust in inter-core communication.
59-
#[arg(long, env = "COLINK_SERVER_INTER_CORE_CA")]
60-
inter_core_ca: Option<PathBuf>,
61-
62-
/// Path to client certificate you want to use in inter-core communication.
63-
#[arg(long, env = "COLINK_SERVER_INTER_CORE_CERT")]
64-
inter_core_cert: Option<PathBuf>,
65-
66-
/// Path to private key you want to use in inter-core communication.
67-
#[arg(long, env = "COLINK_SERVER_INTER_CORE_KEY")]
68-
inter_core_key: Option<PathBuf>,
69-
70-
/// Enforce the generation of the new jwt secret.
71-
#[arg(long, env = "COLINK_SERVER_FORCE_GEN_JWT_SECRET")]
72-
force_gen_jwt_secret: bool,
73-
74-
/// Enforce the generation of the core's private key.
75-
#[arg(long, env = "COLINK_SERVER_FORCE_GEN_PRIV_KEY")]
76-
force_gen_priv_key: bool,
77-
78-
/// Create reverse connections to other servers.
79-
#[arg(long, env = "COLINK_SERVER_INTER_CORE_REVERSE_MODE")]
80-
inter_core_reverse_mode: bool,
81-
}
824

835
#[tokio::main]
846
async fn main() -> Result<(), Box<dyn std::error::Error>> {
857
// install global collector configured based on RUST_LOG env var.
868
tracing_subscriber::fmt::init();
87-
let CommandLineArgs {
88-
address,
89-
port,
90-
mq_uri,
91-
mq_api,
92-
mq_prefix,
93-
core_uri,
94-
cert,
95-
key,
96-
ca,
97-
inter_core_ca,
98-
inter_core_cert,
99-
inter_core_key,
100-
force_gen_jwt_secret,
101-
force_gen_priv_key,
102-
inter_core_reverse_mode,
103-
} = CommandLineArgs::parse();
9+
let colink_server_params = CoLinkServerParams::parse();
10410

105-
init_and_run_server(
106-
address,
107-
port,
108-
mq_uri,
109-
mq_api,
110-
mq_prefix,
111-
core_uri,
112-
cert,
113-
key,
114-
ca,
115-
inter_core_ca,
116-
inter_core_cert,
117-
inter_core_key,
118-
force_gen_jwt_secret,
119-
force_gen_priv_key,
120-
inter_core_reverse_mode,
121-
)
122-
.await;
11+
init_and_run_server(colink_server_params).await;
12312

12413
Ok(())
12514
}

src/params.rs

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
use clap::Parser;
2+
use std::path::PathBuf;
3+
4+
#[derive(Debug, Clone, Parser)]
5+
#[command(name = "CoLink", about = "CoLink", version)]
6+
pub struct CoLinkServerParams {
7+
/// Address of CoLink server
8+
// short and long flags (-d, --debug) will be deduced from the field's name
9+
#[arg(
10+
short,
11+
long,
12+
env = "COLINK_SERVER_ADDRESS",
13+
default_value = "127.0.0.1"
14+
)]
15+
pub address: String,
16+
17+
/// Port of CoLink server
18+
#[arg(short, long, env = "COLINK_SERVER_PORT", default_value = "2021")]
19+
pub port: u16,
20+
21+
/// URI of MQ (AMQP or Redis)
22+
#[arg(long, env = "COLINK_SERVER_MQ_URI")]
23+
pub mq_uri: Option<String>,
24+
25+
/// Management API of MQ, only required by RabbitMQ
26+
#[arg(long, env = "COLINK_SERVER_MQ_API")]
27+
pub mq_api: Option<String>,
28+
29+
/// Prefix of MQ
30+
#[arg(long, env = "COLINK_SERVER_MQ_PREFIX", default_value = "colink")]
31+
pub mq_prefix: String,
32+
33+
/// URI of CoLink server
34+
#[arg(
35+
long,
36+
env = "COLINK_SERVER_CORE_URI",
37+
default_value = "http://127.0.0.1:2021"
38+
)]
39+
pub core_uri: Option<String>,
40+
41+
/// Path to server certificate.
42+
/// If not supplied, TLS and MTLS will not be enabled
43+
#[arg(long, env = "COLINK_SERVER_CERT")]
44+
pub cert: Option<PathBuf>,
45+
46+
/// Path to private key.
47+
/// If not supplied, TLS and MTLS will not be enabled
48+
#[arg(long, env = "COLINK_SERVER_KEY")]
49+
pub key: Option<PathBuf>,
50+
51+
/// Path to client CA certificate.
52+
/// If not supplied and both cert and key are supplied, then TLS is enabled.
53+
/// If all of cert, key, and ca are supplied, then MTLS is enabled.
54+
#[arg(long, env = "COLINK_SERVER_CA")]
55+
pub ca: Option<PathBuf>,
56+
57+
/// Path to CA certificate you want to trust in inter-core communication.
58+
#[arg(long, env = "COLINK_SERVER_INTER_CORE_CA")]
59+
pub inter_core_ca: Option<PathBuf>,
60+
61+
/// Path to client certificate you want to use in inter-core communication.
62+
#[arg(long, env = "COLINK_SERVER_INTER_CORE_CERT")]
63+
pub inter_core_cert: Option<PathBuf>,
64+
65+
/// Path to private key you want to use in inter-core communication.
66+
#[arg(long, env = "COLINK_SERVER_INTER_CORE_KEY")]
67+
pub inter_core_key: Option<PathBuf>,
68+
69+
/// Enforce the generation of the new jwt secret.
70+
#[arg(long, env = "COLINK_SERVER_FORCE_GEN_JWT_SECRET")]
71+
pub force_gen_jwt_secret: bool,
72+
73+
/// Enforce the generation of the core's private key.
74+
#[arg(long, env = "COLINK_SERVER_FORCE_GEN_PRIV_KEY")]
75+
pub force_gen_priv_key: bool,
76+
77+
/// Create reverse connections to other servers.
78+
#[arg(long, env = "COLINK_SERVER_INTER_CORE_REVERSE_MODE")]
79+
pub inter_core_reverse_mode: bool,
80+
81+
/// Set protocol inventory for POM.
82+
#[arg(
83+
long,
84+
env = "COLINK_POM_PROTOCOL_INVENTORY",
85+
default_value = "https://raw.githubusercontent.com/CoLearn-Dev/colink-protocol-inventory/main/protocols"
86+
)]
87+
pub pom_protocol_inventory: String,
88+
89+
/// Allow POM to launch protocol from any source.
90+
#[arg(long, env = "COLINK_POM_ALLOW_EXTERNAL_SOURCE")]
91+
pub pom_allow_external_source: bool,
92+
}

0 commit comments

Comments
 (0)