GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Commit 1867f895 authored by Arlo Breault's avatar Arlo Breault
Browse files

Remove local LAN address ICE candidates in proxy-go answer

Trac: 19026
parent 670e4ba4
...@@ -70,8 +70,9 @@ func remoteIPFromSDP(sdp string) net.IP { ...@@ -70,8 +70,9 @@ func remoteIPFromSDP(sdp string) net.IP {
} }
type Broker struct { type Broker struct {
url *url.URL url *url.URL
transport http.RoundTripper transport http.RoundTripper
keepLocalAddresses bool
} }
type webRTCConn struct { type webRTCConn struct {
...@@ -209,7 +210,14 @@ func (b *Broker) pollOffer(sid string) *webrtc.SessionDescription { ...@@ -209,7 +210,14 @@ func (b *Broker) pollOffer(sid string) *webrtc.SessionDescription {
func (b *Broker) sendAnswer(sid string, pc *webrtc.PeerConnection) error { func (b *Broker) sendAnswer(sid string, pc *webrtc.PeerConnection) error {
brokerPath := b.url.ResolveReference(&url.URL{Path: "answer"}) brokerPath := b.url.ResolveReference(&url.URL{Path: "answer"})
answer := string([]byte(util.SerializeSessionDescription(pc.LocalDescription()))) ld := pc.LocalDescription()
if !b.keepLocalAddresses {
ld = &webrtc.SessionDescription{
Type: ld.Type,
SDP: util.StripLocalAddresses(ld.SDP),
}
}
answer := string([]byte(util.SerializeSessionDescription(ld)))
body, err := messages.EncodeAnswerRequest(answer, sid) body, err := messages.EncodeAnswerRequest(answer, sid)
if err != nil { if err != nil {
return err return err
...@@ -409,6 +417,7 @@ func main() { ...@@ -409,6 +417,7 @@ func main() {
var logFilename string var logFilename string
var rawBrokerURL string var rawBrokerURL string
var unsafeLogging bool var unsafeLogging bool
var keepLocalAddresses bool
flag.UintVar(&capacity, "capacity", 10, "maximum concurrent clients") flag.UintVar(&capacity, "capacity", 10, "maximum concurrent clients")
flag.StringVar(&rawBrokerURL, "broker", defaultBrokerURL, "broker URL") flag.StringVar(&rawBrokerURL, "broker", defaultBrokerURL, "broker URL")
...@@ -416,6 +425,7 @@ func main() { ...@@ -416,6 +425,7 @@ func main() {
flag.StringVar(&stunURL, "stun", defaultSTUNURL, "stun URL") flag.StringVar(&stunURL, "stun", defaultSTUNURL, "stun URL")
flag.StringVar(&logFilename, "log", "", "log filename") flag.StringVar(&logFilename, "log", "", "log filename")
flag.BoolVar(&unsafeLogging, "unsafe-logging", false, "prevent logs from being scrubbed") flag.BoolVar(&unsafeLogging, "unsafe-logging", false, "prevent logs from being scrubbed")
flag.BoolVar(&keepLocalAddresses, "keep-local-addresses", false, "keep local LAN address ICE candidates")
flag.Parse() flag.Parse()
var logOutput io.Writer = os.Stderr var logOutput io.Writer = os.Stderr
...@@ -439,6 +449,7 @@ func main() { ...@@ -439,6 +449,7 @@ func main() {
var err error var err error
broker = new(Broker) broker = new(Broker)
broker.keepLocalAddresses = keepLocalAddresses
broker.url, err = url.Parse(rawBrokerURL) broker.url, err = url.Parse(rawBrokerURL)
if err != nil { if err != nil {
log.Fatalf("invalid broker url: %s", err) log.Fatalf("invalid broker url: %s", err)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment