mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
Add covert-dtls to proxy and client with flags
This commit is contained in:
parent
ae5bd52821
commit
541e124194
8 changed files with 88 additions and 16 deletions
|
@ -41,8 +41,11 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/pion/dtls/v3"
|
||||
"github.com/pion/transport/v3/stdnet"
|
||||
"github.com/pion/webrtc/v4"
|
||||
"github.com/theodorsm/covert-dtls/pkg/mimicry"
|
||||
"github.com/theodorsm/covert-dtls/pkg/randomize"
|
||||
|
||||
"gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/event"
|
||||
"gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/messages"
|
||||
|
@ -165,6 +168,9 @@ type SnowflakeProxy struct {
|
|||
|
||||
periodicProxyStats *periodicProxyStats
|
||||
bytesLogger bytesLogger
|
||||
|
||||
DTLSRandomize bool
|
||||
DTLSMimic bool
|
||||
}
|
||||
|
||||
// Checks whether an IP address is a remote address for the client
|
||||
|
@ -423,6 +429,23 @@ func (sf *SnowflakeProxy) makeWebRTCAPI() *webrtc.API {
|
|||
|
||||
settingsEngine.SetDTLSInsecureSkipHelloVerify(true)
|
||||
|
||||
if sf.DTLSRandomize {
|
||||
rand := randomize.RandomizedMessageClientHello{RandomALPN: true}
|
||||
settingsEngine.SetDTLSClientHelloMessageHook(rand.Hook)
|
||||
} else if sf.DTLSMimic {
|
||||
mimic := &mimicry.MimickedClientHello{}
|
||||
profiles := []dtls.SRTPProtectionProfile{
|
||||
dtls.SRTP_AES128_CM_HMAC_SHA1_80,
|
||||
dtls.SRTP_AES128_CM_HMAC_SHA1_32,
|
||||
dtls.SRTP_AEAD_AES_128_GCM,
|
||||
dtls.SRTP_AEAD_AES_256_GCM,
|
||||
dtls.SRTP_AES256_CM_SHA1_32,
|
||||
dtls.SRTP_AES256_CM_SHA1_80,
|
||||
}
|
||||
settingsEngine.SetSRTPProtectionProfiles(profiles...)
|
||||
settingsEngine.SetDTLSClientHelloMessageHook(mimic.Hook)
|
||||
}
|
||||
|
||||
return webrtc.NewAPI(webrtc.WithSettingEngine(settingsEngine))
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,8 @@ func main() {
|
|||
verboseLogging := flag.Bool("verbose", false, "increase log verbosity")
|
||||
ephemeralPortsRangeFlag := flag.String("ephemeral-ports-range", "", "Set the `range` of ports used for client connections (format:\"<min>:<max>\").\nIf omitted, the ports will be chosen automatically.")
|
||||
versionFlag := flag.Bool("version", false, "display version info to stderr and quit")
|
||||
dtlsRandomize := flag.Bool("dtls-randomize", false, "randomize DTLS client hello")
|
||||
dtlsMimic := flag.Bool("dtls-mimic", false, "mimic DTLS client hello of Chrome and Firefox")
|
||||
|
||||
var ephemeralPortsRange []uint16 = []uint16{0, 0}
|
||||
|
||||
|
@ -64,6 +66,10 @@ func main() {
|
|||
log.Fatal("Cannot keep local address candidates when outbound address is specified")
|
||||
}
|
||||
|
||||
if *dtlsMimic && *dtlsRandomize {
|
||||
log.Fatal("Cannot both Randomize and Mimic DTLS client hello")
|
||||
}
|
||||
|
||||
eventLogger := event.NewSnowflakeEventDispatcher()
|
||||
|
||||
if *ephemeralPortsRangeFlag != "" {
|
||||
|
@ -112,6 +118,8 @@ func main() {
|
|||
AllowNonTLSRelay: *allowNonTLSRelay,
|
||||
|
||||
SummaryInterval: *summaryInterval,
|
||||
DTLSRandomize: *dtlsRandomize,
|
||||
DTLSMimic: *dtlsMimic,
|
||||
}
|
||||
|
||||
var logOutput = io.Discard
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue