Harmonize identifiers to uTLS

This commit is contained in:
Shelikhoo 2022-02-11 11:26:41 +00:00
parent e3aeb5fe5b
commit 8d5998b744
No known key found for this signature in database
GPG key ID: C4D5E79D22B25316
4 changed files with 17 additions and 17 deletions

View file

@ -56,14 +56,14 @@ func createBrokerTransport() http.RoundTripper {
} }
func NewBrokerChannel(broker, ampCache, front string, keepLocalAddresses bool) (*BrokerChannel, error) { 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 // |broker| is the full URL of the facilitating program which assigns proxies
// to clients, and |front| is the option fronting domain. // to clients, and |front| is the option fronting domain.
func NewBrokerChannelWithUTlsSettings(broker, ampCache, front string, keepLocalAddresses bool, func NewBrokerChannelWithUTLSSettings(broker, ampCache, front string, keepLocalAddresses bool,
utlsClientID string, removeSNI bool) (*BrokerChannel, error) { uTLSClientID string, removeSNI bool) (*BrokerChannel, error) {
log.Println("Rendezvous using Broker at:", broker) log.Println("Rendezvous using Broker at:", broker)
if ampCache != "" { if ampCache != "" {
log.Println("Through AMP cache at:", ampCache) log.Println("Through AMP cache at:", ampCache)
@ -74,8 +74,8 @@ func NewBrokerChannelWithUTlsSettings(broker, ampCache, front string, keepLocalA
brokerTransport := createBrokerTransport() brokerTransport := createBrokerTransport()
if utlsClientID != "" { if uTLSClientID != "" {
utlsClientHelloID, err := utlsutil.NameToUTlsID(utlsClientID) utlsClientHelloID, err := utlsutil.NameToUTLSID(uTLSClientID)
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to create broker channel: %v", err) return nil, fmt.Errorf("unable to create broker channel: %v", err)
} }

View file

@ -97,12 +97,12 @@ type ClientConfig struct {
// Max is the maximum number of snowflake proxy peers that the client should attempt to // Max is the maximum number of snowflake proxy peers that the client should attempt to
// connect to. Defaults to 1. // connect to. Defaults to 1.
Max int 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 // If an empty value is provided, it will use Go's default TLS implementation
UTlsClientID string UTLSClientID string
// UTlsRemoveSNI is the flag to control whether SNI should be removed from Client Hello // UTLSRemoveSNI is the flag to control whether SNI should be removed from Client Hello
// when uTLS is used. // when uTLS is used.
UTlsRemoveSNI bool UTLSRemoveSNI bool
} }
// NewSnowflakeClient creates a new Snowflake transport client that can spawn multiple // 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. // Rendezvous with broker using the given parameters.
broker, err := NewBrokerChannelWithUTlsSettings( broker, err := NewBrokerChannelWithUTLSSettings(
config.BrokerURL, config.AmpCacheURL, config.FrontDomain, config.BrokerURL, config.AmpCacheURL, config.FrontDomain,
config.KeepLocalAddresses, config.UTlsClientID, config.UTlsRemoveSNI) config.KeepLocalAddresses, config.UTLSClientID, config.UTLSRemoveSNI)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -126,8 +126,8 @@ func main() {
frontDomain := flag.String("front", "", "front domain") frontDomain := flag.String("front", "", "front domain")
ampCacheURL := flag.String("ampcache", "", "URL of AMP cache to use as a proxy for signaling") ampCacheURL := flag.String("ampcache", "", "URL of AMP cache to use as a proxy for signaling")
logFilename := flag.String("log", "", "name of log file") logFilename := flag.String("log", "", "name of log file")
utlsClientHelloID := flag.String("utls-imitate", "", "type of TLS client to imitate with utls") 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)") 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") 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") keepLocalAddresses := flag.Bool("keep-local-addresses", false, "keep local LAN address ICE candidates")
unsafeLogging := flag.Bool("unsafe-logging", false, "prevent logs from being scrubbed") unsafeLogging := flag.Bool("unsafe-logging", false, "prevent logs from being scrubbed")
@ -180,8 +180,8 @@ func main() {
ICEAddresses: iceAddresses, ICEAddresses: iceAddresses,
KeepLocalAddresses: *keepLocalAddresses || *oldKeepLocalAddresses, KeepLocalAddresses: *keepLocalAddresses || *oldKeepLocalAddresses,
Max: *max, Max: *max,
UTlsClientID: *utlsClientHelloID, UTLSClientID: *uTLSClientHelloID,
UTlsRemoveSNI: *utlsRemoveSNI, UTLSRemoveSNI: *uTLSRemoveSNI,
} }
// Begin goptlib client process. // Begin goptlib client process.

View file

@ -29,7 +29,7 @@ var clientHelloIDMap = map[string]utls.ClientHelloID{
var errNameNotFound = errors.New("client hello name is unrecognized") 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) normalizedName := strings.ToLower(name)
if id, ok := clientHelloIDMap[normalizedName]; ok { if id, ok := clientHelloIDMap[normalizedName]; ok {
return id, nil return id, nil