diff --git a/cli/src/sources/mod.rs b/cli/src/sources/mod.rs --- a/cli/src/sources/mod.rs +++ b/cli/src/sources/mod.rs @@ -17,7 +17,7 @@ #[serde(rename_all = "lowercase")] pub enum Source { Raw(Raw), Hosts(Hosts), - Forge(Forge), + Http(Http), Github(String), Sourcehut(String), Gitlab(String), @@ -30,11 +30,11 @@ async fn fetch(&self) -> Vec { match *self { Source::Raw(ref raw) => raw.fetch().await, Source::Hosts(ref raw) => raw.fetch().await, - Source::Forge(ref raw) => raw.fetch().await, - Source::Github(ref user) => Forge { user: user.clone(), host: "github.com".into() }.fetch().await, - Source::Sourcehut(ref user) => Forge { user: user.clone(), host: "meta.sr.ht".into() }.fetch().await, - Source::Gitlab(ref user) => Forge { user: user.clone(), host: "gitlab.com".into() }.fetch().await, - Source::Codeberg(ref user) => Forge { user: user.clone(), host: "codeberg.org".into() }.fetch().await, + Source::Http(ref raw) => raw.fetch().await, + Source::Github(ref user) => Http { url: format!("https://github.com/{user}.keys") }.fetch().await, + Source::Sourcehut(ref user) => Http { url: format!("https://meta.sr.ht/{user}.keys") }.fetch().await, + Source::Gitlab(ref user) => Http { url: format!("https://gitlab.com/{user}.keys") }.fetch().await, + Source::Codeberg(ref user) => Http { url: format!("https://codeberg.org/{user}.keys") }.fetch().await, } } } @@ -81,17 +81,14 @@ } } #[derive(Debug, Deserialize)] -pub struct Forge { - pub user: String, - pub host: String, +pub struct Http { + pub url: String } #[async_trait] -impl Fetch for Forge { +impl Fetch for Http { async fn fetch(&self) -> Vec { - let url = format!("https://{}/{}.keys", self.host, self.user); - - reqwest::get(url) + reqwest::get(&self.url) .await .unwrap() .text() diff --git a/docs/fuk.1.scd b/docs/fuk.1.scd --- a/docs/fuk.1.scd +++ b/docs/fuk.1.scd @@ -34,15 +34,13 @@ *host* Hostnames that will be passed to _ssh-keyscan_(1). -*forge* - Takes map as an argument, that map must have 2 keys, _user_ which will - be the name of the user used for querying and _host_ which will be the - host that will be queried. The resulting URL will be constructed as - _https://{host}/{user}.keys_. +*http* + Takes `url` as and argument, with URL pointing to the HTTP resource that + will contain SSH keys. *github*, *gitlab*, *sourcehut*, *codeberg* - Each of these are shortcuts for *forge* entries to provide default - _host_ for equivalent entries. In order these would be _github.com_, + Each of these are shortcuts for *http* entries to provide default + _url_ for equivalent entries. In order these would be _github.com_, _gitlab.com_, _meta.sr.ht_, and _codeberg.org_. Example configuration: