Skip to content

Commit

Permalink
support ipv6 link-local addresses; fix #6
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed May 3, 2020
1 parent 6cb36ab commit 0b38b3c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,17 @@ func (p *program) forwardTrack(path string, id int, flow trackFlow, frame []byte
if flow == _TRACK_FLOW_RTP {
p.rtpl.chanWrite <- &udpWrite{
addr: &net.UDPAddr{
IP: c.ip,
IP: c.ip(),
Zone: c.zone(),
Port: c.streamTracks[id].rtpPort,
},
buf: frame,
}
} else {
p.rtcpl.chanWrite <- &udpWrite{
addr: &net.UDPAddr{
IP: c.ip,
IP: c.ip(),
Zone: c.zone(),
Port: c.streamTracks[id].rtcpPort,
},
buf: frame,
Expand Down
12 changes: 8 additions & 4 deletions server-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ type serverClient struct {
p *program
conn *gortsplib.ConnServer
state clientState
ip net.IP
path string
as *gortsplib.AuthServer
streamSdpText []byte // filled only if publisher
Expand Down Expand Up @@ -164,6 +163,14 @@ func (c *serverClient) log(format string, args ...interface{}) {
fmt.Sprintf(format, args...))
}

func (c *serverClient) ip() net.IP {
return c.conn.NetConn().RemoteAddr().(*net.TCPAddr).IP
}

func (c *serverClient) zone() string {
return c.conn.NetConn().RemoteAddr().(*net.TCPAddr).Zone
}

func (c *serverClient) run() {
defer func() {
if c.p.postScript != "" {
Expand All @@ -183,9 +190,6 @@ func (c *serverClient) run() {
c.close()
}()

ipstr, _, _ := net.SplitHostPort(c.conn.NetConn().RemoteAddr().String())
c.ip = net.ParseIP(ipstr)

c.log("connected")

if c.p.preScript != "" {
Expand Down
2 changes: 1 addition & 1 deletion server-udpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (l *serverUdpListener) run() {
path, trackId := func() (string, int) {
for _, pub := range l.p.publishers {
for i, t := range pub.streamTracks {
if !pub.ip.Equal(addr.IP) {
if !pub.ip().Equal(addr.IP) {
continue
}

Expand Down

0 comments on commit 0b38b3c

Please sign in to comment.