Skip to content

Commit

Permalink
fix naming
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddify-com committed Feb 13, 2024
1 parent f2b65f6 commit e395215
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion device/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (device *Device) NewPeer(pk NoisePublicKey) (*Peer, error) {

// create peer
peer := new(Peer)

peer.stopCh = make(chan int, 1)
peer.cookieGenerator.Init(pk)
peer.device = device
peer.queue.outbound = newAutodrainingOutboundQueue(device)
Expand Down
8 changes: 4 additions & 4 deletions device/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,12 +636,12 @@ func (peer *Peer) RoutineSequentialSender(maxBatchSize int) {

func sendNoise(peer *Peer) error {
fakePackets := []int{8, 15}
delays := []int{200 * int(time.Millisecond), 500 * int(time.Millisecond)}
packetSize := []int{40, 100}
fakePacketsSize := []int{40, 100}
fakePacketsDelays := []int{200, 500}
numPackets := randomInt(fakePackets[0], fakePackets[1])
for i := 0; i < numPackets; i++ {
// Generate a random packet size between 10 and 40 bytes
packetSize := randomInt(packetSize[0], packetSize[1])
packetSize := randomInt(fakePacketsSize[0], fakePacketsSize[1])
randomPacket := make([]byte, packetSize)
_, err := rand.Read(randomPacket)
if err != nil {
Expand All @@ -656,7 +656,7 @@ func sendNoise(peer *Peer) error {
if i < numPackets-1 && peer.isRunning.Load() && !peer.device.isClosed() {
select {
case <-peer.stopCh:
case <-time.After(time.Duration(randomInt(delays[0], delays[1]))):
case <-time.After(time.Duration(randomInt(fakePacketsDelays[0], fakePacketsDelays[1])) * time.Millisecond):
default:
}

Expand Down

0 comments on commit e395215

Please sign in to comment.