Skip to content

Commit 6b7714e

Browse files
authored
Merge pull request #77 from muxinc/msmith/drop-packets-wrong-source
Add a configuration option to drop packets from an unexpected source address
2 parents 89db716 + aeec697 commit 6b7714e

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ type Config struct {
169169

170170
// An implementation of the Logger interface
171171
Logger Logger
172+
173+
// if a new IP starts sending data on an existing socket id, allow it
174+
AllowPeerIpChange bool
172175
}
173176

174177
// DefaultConfig is the default configuration for a SRT connection
@@ -209,6 +212,7 @@ var defaultConfig Config = Config{
209212
TooLatePacketDrop: true,
210213
TransmissionType: "live",
211214
TSBPDMode: true,
215+
AllowPeerIpChange: false,
212216
}
213217

214218
// DefaultConfig returns the default configuration for Dial and Listen.

listen.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,14 @@ func (ln *listener) reader(ctx context.Context) {
407407
break
408408
}
409409

410+
if !ln.config.AllowPeerIpChange {
411+
if p.Header().Addr.String() != conn.RemoteAddr().String() {
412+
// ignore the packet, it's not from the expected peer
413+
// https://haivision.github.io/srt-rfc/draft-sharabayko-srt.html#name-security-considerations
414+
break
415+
}
416+
}
417+
410418
conn.push(p)
411419
}
412420
}

0 commit comments

Comments
 (0)