Beispiel #1
0
	// initialConnectionID is the magic initial connection ID specified by BEP 15.
	initialConnectionID = []byte{0, 0, 0x04, 0x17, 0x27, 0x10, 0x19, 0x80}

	// emptyIPs are the value of an IP field that has been left blank.
	emptyIPv4 = []byte{0, 0, 0, 0}
	emptyIPv6 = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

	// eventIDs map IDs to event names.
	eventIDs = []string{
		"",
		"completed",
		"started",
		"stopped",
	}

	errMalformedPacket = models.ProtocolError("malformed packet")
	errMalformedIP     = models.ProtocolError("malformed IP address")
	errMalformedEvent  = models.ProtocolError("malformed event ID")
	errUnknownAction   = models.ProtocolError("unknown action ID")
	errBadConnectionID = errors.New("bad connection ID")
)

// handleTorrentError writes err to w if err is a models.ClientError.
func handleTorrentError(err error, w *Writer) {
	if err == nil {
		return
	}

	if models.IsPublicError(err) {
		w.WriteError(err)
		stats.RecordEvent(stats.ClientError)
Beispiel #2
0
	// Option-Types described in BEP41 and BEP45.
	optionEndOfOptions = byte(0x0)
	optionNOP          = byte(0x1)
	optionURLData      = byte(0x2)
	optionIPv6         = byte(0x3)

	// eventIDs map IDs to event names.
	eventIDs = []string{
		"",
		"completed",
		"started",
		"stopped",
	}

	errMalformedPacket = models.ProtocolError("malformed packet")
	errMalformedIP     = models.ProtocolError("malformed IP address")
	errMalformedEvent  = models.ProtocolError("malformed event ID")
	errBadConnectionID = models.ProtocolError("bad connection ID")
)

// handleTorrentError writes err to w if err is a models.ClientError.
func handleTorrentError(err error, w *Writer) {
	if err == nil {
		return
	}

	if models.IsPublicError(err) {
		w.WriteError(err)
		stats.RecordEvent(stats.ClientError)
	}
Beispiel #3
0
	// Option-Types described in BEP41 and BEP45.
	optionEndOfOptions = byte(0x0)
	optionNOP          = byte(0x1)
	optionURLData      = byte(0x2)
	optionIPv6         = byte(0x3)

	// eventIDs map IDs to event names.
	eventIDs = []string{
		"",
		"completed",
		"started",
		"stopped",
	}

	errMalformedPacket = models.ProtocolError("malformed packet")
	errMalformedIP     = models.ProtocolError("malformed IP address")
	errMalformedEvent  = models.ProtocolError("malformed event ID")
	errBadConnectionID = errors.New("bad connection ID")
)

// handleTorrentError writes err to w if err is a models.ClientError.
func handleTorrentError(err error, w *Writer) {
	if err == nil {
		return
	}

	if models.IsPublicError(err) {
		w.WriteError(err)
		stats.RecordEvent(stats.ClientError)
	}