Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/service/scraper/event.go
Jeff Becker 1089883ed5 initial
2017-05-10 13:29:35 -04:00

37 lignes
565 o
Go

package scraperService
import (
"encoding/binary"
"net"
)
type RecvEvent struct {
From net.Addr
Data []byte
}
// TID extract transaction id
func (ev *RecvEvent) TID() (id uint32, err error) {
if len(ev.Data) < 8 {
err = ErrShortPacket
} else {
id = binary.BigEndian.Uint32(ev.Data[4:])
}
return
}
// Action extract action
func (ev *RecvEvent) Action() (action uint32, err error) {
if len(ev.Data) < 4 {
err = ErrShortPacket
} else {
action = binary.BigEndian.Uint32(ev.Data)
}
return
}
type SendEvent struct {
To net.Addr
Data []byte
}