|
@@ -39,6 +39,7 @@ import (
|
|
|
"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/obfuscator"
|
|
"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/obfuscator"
|
|
|
"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/parameters"
|
|
"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/parameters"
|
|
|
"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/protocol"
|
|
"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/protocol"
|
|
|
|
|
+ "github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/quic"
|
|
|
"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/tactics"
|
|
"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/tactics"
|
|
|
"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/transferstats"
|
|
"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/transferstats"
|
|
|
regen "github.com/zach-klippenstein/goregen"
|
|
regen "github.com/zach-klippenstein/goregen"
|
|
@@ -536,6 +537,7 @@ func selectProtocol(
|
|
|
usePriorityProtocol bool) (selectedProtocol string, err error) {
|
|
usePriorityProtocol bool) (selectedProtocol string, err error) {
|
|
|
|
|
|
|
|
candidateProtocols := serverEntry.GetSupportedProtocols(
|
|
candidateProtocols := serverEntry.GetSupportedProtocols(
|
|
|
|
|
+ config.UseUpstreamProxy(),
|
|
|
config.clientParameters.Get().TunnelProtocols(parameters.LimitTunnelProtocols),
|
|
config.clientParameters.Get().TunnelProtocols(parameters.LimitTunnelProtocols),
|
|
|
impairedProtocols,
|
|
impairedProtocols,
|
|
|
excludeMeek)
|
|
excludeMeek)
|
|
@@ -745,7 +747,7 @@ func initDialConfig(
|
|
|
|
|
|
|
|
var upstreamProxyType string
|
|
var upstreamProxyType string
|
|
|
|
|
|
|
|
- if config.UpstreamProxyURL != "" {
|
|
|
|
|
|
|
+ if config.UseUpstreamProxy() {
|
|
|
// Note: UpstreamProxyURL will be validated in the dial
|
|
// Note: UpstreamProxyURL will be validated in the dial
|
|
|
proxyURL, err := url.Parse(config.UpstreamProxyURL)
|
|
proxyURL, err := url.Parse(config.UpstreamProxyURL)
|
|
|
if err == nil {
|
|
if err == nil {
|
|
@@ -877,19 +879,23 @@ func dialSsh(
|
|
|
var selectedSSHClientVersion bool
|
|
var selectedSSHClientVersion bool
|
|
|
SSHClientVersion := ""
|
|
SSHClientVersion := ""
|
|
|
useObfuscatedSsh := false
|
|
useObfuscatedSsh := false
|
|
|
- var directTCPDialAddress string
|
|
|
|
|
|
|
+ var directDialAddress string
|
|
|
var meekConfig *MeekConfig
|
|
var meekConfig *MeekConfig
|
|
|
var err error
|
|
var err error
|
|
|
|
|
|
|
|
switch selectedProtocol {
|
|
switch selectedProtocol {
|
|
|
case protocol.TUNNEL_PROTOCOL_OBFUSCATED_SSH:
|
|
case protocol.TUNNEL_PROTOCOL_OBFUSCATED_SSH:
|
|
|
useObfuscatedSsh = true
|
|
useObfuscatedSsh = true
|
|
|
- directTCPDialAddress = fmt.Sprintf("%s:%d", serverEntry.IpAddress, serverEntry.SshObfuscatedPort)
|
|
|
|
|
|
|
+ directDialAddress = fmt.Sprintf("%s:%d", serverEntry.IpAddress, serverEntry.SshObfuscatedPort)
|
|
|
|
|
+
|
|
|
|
|
+ case protocol.TUNNEL_PROTOCOL_QUIC_OBFUSCATED_SSH:
|
|
|
|
|
+ useObfuscatedSsh = true
|
|
|
|
|
+ directDialAddress = fmt.Sprintf("%s:%d", serverEntry.IpAddress, serverEntry.SshObfuscatedQUICPort)
|
|
|
|
|
|
|
|
case protocol.TUNNEL_PROTOCOL_SSH:
|
|
case protocol.TUNNEL_PROTOCOL_SSH:
|
|
|
selectedSSHClientVersion = true
|
|
selectedSSHClientVersion = true
|
|
|
SSHClientVersion = pickSSHClientVersion()
|
|
SSHClientVersion = pickSSHClientVersion()
|
|
|
- directTCPDialAddress = fmt.Sprintf("%s:%d", serverEntry.IpAddress, serverEntry.SshPort)
|
|
|
|
|
|
|
+ directDialAddress = fmt.Sprintf("%s:%d", serverEntry.IpAddress, serverEntry.SshPort)
|
|
|
|
|
|
|
|
default:
|
|
default:
|
|
|
useObfuscatedSsh = true
|
|
useObfuscatedSsh = true
|
|
@@ -921,6 +927,7 @@ func dialSsh(
|
|
|
|
|
|
|
|
var dialConn net.Conn
|
|
var dialConn net.Conn
|
|
|
if meekConfig != nil {
|
|
if meekConfig != nil {
|
|
|
|
|
+
|
|
|
dialConn, err = DialMeek(
|
|
dialConn, err = DialMeek(
|
|
|
ctx,
|
|
ctx,
|
|
|
meekConfig,
|
|
meekConfig,
|
|
@@ -928,10 +935,29 @@ func dialSsh(
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return nil, common.ContextError(err)
|
|
return nil, common.ContextError(err)
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ } else if protocol.TunnelProtocolUsesQUIC(selectedProtocol) {
|
|
|
|
|
+
|
|
|
|
|
+ // TODO:
|
|
|
|
|
+ // - use dialConfig?
|
|
|
|
|
+ // - SO_BINDTODEVICE etc.
|
|
|
|
|
+ packetConn, err := net.ListenUDP("udp", &net.UDPAddr{IP: nil, Port: 0})
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return nil, common.ContextError(err)
|
|
|
|
|
+ }
|
|
|
|
|
+ dialConn, err = quic.Dial(
|
|
|
|
|
+ ctx,
|
|
|
|
|
+ packetConn,
|
|
|
|
|
+ directDialAddress)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return nil, common.ContextError(err)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+
|
|
|
dialConn, err = DialTCPFragmentor(
|
|
dialConn, err = DialTCPFragmentor(
|
|
|
ctx,
|
|
ctx,
|
|
|
- directTCPDialAddress,
|
|
|
|
|
|
|
+ directDialAddress,
|
|
|
dialConfig,
|
|
dialConfig,
|
|
|
selectedProtocol,
|
|
selectedProtocol,
|
|
|
config.clientParameters,
|
|
config.clientParameters,
|