Skip to content

Commit

Permalink
Add User-Agent to requests, bump version number, clean up dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
4f48 committed Sep 6, 2024
1 parent 16eb91e commit a88463c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 1 addition & 3 deletions Cargo.lock

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

4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
[package]
name = "dpb"
version = "1.0.0-rc.1"
version = "1.0.0-rc.2"
edition = "2021"

[dependencies]
clap = { version = "4.5.16", features = ["derive"] }
http = "1.1.0"
log = "0.4.22"
reqwest = { version = "0.12.5", features = ["json", "blocking"] }
serde = { version = "1.0.204", features = ["derive"] }
serde_json = "1.0.120"
stderrlog = "0.6.0"
tokio = { version = "1.40.0", features = [ "time" ] }
toml = "0.8.16"
7 changes: 7 additions & 0 deletions src/http.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use crate::config::Config;

use reqwest::header::USER_AGENT;
use serde::Deserialize;
use serde_json::json;
use std::net::{Ipv4Addr, Ipv6Addr};

const DPB_USERAGENT: &str = "4f48/[email protected] ([email protected])";

#[allow(non_snake_case, unused)]
#[derive(Deserialize, Debug)]
pub struct GetIpV4 {
Expand All @@ -24,6 +27,7 @@ pub fn get_ipv4(
) -> Result<GetIpV4, reqwest::Error> {
let res: GetIpV4 = client
.post("https://api-ipv4.porkbun.com/api/json/v3/ping")
.header(USER_AGENT, DPB_USERAGENT)
.json(&json!({
"secretapikey": config.secret,
"apikey": config.key
Expand All @@ -39,6 +43,7 @@ pub fn get_ipv6(
) -> Result<GetIpV6, reqwest::Error> {
let res: GetIpV6 = client
.post("https://api.porkbun.com/api/json/v3/ping")
.header(USER_AGENT, DPB_USERAGENT)
.json(&json!({
"secretapikey": config.secret,
"apikey": config.key
Expand All @@ -59,6 +64,7 @@ pub fn edit_a(
"https://api.porkbun.com/api/json/v3/dns/editByNameType/{}/A/{}",
config.domain, subdomain
))
.header(USER_AGENT, DPB_USERAGENT)
.json(&json!({
"secretapikey": config.secret,
"apikey": config.key,
Expand All @@ -79,6 +85,7 @@ pub fn edit_aaaa(
"https://api.porkbun.com/api/json/v3/dns/editByNameType/{}/AAAA/{}",
config.domain, subdomain
))
.header(USER_AGENT, DPB_USERAGENT)
.json(&json!({
"secretapikey": config.secret,
"apikey": config.key,
Expand Down

0 comments on commit a88463c

Please sign in to comment.