Add Ignore Android Restriction Workaround for Proxy

This commit is contained in:
n8fr8 2023-11-30 14:05:18 +00:00 committed by Shelikhoo
parent cd0167fe65
commit 36a8eb487f
No known key found for this signature in database
GPG key ID: C4D5E79D22B25316

View file

@ -42,6 +42,7 @@ import (
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"github.com/pion/ice/v2" "github.com/pion/ice/v2"
"github.com/pion/transport/v2/stdnet"
"github.com/pion/webrtc/v3" "github.com/pion/webrtc/v3"
"gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/event" "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/event"
"gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/messages" "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/messages"
@ -374,6 +375,13 @@ func (d dataChannelHandlerWithRelayURL) datachannelHandler(conn *webRTCConn, rem
func (sf *SnowflakeProxy) makeWebRTCAPI() *webrtc.API { func (sf *SnowflakeProxy) makeWebRTCAPI() *webrtc.API {
settingsEngine := webrtc.SettingEngine{} settingsEngine := webrtc.SettingEngine{}
// Use the SetNet setting https://pkg.go.dev/github.com/pion/webrtc/v3#SettingEngine.SetNet
// to get snowflake working in shadow (where the AF_NETLINK family is not implemented).
// These two lines of code functionally revert a new change in pion by silently ignoring
// when net.Interfaces() fails, rather than throwing an error
vnet, _ := stdnet.NewNet()
settingsEngine.SetNet(vnet)
if sf.EphemeralMinPort != 0 && sf.EphemeralMaxPort != 0 { if sf.EphemeralMinPort != 0 && sf.EphemeralMaxPort != 0 {
err := settingsEngine.SetEphemeralUDPPortRange(sf.EphemeralMinPort, sf.EphemeralMaxPort) err := settingsEngine.SetEphemeralUDPPortRange(sf.EphemeralMinPort, sf.EphemeralMaxPort)
if err != nil { if err != nil {