Skip to content

Commit

Permalink
derp: sprinkle comments and docstrings.
Browse files Browse the repository at this point in the history
Signed-off-by: David Anderson <dave@natulte.net>
  • Loading branch information
danderson committed Mar 20, 2020
1 parent 24235c6 commit ea1a413
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions derp/derp_server.go
Expand Up @@ -51,11 +51,11 @@ type Server struct {
packetsRecv, bytesRecv expvar.Int
packetsDropped expvar.Int
packetsDroppedReason metrics.LabelMap
packetsDroppedUnknown *expvar.Int
packetsDroppedGone *expvar.Int
packetsDroppedQueueHead *expvar.Int
packetsDroppedQueueTail *expvar.Int
packetsDroppedWrite *expvar.Int
packetsDroppedUnknown *expvar.Int // unknown dst pubkey
packetsDroppedGone *expvar.Int // dst conn shutting down
packetsDroppedQueueHead *expvar.Int // queue full, drop head packet
packetsDroppedQueueTail *expvar.Int // queue full, drop tail packet
packetsDroppedWrite *expvar.Int // error writing to dst conn
accepts expvar.Int
curClients expvar.Int
curHomeClients expvar.Int // ones with preferred
Expand Down Expand Up @@ -486,7 +486,7 @@ type sclient struct {

type pkt struct {
src key.Public
bs []byte
bs []byte // pkt owns backing array
// TODO(danderson): enqueue time, to measure queue latency?
}

Expand Down Expand Up @@ -587,6 +587,10 @@ func (c *sclient) sendKeepalive() error {
return c.bw.Flush()
}

// sendPacket writes contents to the client in a RecvPacket frame. If
// srcKey.IsZero, uses the old DERPv1 framing format, otherwise uses
// DERPv2. The bytes of contents are only valid until this function
// returns, do not retain slices.
func (c *sclient) sendPacket(srcKey key.Public, contents []byte) (err error) {
defer func() {
// Stats update.
Expand Down

0 comments on commit ea1a413

Please sign in to comment.