mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 08:51:09 +00:00
Make using insecure connections opt-in (#1309)
* add insecure url checks * rename variables * add feature flags to expose Url properly * fix test compile error * fix feature errors * remove comment * add url crate and use it for url parsing * fix compile errors * satisfy the holy clippy * fix typos and host loopback * macro attribute, provide validation function in utils * fix expected output of ui tests * remove the success case for --allow-insecure because we cannot establish ws:// connection at the moment.
This commit is contained in:
+8
-5
@@ -32,7 +32,7 @@ struct RuntimeMetadataArgs {
|
||||
#[darling(default)]
|
||||
runtime_metadata_path: Option<String>,
|
||||
#[darling(default)]
|
||||
runtime_metadata_url: Option<String>,
|
||||
runtime_metadata_insecure_url: Option<String>,
|
||||
#[darling(default)]
|
||||
derive_for_all_types: Option<Punctuated<syn::Path, syn::Token![,]>>,
|
||||
#[darling(default)]
|
||||
@@ -146,11 +146,14 @@ pub fn subxt(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
// Do we want to fetch unstable metadata? This only works if fetching from a URL.
|
||||
let unstable_metadata = args.unstable_metadata.is_present();
|
||||
|
||||
match (args.runtime_metadata_path, args.runtime_metadata_url) {
|
||||
match (
|
||||
args.runtime_metadata_path,
|
||||
args.runtime_metadata_insecure_url,
|
||||
) {
|
||||
(Some(rest_of_path), None) => {
|
||||
if unstable_metadata {
|
||||
abort_call_site!(
|
||||
"The 'unstable_metadata' attribute requires `runtime_metadata_url`"
|
||||
"The 'unstable_metadata' attribute requires `runtime_metadata_insecure_url`"
|
||||
)
|
||||
}
|
||||
|
||||
@@ -185,12 +188,12 @@ pub fn subxt(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
}
|
||||
(None, None) => {
|
||||
abort_call_site!(
|
||||
"One of 'runtime_metadata_path' or 'runtime_metadata_url' must be provided"
|
||||
"One of 'runtime_metadata_path' or 'runtime_metadata_insecure_url' must be provided"
|
||||
)
|
||||
}
|
||||
(Some(_), Some(_)) => {
|
||||
abort_call_site!(
|
||||
"Only one of 'runtime_metadata_path' or 'runtime_metadata_url' can be provided"
|
||||
"Only one of 'runtime_metadata_path' or 'runtime_metadata_insecure_url' can be provided"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user