package module
Version: v0.0.0-...-0de3fda Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2014 License: BSD-3-Clause Imports: 10 Imported by: 0



Netclip is a protocol for synchronizing the text clipboard of two or more peers in the same local network. It provides confidentiality and supports multiple concurrent users.

A reference client is available at


The protocol exchanges packets on UDP port 2547 over the link-local multicast address.

Message structure
| Magic | HMAC | IV | Time | Len | Payload | Pad |
  • Magic (4 bytes) is the ASCII encoding of the string 'CLIP'.

  • HMAC (32 bytes) is the SHA-256 Keyed-Hash Message Authentication Code (FIPS 198) for the remainder of the message (IV, Time, Len, Payload, Pad).

  • IV (16 bytes) is an initialization vector for the encryption algorithm.

The remainder of the message (Time, Len, Payload, Pad) is encrypted in AES-256 CBC mode (FIPS 197) with initialization vector IV.

  • Time (8 bytes) is a 64-bit Unix time in network byte order.

  • Len (2 bytes) is the payload length in bytes, in network byte order.

  • Payload (variable length) is a UTF-8 encoded text string.

  • Pad (variable length) are zero or more null bytes such that the length of (Time, Len, Payload, Pad) is a multiple of 16 bytes.


All protocol peers belonging to the same user must use a shared key used for encryption/decryption and message authentication. This provides confidentiality and allows the rejection of messages intended for other users running the protocol in the same local network.

The protocol provides limited protection against replay attacks. A message whose Time does not belong to a 1-minute window centered on the current 64-bit Unix time is rejected. As a consequence, clock synchronization is required among protocol peers.

Message delivery is not guaranteed. The protocol makes no provisions for the acknowledgement or retransmission of messages.

Message size cannot exceed 65507 bytes, the maximum data length for a UDP packet. The system's TCP/IP stack may impose a lower limit.



Package netclip implements a protocol for synchronizing a text clipboard over the local network.



View Source
const (
	KeySize = aes.BlockSize


This section is empty.


This section is empty.


type Peer

type Peer struct {
	Key []byte
	// contains filtered or unexported fields

func NewPeer

func NewPeer(key []byte) *Peer

NewPeer creates a new peer with the given key.

func (*Peer) Close

func (p *Peer) Close()

Close disconnects the peer from the network.

func (*Peer) Connect

func (p *Peer) Connect() error

Connect connects the peer to the network.

func (*Peer) Recv

func (p *Peer) Recv() (string, net.Addr, error)

Recv receives the next message from the network.

func (*Peer) Send

func (p *Peer) Send(s string) error

Send sends a message to other peers in the network.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL