packets.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright (C) 2014 The Syncthing Authors.
  2. //
  3. // This program is free software: you can redistribute it and/or modify it
  4. // under the terms of the GNU General Public License as published by the Free
  5. // Software Foundation, either version 3 of the License, or (at your option)
  6. // any later version.
  7. //
  8. // This program is distributed in the hope that it will be useful, but WITHOUT
  9. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. // more details.
  12. //
  13. // You should have received a copy of the GNU General Public License along
  14. // with this program. If not, see <http://www.gnu.org/licenses/>.
  15. //go:generate -command genxdr go run ../../Godeps/_workspace/src/github.com/calmh/xdr/cmd/genxdr/main.go
  16. //go:generate genxdr -o packets_xdr.go packets.go
  17. package discover
  18. const (
  19. AnnouncementMagic = 0x9D79BC39
  20. QueryMagic = 0x2CA856F5
  21. )
  22. type Query struct {
  23. Magic uint32
  24. DeviceID []byte // max:32
  25. }
  26. type Announce struct {
  27. Magic uint32
  28. This Device
  29. Extra []Device // max:16
  30. }
  31. type Device struct {
  32. ID []byte // max:32
  33. Addresses []Address // max:16
  34. }
  35. type Address struct {
  36. IP []byte // max:16
  37. Port uint16
  38. }