Creating an Endpoint
This method initializes a new endpoint and binds it to a local address, allowing it to listen for incoming connections.bindcreates the endpoint and starts listening for incoming connectionsawaitkeyword is used to wait for the endpoint to be created in an asynchronous context.
Each time you
bind without supplying a secret key, iroh generates a brand
new random identity. That means a different EndpointId — and therefore
different tickets and addresses — every time your program starts. If you want a
stable identity that survives restarts, see Persistent
identity below.Persistent identity
An endpoint’s identity is an Ed25519 keypair. The public half is itsEndpointId (the stable address other endpoints dial); the private half is its
SecretKey. By default the builder generates a fresh SecretKey on every
launch, so your EndpointId changes each run.
For most applications — anything where peers reconnect to you over time, or
where you hand out a ticket that should keep working — you want a persistent
identity. To get one, generate a SecretKey once, store it, and load the same
key on every subsequent launch:
Your
SecretKey is sensitive: anyone who has it can impersonate your endpoint.
Store it the way you’d store a private key or password — file permissions, a
keychain, or an OS secret store — not in source control.