Add uTLS remove SNI to snowflake client

This commit is contained in:
Shelikhoo 2022-02-11 09:57:37 +00:00
parent 9af0ad119b
commit ccfdcab8fe
No known key found for this signature in database
GPG key ID: C4D5E79D22B25316
3 changed files with 8 additions and 3 deletions

View file

@ -56,13 +56,13 @@ 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 NewBrokerChannelWithUTlsClientID(broker, ampCache, front, keepLocalAddresses, "") return NewBrokerChannelWithUTlsClientID(broker, ampCache, front, keepLocalAddresses, "", false)
} }
// NewBrokerChannelWithUTlsClientID construct a new BrokerChannel, where: // NewBrokerChannelWithUTlsClientID 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 NewBrokerChannelWithUTlsClientID(broker, ampCache, front string, keepLocalAddresses bool, utlsClientID string) (*BrokerChannel, error) { func NewBrokerChannelWithUTlsClientID(broker, ampCache, front string, keepLocalAddresses bool, 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)
@ -79,7 +79,7 @@ func NewBrokerChannelWithUTlsClientID(broker, ampCache, front string, keepLocalA
return nil, fmt.Errorf("unable to create broker channel: %v", err) return nil, fmt.Errorf("unable to create broker channel: %v", err)
} }
config := &utls.Config{} config := &utls.Config{}
brokerTransport = utlsutil.NewUTLSHTTPRoundTripper(utlsClientHelloID, config, brokerTransport, false) brokerTransport = utlsutil.NewUTLSHTTPRoundTripper(utlsClientHelloID, config, brokerTransport, removeSNI)
} }
var rendezvous RendezvousMethod var rendezvous RendezvousMethod

View file

@ -100,6 +100,9 @@ type ClientConfig struct {
// 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
// when uTLS is used.
UTlsRemoveSNI bool
} }
// NewSnowflakeClient creates a new Snowflake transport client that can spawn multiple // NewSnowflakeClient creates a new Snowflake transport client that can spawn multiple

View file

@ -127,6 +127,7 @@ func main() {
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)")
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,6 +181,7 @@ func main() {
KeepLocalAddresses: *keepLocalAddresses || *oldKeepLocalAddresses, KeepLocalAddresses: *keepLocalAddresses || *oldKeepLocalAddresses,
Max: *max, Max: *max,
UTlsClientID: *utlsClientHelloID, UTlsClientID: *utlsClientHelloID,
UTlsRemoveSNI: *utlsRemoveSNI,
} }
// Begin goptlib client process. // Begin goptlib client process.