Skip to content

Commit 03abb9c

Browse files
matrssMatthias Riße
andauthored
fix: make generate-ticket create ID-only tickets (#88)
Co-authored-by: Matthias Riße <matrss@0px.xyz>
1 parent d78922c commit 03abb9c

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

src/main.rs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub enum Commands {
4747
///
4848
/// This command only really makes sense when you are providing dumbpipe with a
4949
/// secret key.
50-
GenerateTicket(GenerateTicketArgs),
50+
GenerateTicket,
5151

5252
/// Listen on an endpoint and forward stdin/stdout to the first incoming
5353
/// bidi stream.
@@ -155,12 +155,6 @@ fn parse_alpn(alpn: &str) -> Result<Vec<u8>> {
155155
})
156156
}
157157

158-
#[derive(Parser, Debug)]
159-
pub struct GenerateTicketArgs {
160-
#[clap(flatten)]
161-
pub common: CommonArgs,
162-
}
163-
164158
#[derive(Parser, Debug)]
165159
pub struct ListenArgs {
166160
/// Immediately close our sending side, indicating that we will not transmit any data
@@ -836,14 +830,12 @@ async fn connect_unix(args: ConnectUnixArgs) -> Result<()> {
836830
Ok(())
837831
}
838832

839-
async fn generate_ticket(args: GenerateTicketArgs) -> Result<()> {
833+
async fn generate_ticket() -> Result<()> {
840834
let secret_key = get_or_create_secret()?;
841-
let endpoint = create_endpoint(secret_key, &args.common, vec![args.common.alpn()?]).await?;
842-
// wait for the endpoint to figure out its home relay and addresses before making a ticket
843-
endpoint.online().await;
844-
let addr = endpoint.addr();
845-
let short = create_short_ticket(&addr);
846-
println!("{}", short);
835+
let public_key = secret_key.public();
836+
let addr = EndpointAddr::new(public_key);
837+
let ticket = EndpointTicket::new(addr);
838+
println!("{}", ticket);
847839
Ok(())
848840
}
849841

@@ -852,7 +844,7 @@ async fn main() -> Result<()> {
852844
tracing_subscriber::fmt::init();
853845
let args = Args::parse();
854846
let res = match args.command {
855-
Commands::GenerateTicket(args) => generate_ticket(args).await,
847+
Commands::GenerateTicket => generate_ticket().await,
856848
Commands::Listen(args) => listen_stdio(args).await,
857849
Commands::ListenTcp(args) => listen_tcp(args).await,
858850
Commands::Connect(args) => connect_stdio(args).await,

0 commit comments

Comments
 (0)