mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
Harmonize identifiers to uTLS
This commit is contained in:
parent
e3aeb5fe5b
commit
8d5998b744
4 changed files with 17 additions and 17 deletions
|
@ -56,14 +56,14 @@ func createBrokerTransport() http.RoundTripper {
|
|||
}
|
||||
|
||||
func NewBrokerChannel(broker, ampCache, front string, keepLocalAddresses bool) (*BrokerChannel, error) {
|
||||
return NewBrokerChannelWithUTlsSettings(broker, ampCache, front, keepLocalAddresses, "", false)
|
||||
return NewBrokerChannelWithUTLSSettings(broker, ampCache, front, keepLocalAddresses, "", false)
|
||||
}
|
||||
|
||||
// NewBrokerChannelWithUTlsSettings construct a new BrokerChannel, where:
|
||||
// NewBrokerChannelWithUTLSSettings construct a new BrokerChannel, where:
|
||||
// |broker| is the full URL of the facilitating program which assigns proxies
|
||||
// to clients, and |front| is the option fronting domain.
|
||||
func NewBrokerChannelWithUTlsSettings(broker, ampCache, front string, keepLocalAddresses bool,
|
||||
utlsClientID string, removeSNI bool) (*BrokerChannel, error) {
|
||||
func NewBrokerChannelWithUTLSSettings(broker, ampCache, front string, keepLocalAddresses bool,
|
||||
uTLSClientID string, removeSNI bool) (*BrokerChannel, error) {
|
||||
log.Println("Rendezvous using Broker at:", broker)
|
||||
if ampCache != "" {
|
||||
log.Println("Through AMP cache at:", ampCache)
|
||||
|
@ -74,8 +74,8 @@ func NewBrokerChannelWithUTlsSettings(broker, ampCache, front string, keepLocalA
|
|||
|
||||
brokerTransport := createBrokerTransport()
|
||||
|
||||
if utlsClientID != "" {
|
||||
utlsClientHelloID, err := utlsutil.NameToUTlsID(utlsClientID)
|
||||
if uTLSClientID != "" {
|
||||
utlsClientHelloID, err := utlsutil.NameToUTLSID(uTLSClientID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to create broker channel: %v", err)
|
||||
}
|
||||
|
|
|
@ -97,12 +97,12 @@ type ClientConfig struct {
|
|||
// Max is the maximum number of snowflake proxy peers that the client should attempt to
|
||||
// connect to. Defaults to 1.
|
||||
Max int
|
||||
// UTlsClientID is the type of user application that snowflake should imitate.
|
||||
// UTLSClientID is the type of user application that snowflake should imitate.
|
||||
// If an empty value is provided, it will use Go's default TLS implementation
|
||||
UTlsClientID string
|
||||
// UTlsRemoveSNI is the flag to control whether SNI should be removed from Client Hello
|
||||
UTLSClientID string
|
||||
// UTLSRemoveSNI is the flag to control whether SNI should be removed from Client Hello
|
||||
// when uTLS is used.
|
||||
UTlsRemoveSNI bool
|
||||
UTLSRemoveSNI bool
|
||||
}
|
||||
|
||||
// NewSnowflakeClient creates a new Snowflake transport client that can spawn multiple
|
||||
|
@ -131,9 +131,9 @@ func NewSnowflakeClient(config ClientConfig) (*Transport, error) {
|
|||
}
|
||||
|
||||
// Rendezvous with broker using the given parameters.
|
||||
broker, err := NewBrokerChannelWithUTlsSettings(
|
||||
broker, err := NewBrokerChannelWithUTLSSettings(
|
||||
config.BrokerURL, config.AmpCacheURL, config.FrontDomain,
|
||||
config.KeepLocalAddresses, config.UTlsClientID, config.UTlsRemoveSNI)
|
||||
config.KeepLocalAddresses, config.UTLSClientID, config.UTLSRemoveSNI)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -126,8 +126,8 @@ func main() {
|
|||
frontDomain := flag.String("front", "", "front domain")
|
||||
ampCacheURL := flag.String("ampcache", "", "URL of AMP cache to use as a proxy for signaling")
|
||||
logFilename := flag.String("log", "", "name of log file")
|
||||
utlsClientHelloID := flag.String("utls-imitate", "", "type of TLS client to imitate with utls")
|
||||
utlsRemoveSNI := flag.Bool("utls-nosni", false, "remove SNI from client hello(ignored if uTLS is not used)")
|
||||
uTLSClientHelloID := flag.String("utls-imitate", "", "type of TLS client to imitate with utls")
|
||||
uTLSRemoveSNI := flag.Bool("utls-nosni", false, "remove SNI from client hello(ignored if uTLS is not used)")
|
||||
logToStateDir := flag.Bool("log-to-state-dir", false, "resolve the log file relative to tor's pt state dir")
|
||||
keepLocalAddresses := flag.Bool("keep-local-addresses", false, "keep local LAN address ICE candidates")
|
||||
unsafeLogging := flag.Bool("unsafe-logging", false, "prevent logs from being scrubbed")
|
||||
|
@ -180,8 +180,8 @@ func main() {
|
|||
ICEAddresses: iceAddresses,
|
||||
KeepLocalAddresses: *keepLocalAddresses || *oldKeepLocalAddresses,
|
||||
Max: *max,
|
||||
UTlsClientID: *utlsClientHelloID,
|
||||
UTlsRemoveSNI: *utlsRemoveSNI,
|
||||
UTLSClientID: *uTLSClientHelloID,
|
||||
UTLSRemoveSNI: *uTLSRemoveSNI,
|
||||
}
|
||||
|
||||
// Begin goptlib client process.
|
||||
|
|
|
@ -29,7 +29,7 @@ var clientHelloIDMap = map[string]utls.ClientHelloID{
|
|||
|
||||
var errNameNotFound = errors.New("client hello name is unrecognized")
|
||||
|
||||
func NameToUTlsID(name string) (utls.ClientHelloID, error) {
|
||||
func NameToUTLSID(name string) (utls.ClientHelloID, error) {
|
||||
normalizedName := strings.ToLower(name)
|
||||
if id, ok := clientHelloIDMap[normalizedName]; ok {
|
||||
return id, nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue