Documentation ¶
Overview ¶
Package ptx contains code to use pluggable transports.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrSnowflakeNoSuchRendezvousMethod = errors.New("ptx: unsupported rendezvous method")
ErrSnowflakeNoSuchRendezvousMethod indicates the given rendezvous method is not supported by this implementation.
Functions ¶
This section is empty.
Types ¶
type FakeDialer ¶
type FakeDialer struct { // Address is the real destination address. Address string }
FakeDialer is a fake pluggable transport dialer. It actually just creates a TCP connection with the given address.
func (*FakeDialer) AsBridgeArgument ¶
func (d *FakeDialer) AsBridgeArgument() string
AsBridgeArgument returns the argument to be passed to the tor command line to declare this bridge.
func (*FakeDialer) DialContext ¶
DialContext establishes a TCP connection with d.Address.
func (*FakeDialer) Name ¶
func (d *FakeDialer) Name() string
Name returns the pluggable transport name.
type Listener ¶
type Listener struct { // ExperimentByteCounter is the OPTIONAL byte counter that // counts the bytes consumed by the experiment. ExperimentByteCounter *bytecounter.Counter // ListenSocks is OPTIONAL and allows you to override the // function called by default to listen for SOCKS5. ListenSocks func(network string, laddr string) (SocksListener, error) // Logger is the OPTIONAL logger. When not set, this library // will not emit logs. (But the underlying pluggable transport // may still emit its own log messages.) Logger model.Logger // PTDialer is the MANDATORY pluggable transports dialer // to use. Both SnowflakeDialer and OBFS4Dialer implement this // interface and can be thus safely used here. PTDialer PTDialer // SessionByteCounter is the OPTIONAL byte counter that // counts the bytes consumed by the session. SessionByteCounter *bytecounter.Counter // contains filtered or unexported fields }
Listener is a generic pluggable transports listener. Make sure you fill the mandatory fields before using it. Do not modify public fields after you called Start, since this causes data races.
func (*Listener) Addr ¶
Addr returns the listening address. This function should not be called after you have called the Stop method or before the Start method has successfully returned. When invoked in such conditions, this function may return nil. Otherwise, it will return the valid net.Addr where we are listening.
func (*Listener) AsClientTransportPluginArgument ¶
AsClientTransportPluginArgument converts the current configuration of the pluggable transport to a ClientTransportPlugin argument to be passed to the tor daemon command line. This function must be called after Start and before Stop so that we have a valid Addr.
Assuming that we are listening at 127.0.0.1:12345, then this function will return the following string:
obfs4 socks5 127.0.0.1:12345
The correct configuration line for the `torrc` would be:
ClientTransportPlugin obfs4 socks5 127.0.0.1:12345
Since we pass configuration to tor using the command line, it is more convenient to us to avoid including ClientTransportPlugin in the returned string. In fact, ClientTransportPlugin and its arguments need to be two consecutive argv strings.
type OBFS4Dialer ¶
type OBFS4Dialer struct { // Address contains the MANDATORY proxy address. Address string // Cert contains the MANDATORY certificate parameter. Cert string // DataDir is the MANDATORY directory where to store obfs4 data. DataDir string // Fingerprint is the MANDATORY bridge fingerprint. Fingerprint string // IATMode contains the MANDATORY iat-mode parameter. IATMode string // UnderlyingDialer is the optional underlying dialer to // use. If not set, we will use &net.Dialer{}. UnderlyingDialer model.SimpleDialer }
OBFS4Dialer is a dialer for obfs4. Make sure you fill all the fields marked as mandatory before using.
func DefaultTestingOBFS4Bridge ¶
func DefaultTestingOBFS4Bridge() *OBFS4Dialer
DefaultTestingOBFS4Bridge is a factory that returns you an OBFS4Dialer configured for the bridge we use by default when testing. Of course, given the nature of obfs4, it's not wise to use this bridge in general. But, feel free to use this bridge for integration testing of this code.
func (*OBFS4Dialer) AsBridgeArgument ¶
func (d *OBFS4Dialer) AsBridgeArgument() string
AsBridgeArgument returns the argument to be passed to the tor command line to declare this bridge.
func (*OBFS4Dialer) DialContext ¶
DialContext establishes a connection with the given obfs4 proxy. The context argument allows to interrupt this operation midway.
func (*OBFS4Dialer) Name ¶
func (d *OBFS4Dialer) Name() string
Name returns the pluggable transport name.
type PTDialer ¶
type PTDialer interface { // DialContext establishes a connection to the pluggable // transport backend according to PT-specific configuration // and returns you such a connection. DialContext(ctx context.Context) (net.Conn, error) // AsBridgeArgument returns the argument to be passed to // the tor command line to declare this bridge. AsBridgeArgument() string // Name returns the pluggable transport name. Name() string }
PTDialer is a generic pluggable transports dialer.
type SnowflakeDialer ¶
type SnowflakeDialer struct { // RendezvousMethod is the MANDATORY rendezvous method to use. RendezvousMethod SnowflakeRendezvousMethod // contains filtered or unexported fields }
SnowflakeDialer is a dialer for snowflake. You SHOULD either use a factory for constructing this type or set the fields marked as MANDATORY.
func NewSnowflakeDialer ¶ added in v3.14.0
func NewSnowflakeDialer() *SnowflakeDialer
NewSnowflakeDialer creates a SnowflakeDialer with default settings.
func NewSnowflakeDialerWithRendezvousMethod ¶ added in v3.14.0
func NewSnowflakeDialerWithRendezvousMethod(m SnowflakeRendezvousMethod) *SnowflakeDialer
NewSnowflakeDialerWithRendezvousMethod creates a SnowflakeDialer using the given RendezvousMethod explicitly.
func (*SnowflakeDialer) AsBridgeArgument ¶
func (d *SnowflakeDialer) AsBridgeArgument() string
AsBridgeArgument returns the argument to be passed to the tor command line to declare this bridge.
func (*SnowflakeDialer) DialContext ¶
DialContext establishes a connection with the given SF proxy. The context argument allows to interrupt this operation midway.
func (*SnowflakeDialer) Name ¶
func (d *SnowflakeDialer) Name() string
Name returns the pluggable transport name.
type SnowflakeRendezvousMethod ¶ added in v3.14.0
type SnowflakeRendezvousMethod interface { // Name is the name of the method. Name() string // AMPCacheURL returns a suitable AMP cache URL. AMPCacheURL() string // BrokerURL returns a suitable broker URL. BrokerURL() string // FrontDomain returns a suitable front domain. FrontDomain() string }
SnowflakeRendezvousMethod is the method which with we perform the rendezvous.
func NewSnowflakeRendezvousMethod ¶ added in v3.14.0
func NewSnowflakeRendezvousMethod(method string) (SnowflakeRendezvousMethod, error)
NewSnowflakeRendezvousMethod creates a new rendezvous method by name. We currently support the following rendezvous methods:
1. "domain_fronting" uses domain fronting with the sstatic.net CDN;
2. "" means default and it is currently equivalent to "domain_fronting" (but we don't guarantee that this default may change over time);
3. "amp" uses the AMP cache.
Returns either a valid rendezvous method or an error.
func NewSnowflakeRendezvousMethodAMP ¶ added in v3.14.0
func NewSnowflakeRendezvousMethodAMP() SnowflakeRendezvousMethod
NewSnowflakeRendezvousMethodAMP is a rendezvous method that uses the AMP cache to perform the rendezvous.
func NewSnowflakeRendezvousMethodDomainFronting ¶ added in v3.14.0
func NewSnowflakeRendezvousMethodDomainFronting() SnowflakeRendezvousMethod
NewSnowflakeRendezvousMethodDomainFronting is a rendezvous method that uses domain fronting to perform the rendezvous.