func (t *Tracker) CreatePeer(announce *Announce) *data.Peer { log.Print("assigning IP to peer: %s", t.RemoteHost) peer := new(data.Peer) peer.PeerId = []byte(announce.PeerId) peer.Ip = t.RemoteHost peer.Port = int32(announce.Port) peer.InfoHash = []byte(announce.InfoHash) peer.IsIpV6 = t.IsIpV6 peer.Save() return peer }
func (t *Tracker) UpdatePeer(peer *data.Peer, announce *Announce) { peer.Port = int32(announce.Port) peer.Ip = t.RemoteHost peer.IsIpV6 = t.IsIpV6 peer.Update() }