This introduces interfaces to represent the packet forwarding mechanism, and brings all the scattered UDP-related code together into a single implementation. This is not a pure refactoring, although much of the code in sleeve.go has been copied from pre-existing code, and the UDP protocol remains the same in spirit. The biggest change is the organization of the forwarder goroutines (there is now one instead of two, and that goroutine does a lot of auxiliary work as well as forwarding). Performance testing between VMs on my laptop suggests that packet throughput has not gone down, and may even have improved slightly.
18 lines
317 B
Go
18 lines
317 B
Go
package router
|
|
|
|
import (
|
|
"math"
|
|
"time"
|
|
)
|
|
|
|
const (
|
|
Port = 6783
|
|
HTTPPort = Port + 1
|
|
MaxUDPPacketSize = 65535
|
|
ChannelSize = 16
|
|
TCPHeartbeat = 30 * time.Second
|
|
GossipInterval = 30 * time.Second
|
|
MaxDuration = time.Duration(math.MaxInt64)
|
|
MaxTCPMsgSize = 10 * 1024 * 1024
|
|
)
|