Tailscale.Udp (Tailscale v0.3.3)

View Source

Tailscale UDP sockets.

Summary

Types

t()

A handle to a tailscale UDP socket.

Functions

Bind a UDP socket on the specified port.

Get the local address on which this UDP socket is bound.

Receive a packet from the socket, blocking until one is ready.

Send a packet to a specified remote address.

Types

t()

@opaque t()

A handle to a tailscale UDP socket.

Functions

bind(dev, addr, port)

@spec bind(Tailscale.t(), Tailscale.ip_addr() | :ip4 | :ip6, :inet.port_number()) ::
  {:ok, t()} | {:error, any()}

Bind a UDP socket on the specified port.

Parameters

  • dev: the tailscale device on which to bind a socket.
  • addr: the address to bind to. Passing :ip4 or :ip6 will cause the socket to bind to the
        tailscale node's respective tailnet ip.
  • port: the port number to bind.

local_addr(sock)

@spec local_addr(t()) :: {:inet.ip_address(), :inet.port_number()}

Get the local address on which this UDP socket is bound.

recv(sock)

@spec recv(t()) ::
  {:ok, Tailscale.ip_addr(), :inet.port_number(), binary()} | {:error, any()}

Receive a packet from the socket, blocking until one is ready.

send(sock, remote, port, payload)

@spec send(t(), Tailscale.ip_addr(), :inet.port_number(), binary()) ::
  :ok | {:error, any()}

Send a packet to a specified remote address.

Parameters

  • sock: the socket to send on
  • remote: the host to deliver the packet to. DNS is not yet supported: this must be an IP address for now.
  • port: the port on the remote host the packet should be delivered to.
  • payload: the message payload.