예제 #1
0
파일: proxy.go 프로젝트: keyphact/pso2-go
func (h proxyHandlerCipher) HandlePacket(c *Connection, p *packets.Packet) (bool, error) {
	Logger.Debugf("%s %s cipher packet, re-encrypting", h.proxy, c)

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

	key, err := b.Key(h.privateKey)
	if err != nil {
		return false, err
	}

	rc4key, err := packets.CipherRC4Key(key)
	if err != nil {
		return false, err
	}

	b.SetKey(key, h.publicKey)

	p, err = b.Packet()
	if err != nil {
		return false, err
	}

	dest := h.proxy.Destination(c)
	err = dest.WritePacket(p)
	if err == nil {
		err = dest.SetCipher(rc4key)
	}

	return true, err
}
예제 #2
0
func (h handlerCipher) HandlePacket(c *Connection, p *packets.Packet) (bool, error) {
	Logger.Debugf("%s cipher packet, enabling encryption", c)

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

	key, err := b.RC4Key(h.privateKey)
	if err != nil {
		return false, err
	}

	err = c.SetCipher(key)

	return true, err
}