Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add an option to configure owner_api address and port #1867

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions config/src/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,20 @@ fn comments() -> HashMap<String, String> {
#private key for the TLS certificate
#tls_certificate_key = \"\"

".to_string(),
);

retval.insert(
"owner_api_listen_interface".to_string(),
"
#host IP for owner_api listener
".to_string(),
);

retval.insert(
"owner_api_listen_port".to_string(),
"
#port for owner_api listener
".to_string(),
);

Expand Down
37 changes: 22 additions & 15 deletions src/bin/cmd/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,25 +165,32 @@ pub fn wallet_command(wallet_args: &ArgMatches, config: GlobalWalletConfig) {
});
}
("owner_api", Some(_api_args)) => {
// TLS is disabled because we bind to localhost
controller::owner_listener(wallet, "127.0.0.1:13420", api_secret, None)
.unwrap_or_else(|e| {
panic!(
"Error creating wallet api listener: {:?} Config: {:?}",
e, wallet_config
)
});
controller::owner_listener(
wallet,
&wallet_config.owner_api_listen_addr(),
api_secret,
tls_conf,
).unwrap_or_else(|e| {
panic!(
"Error creating wallet owner api listener: {:?} Config: {:?}",
e, wallet_config
)
});
}
("web", Some(_api_args)) => {
// start owner listener and run static file server
start_webwallet_server();
controller::owner_listener(wallet, "127.0.0.1:13420", api_secret, tls_conf)
.unwrap_or_else(|e| {
panic!(
"Error creating wallet api listener: {:?} Config: {:?}",
e, wallet_config
)
});
controller::owner_listener(
wallet,
&wallet_config.owner_api_listen_addr(),
api_secret,
tls_conf,
).unwrap_or_else(|e| {
panic!(
"Error creating wallet owner api listener: {:?} Config: {:?}",
e, wallet_config
)
});
}
_ => {}
};
Expand Down
14 changes: 14 additions & 0 deletions wallet/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ pub struct WalletConfig {
pub api_listen_interface: String,
// The port this wallet will run on
pub api_listen_port: u16,
// The api interface/ip_address that the owner api server will run
// by default this is 127.0.0.1 (and will not accept connections from external clients)
pub owner_api_listen_interface: String,
// The port the owner api will run on
pub owner_api_listen_port: u16,
/// Location of the secret for basic auth on the Owner API
pub api_secret_path: Option<String>,
/// Location of the node api secret for basic auth on the Grin API
Expand All @@ -59,6 +64,8 @@ impl Default for WalletConfig {
chain_type: Some(ChainTypes::Testnet4),
api_listen_interface: "127.0.0.1".to_string(),
api_listen_port: 13415,
owner_api_listen_interface: "127.0.0.1".to_string(),
owner_api_listen_port: 13420,
api_secret_path: Some(".api_secret".to_string()),
node_api_secret_path: Some(".api_secret".to_string()),
check_node_api_http_addr: "http://127.0.0.1:13413".to_string(),
Expand All @@ -73,6 +80,13 @@ impl WalletConfig {
pub fn api_listen_addr(&self) -> String {
format!("{}:{}", self.api_listen_interface, self.api_listen_port)
}

pub fn owner_api_listen_addr(&self) -> String {
format!(
"{}:{}",
self.owner_api_listen_interface, self.owner_api_listen_port
)
}
}

#[derive(Clone, PartialEq)]
Expand Down