5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-29 17:51:35 +00:00

Merge pull request #170 from neilalexander/backpressure

Only split queues based on port number for TCP/UDP/SCTP
This commit is contained in:
Arceliar 2018-07-22 10:43:26 -05:00 committed by GitHub
commit 98f1dd1624
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -445,9 +445,16 @@ func (sinfo *sessionInfo) doSend(bs []byte) {
coords = append(coords, sinfo.coords...) // Start with the real coords coords = append(coords, sinfo.coords...) // Start with the real coords
coords = append(coords, 0) // Add an explicit 0 for the destination's self peer coords = append(coords, 0) // Add an explicit 0 for the destination's self peer
addUint64(bs[6:7]) // Byte 6, next header type (e.g. TCP vs UDP) addUint64(bs[6:7]) // Byte 6, next header type (e.g. TCP vs UDP)
// TODO parse headers, in case the next header isn't TCP/UDP for some reason // Is the next header TCP, UDP, SCTP for finding source port?
addUint64(bs[40:42]) // Bytes 40-41, source port for TCP/UDP // 0x06 (6) = TCP, 0x11 (17) = UDP, 0x84 (132) = SCTP
addUint64(bs[42:44]) // Bytes 42-43, destination port for TCP/UDP // TODO: Perhaps improve this for other protocols
// TODO: Consider that the Next Header could be an IPv6 Extension Header instead
if bs[6:7][0] == 0x06 || bs[6:7][0] == 0x11 || bs[6:7][0] == 0x84 {
if len(bs) > 44 {
addUint64(bs[40:42]) // Bytes 40-41, source port for TCP/UDP/SCTP
addUint64(bs[42:44]) // Bytes 42-43, destination port for TCP/UDP/SCTP
}
}
payload, nonce := boxSeal(&sinfo.sharedSesKey, bs, &sinfo.myNonce) payload, nonce := boxSeal(&sinfo.sharedSesKey, bs, &sinfo.myNonce)
defer util_putBytes(payload) defer util_putBytes(payload)
p := wire_trafficPacket{ p := wire_trafficPacket{