mirror of
https://github.com/aljazceru/pubky-core.git
synced 2026-01-07 16:24:20 +01:00
feat: publish HTTPS port even in testnet, and use testnet in request binary
This commit is contained in:
@@ -15,3 +15,7 @@ Or make a direct HTTP request.
|
||||
```bash
|
||||
cargo run --bin request GET https://<Pkarr domain>/[path]
|
||||
```
|
||||
|
||||
### Testnet
|
||||
|
||||
You can pass a `--testnet` argument to run the query in testnet mode (using local DHT testnet).
|
||||
|
||||
@@ -14,6 +14,9 @@ struct Cli {
|
||||
method: Method,
|
||||
/// Pubky or HTTPS url
|
||||
url: Url,
|
||||
/// Use testnet mode
|
||||
#[clap(long)]
|
||||
testnet: bool,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
@@ -24,7 +27,11 @@ async fn main() -> Result<()> {
|
||||
.with_env_filter(env::var("TRACING").unwrap_or("info".to_string()))
|
||||
.init();
|
||||
|
||||
let client = Client::new()?;
|
||||
let client = if args.testnet {
|
||||
Client::testnet()?
|
||||
} else {
|
||||
Client::new()?
|
||||
};
|
||||
|
||||
// Build the request
|
||||
let response = client.get(args.url).send().await?;
|
||||
|
||||
@@ -85,11 +85,8 @@ impl Homeserver {
|
||||
|
||||
let pkarr_server = PkarrServer::new(
|
||||
&config,
|
||||
if config.testnet {
|
||||
http_servers.http_address().port()
|
||||
} else {
|
||||
http_servers.https_address().port()
|
||||
},
|
||||
http_servers.https_address().port(),
|
||||
http_servers.http_address().port(),
|
||||
)?;
|
||||
pkarr_server.publish_server_packet().await?;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ pub struct PkarrServer {
|
||||
}
|
||||
|
||||
impl PkarrServer {
|
||||
pub fn new(config: &Config, port: u16) -> Result<Self> {
|
||||
pub fn new(config: &Config, https_port: u16, http_port: u16) -> Result<Self> {
|
||||
let mut dht_config = mainline::Config::default();
|
||||
|
||||
if let Some(bootstrap) = config.bootstrap.clone() {
|
||||
@@ -23,7 +23,7 @@ impl PkarrServer {
|
||||
|
||||
let client = pkarr::Client::builder().dht_config(dht_config).build()?;
|
||||
|
||||
let signed_packet = create_signed_packet(config, port)?;
|
||||
let signed_packet = create_signed_packet(config, https_port, http_port)?;
|
||||
|
||||
Ok(Self {
|
||||
client,
|
||||
@@ -41,7 +41,7 @@ impl PkarrServer {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_signed_packet(config: &Config, port: u16) -> Result<SignedPacket> {
|
||||
pub fn create_signed_packet(config: &Config, port: u16, http_port: u16) -> Result<SignedPacket> {
|
||||
// TODO: Try to resolve first before publishing.
|
||||
|
||||
let default = ".".to_string();
|
||||
|
||||
Reference in New Issue
Block a user