bigeagle / gohop

A VPN implemention in golang, with crypto and obfuscation in nature.
1.33k stars 195 forks source link

Some questions about source code #16

Open FTwOoO opened 8 years ago

FTwOoO commented 8 years ago

After reading the source code of gohop, i have 2 questions about the implementation that i don't understand, could u explain it?

  1. What does the 'rate' mean in hopPacketBuffer:Pop(), to delay the pop operation? What does the algorithm means?

    func (hb *hopPacketBuffer) Pop() *HopPacket {
    <-hb.newPack
    r := int(hb.rate & 0x10)
    if hb.buf.count < 8+r {
       time.Sleep(time.Duration(r*20+50) * time.Microsecond)
       hb.rate = hb.rate >> 1
    }
    p := hb.buf.Pop().(*HopPacket)
    return p
    }
  2. For the PKCS5UnPadding method, if there's no padding, this method will still get the last byte as padding length, is it wrong ?

    func PKCS5UnPadding(origData []byte) []byte {
    length := len(origData)
    unpadding := int(origData[length-1])
    return origData[:(length - unpadding)]
    }
  3. If one of the port between [HopStart, HopEnd] is blocked, the client knowns nothing about that, and still trying to forward packets to the port blocked (because of handshake succed on another port), without retrying and port switching ?