Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client can send to or receive from a relay server.
func NewClient ¶
NewClient creates a new Client that will communicate with the server at the specified address.
func (*Client) Offer ¶
Offer offers a file, with a proposed filename, to a recipient via the relay server.
It does not block on sending the file, but instead returns the file's secret immediately along with a blocking function to send the file's contents.
secret, send, _ := client.Offer(filename, file) fmt.Println(secret) // immediately show the secret _ = send() // wait for the file to be sent
type Handler ¶
Handler is the HTTP request handler that relays messages between clients.
func NewHandler ¶
NewHandler returns a new Handler.
It generates secret strings via the provided Stringer and logs events to the provided Writer.
type Secrets ¶
type Secrets struct {
// contains filtered or unexported fields
}
Secrets is a generator that provides unique secret strings in the form "first-second-third."
func NewSecrets ¶
NewSecrets returns a new secret generator based on the provided random-number generator.
If `rng` is deterministic, the secret strings will be as well, so be sure to seed your generator with something pseudo-random like the current time in order to generate unique secrets.
Example ¶
rng := rand.New(rand.NewSource(time.Now().UnixNano())) secrets := NewSecrets(rng) fmt.Println(secrets.String())
Output: