forked from quic-go/quic-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scheduler.go
53 lines (43 loc) · 983 Bytes
/
scheduler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package quic
import "net"
type direcionAddr uint8
const (
local = direcionAddr(0)
remote = direcionAddr(1)
)
type schedulerOperation uint8
const (
roundRobin = schedulerOperation(0)
weightBased = schedulerOperation(1)
)
type Scheduler interface {
Write([]byte) error
Read([]byte) (int, net.Addr, error)
Close() error
LocalAddr() net.Addr
RemoteAddr() net.Addr
SetCurrentRemoteAddr(net.Addr)
IsInitialised() bool
SetIsInitialised(bool)
IsActive() bool
Activate(bool)
}
func xor(local, remote []byte) []byte {
rval := make([]byte, 0)
for i := 0; i < len(local); i++ {
rval = append(rval, local[i])
}
for i := 0; i < len(remote); i++ {
rval = append(rval, remote[i])
}
return rval
}
func isSameVersion(local, remote net.Addr) bool {
if local.(*net.UDPAddr).IP.To4() == nil && remote.(*net.UDPAddr).IP.To4() == nil {
return true
}
if local.(*net.UDPAddr).IP.To4() != nil && remote.(*net.UDPAddr).IP.To4() != nil {
return true
}
return false
}