Select Git revision
iptproxy.patch
Forked from
leap / Android Libs / Bitmask Core
1 commit behind, 4 commits ahead of the upstream repository.

cyberta authored
iptproxy.patch 6.63 KiB
diff --git a/IPtProxy.go/IPtProxy.go b/IPtProxy.go/IPtProxy.go
index d9c3c25..0cb8e03 100644
--- a/IPtProxy.go/IPtProxy.go
+++ b/IPtProxy.go/IPtProxy.go
@@ -2,12 +2,6 @@ package IPtProxy
import (
"errors"
- "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/lyrebird/cmd/lyrebird"
- snowflakeclient "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/client"
- "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/event"
- "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/safelog"
- "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/version"
- sfp "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/proxy/lib"
"io"
"io/fs"
"log"
@@ -15,67 +9,13 @@ import (
"os"
"strconv"
"time"
-)
-
-var meekPort = 47000
-
-// MeekPort - Port where Lyrebird will provide its Meek service.
-// Only use this after calling StartLyrebird! It might have changed after that!
-//
-//goland:noinspection GoUnusedExportedFunction
-func MeekPort() int {
- return meekPort
-}
-
-var obfs2Port = 47100
-
-// Obfs2Port - Port where Lyrebird will provide its Obfs2 service.
-// Only use this property after calling StartLyrebird! It might have changed after that!
-//
-//goland:noinspection GoUnusedExportedFunction
-func Obfs2Port() int {
- return obfs2Port
-}
-
-var obfs3Port = 47200
-
-// Obfs3Port - Port where Lyrebird will provide its Obfs3 service.
-// Only use this property after calling StartLyrebird! It might have changed after that!
-//
-//goland:noinspection GoUnusedExportedFunction
-func Obfs3Port() int {
- return obfs3Port
-}
-
-var obfs4Port = 47300
-
-// Obfs4Port - Port where Lyrebird will provide its Obfs4 service.
-// Only use this property after calling StartLyrebird! It might have changed after that!
-//
-//goland:noinspection GoUnusedExportedFunction
-func Obfs4Port() int {
- return obfs4Port
-}
-
-var scramblesuitPort = 47400
-
-// ScramblesuitPort - Port where Lyrebird will provide its Scramblesuit service.
-// Only use this property after calling StartLyrebird! It might have changed after that!
-//
-//goland:noinspection GoUnusedExportedFunction
-func ScramblesuitPort() int {
- return scramblesuitPort
-}
-
-var webtunnelPort = 47500
-// WebtunnelPort - Port where Lyrebird will provide its Webtunnel service.
-// Only use this property after calling StartLyrebird! It might have changed after that!
-//
-//goland:noinspection GoUnusedExportedFunction
-func WebtunnelPort() int {
- return webtunnelPort
-}
+ snowflakeclient "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/client"
+ "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/event"
+ "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/safelog"
+ "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/version"
+ sfp "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/proxy/lib"
+)
var snowflakePort = 52000
@@ -87,20 +27,12 @@ func SnowflakePort() int {
return snowflakePort
}
-var lyrebirdRunning = false
var snowflakeRunning = false
var snowflakeProxy *sfp.SnowflakeProxy
// StateLocation - Sets TOR_PT_STATE_LOCATION
var StateLocation string
-// LyrebirdVersion - The version of Lyrebird bundled with IPtProxy.
-//
-//goland:noinspection GoUnusedExportedFunction
-func LyrebirdVersion() string {
- return lyrebird.LyrebirdVersion
-}
-
// SnowflakeVersion - The version of Snowflake bundled with IPtProxy.
//
//goland:noinspection GoUnusedExportedFunction
@@ -108,110 +40,6 @@ func SnowflakeVersion() string {
return version.GetVersion()
}
-// LyrebirdLogFile - The log file name used by Lyrebird.
-//
-// The Lyrebird log file can be found at `filepath.Join(StateLocation, LyrebirdLogFile())`.
-//
-//goland:noinspection GoUnusedExportedFunction
-func LyrebirdLogFile() string {
- return lyrebird.LyrebirdLogFile
-}
-
-// StartLyrebird - Start Lyrebird.
-//
-// This will test, if the default ports are available. If not, it will increment them until there is.
-// Only use the port properties after calling this, they might have been changed!
-//
-// @param logLevel Log level (ERROR/WARN/INFO/DEBUG). Defaults to ERROR if empty string.
-//
-// @param enableLogging Log to TOR_PT_STATE_LOCATION/lyrebird.log.
-//
-// @param unsafeLogging Disable the address scrubber.
-//
-// @param proxy HTTP, SOCKS4 or SOCKS5 proxy to be used behind Lyrebird. E.g. "socks5://127.0.0.1:12345"
-//
-// @return Port number where Lyrebird will listen on for Obfs4(!), if no error happens during start up.
-//
-// If you need the other ports, check MeekPort, Obfs2Port, Obfs3Port, ScramblesuitPort and WebtunnelPort properties!
-//
-//goland:noinspection GoUnusedExportedFunction
-func StartLyrebird(logLevel string, enableLogging, unsafeLogging bool, proxy string) int {
- if lyrebirdRunning {
- return obfs4Port
- }
-
- lyrebirdRunning = true
-
- for !IsPortAvailable(meekPort) {
- meekPort++
- }
-
- if meekPort >= obfs2Port {
- obfs2Port = meekPort + 1
- }
-
- for !IsPortAvailable(obfs2Port) {
- obfs2Port++
- }
-
- if obfs2Port >= obfs3Port {
- obfs3Port = obfs2Port + 1
- }
-
- for !IsPortAvailable(obfs3Port) {
- obfs3Port++
- }
-
- if obfs3Port >= obfs4Port {
- obfs4Port = obfs3Port + 1
- }
-
- for !IsPortAvailable(obfs4Port) {
- obfs4Port++
- }
-
- if obfs4Port >= scramblesuitPort {
- scramblesuitPort = obfs4Port + 1
- }
-
- for !IsPortAvailable(scramblesuitPort) {
- scramblesuitPort++
- }
-
- if scramblesuitPort >= webtunnelPort {
- webtunnelPort = scramblesuitPort + 1
- }
-
- for !IsPortAvailable(webtunnelPort) {
- webtunnelPort++
- }
-
- fixEnv()
-
- if len(proxy) > 0 {
- _ = os.Setenv("TOR_PT_PROXY", proxy)
- } else {
- _ = os.Unsetenv("TOR_PT_PROXY")
- }
-
- go lyrebird.Start(&meekPort, &obfs2Port, &obfs3Port, &obfs4Port, &scramblesuitPort, &webtunnelPort, &logLevel, &enableLogging, &unsafeLogging)
-
- return obfs4Port
-}
-
-// StopLyrebird - Stop Lyrebird.
-//
-//goland:noinspection GoUnusedExportedFunction
-func StopLyrebird() {
- if !lyrebirdRunning {
- return
- }
-
- go lyrebird.Stop()
-
- lyrebirdRunning = false
-}
-
// StartSnowflake - Start the Snowflake client.
//
// @param ice Comma-separated list of ICE servers.
@@ -449,7 +277,7 @@ func fixEnv() {
" Use a non-temporary directory to allow reuse of potentially stored state.")
}
- _ = os.Setenv("TOR_PT_CLIENT_TRANSPORTS", "meek_lite,obfs2,obfs3,obfs4,scramblesuit,webtunnel,snowflake")
+ _ = os.Setenv("TOR_PT_CLIENT_TRANSPORTS", "snowflake")
_ = os.Setenv("TOR_PT_MANAGED_TRANSPORT_VER", "1")
_ = os.Setenv("TOR_PT_STATE_LOCATION", StateLocation)
}