Ejemplo n.º 1
0
func (h proxyHandlerBlocks) HandlePacket(c *Connection, p *packets.Packet) (bool, error) {
	Logger.Debugf("%s %s block list packet, rewriting addresses", h.proxy, c)

	b, err := packets.ParseBlocks(p)
	if err != nil {
		return false, err
	}

	for i := range b.Entries {
		e := &b.Entries[i]
		h.listener.EndpointAnnouncement(e.Address(), e.Port)
		e.SetAddress(h.addr)
	}

	packetType := p.Type
	p, err = b.Packet()

	if err != nil {
		return false, err
	}

	p.Type = packetType

	return true, h.proxy.Destination(c).WritePacket(p)
}
Ejemplo n.º 2
0
func (h proxyHandlerRoom) HandlePacket(c *Connection, p *packets.Packet) (bool, error) {
	Logger.Debugf("%s %s room packet, rewriting address", h.proxy, c)

	r, err := packets.ParseRoom(p)
	if err != nil {
		return false, err
	}

	h.listener.EndpointAnnouncement(r.Address(), r.Port)
	r.SetAddress(h.addr)

	packetType := p.Type
	p, err = r.Packet()

	if err != nil {
		return false, err
	}

	p.Type = packetType

	return true, h.proxy.Destination(c).WritePacket(p)
}