tladesignz / IPtProxy

Obfs4proxy and Snowflake Pluggable Transports for iOS
MIT License
54 stars 12 forks source link

Issue Running Snowflake Proxy on snowflake v2.5.1 in Orbot #39

Closed bitmold closed 1 year ago

bitmold commented 1 year ago

Looking into this now, finally.

For the time being, here's the crashlog:

2023-02-14 19:07:39.102 32276-0     Go                      org.torproject.android               E  panic: runtime error: invalid memory address or nil pointer dereference
2023-02-14 19:07:39.102 32276-0     Go                      org.torproject.android               E  [signal SIGSEGV: segmentation violation code=0x1 addr=0x14 pc=0x812a3598]
2023-02-14 19:07:39.102 32276-0     Go                      org.torproject.android               E  
2023-02-14 19:07:39.102 32276-0     Go                      org.torproject.android               E  goroutine 32 [running]:
2023-02-14 19:07:39.102 32276-32306 GoLog                   org.torproject.android               E  panic: runtime error: invalid memory address or nil pointer dereference
2023-02-14 19:07:39.102 32276-0     Go                      org.torproject.android               E  git.torproject.org/pluggable-transports/snowflake.git/v2/proxy/lib.(*SnowflakeProxy).Start(0x508aed80)
2023-02-14 19:07:39.102 32276-0     Go                      org.torproject.android               E      git.torproject.org/pluggable-transports/snowflake.git/v2@v2.4.1/proxy/lib/snowflake.go:571 +0x64
2023-02-14 19:07:39.102 32276-0     Go                      org.torproject.android               E  github.com/tladesignz/IPtProxy%2egit.StartSnowflakeProxy.func2(0x508aed80)
2023-02-14 19:07:39.102 32276-0     Go                      org.torproject.android               E      github.com/tladesignz/IPtProxy.git@v0.0.0-00010101000000-000000000000/IPtProxy.go:357 +0x260
2023-02-14 19:07:39.102 32276-0     Go                      org.torproject.android               E  created by github.com/tladesignz/IPtProxy%2egit.StartSnowflakeProxy
2023-02-14 19:07:39.102 32276-0     Go                      org.torproject.android               E      github.com/tladesignz/IPtProxy.git@v0.0.0-00010101000000-000000000000/IPtProxy.go:337 +0x2c4
2023-02-14 19:07:39.103 32276-32309 libc                    org.torproject.android               A  Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 32309 (project.android), pid 32276 (project.android)
bitmold commented 1 year ago

Specifically the new event dispatcher in snowflake seems to be the problem...

bitmold commented 1 year ago

Seems like it's because the event dispatcher is initialized after it's first used:

(patched snowflake.go):

    var err error
    log.Printf("should be right before crash!")
    sf.EventDispatcher.OnNewSnowflakeEvent(event.EventOnProxyStarting{})
    sf.shutdown = make(chan struct{})

    // blank configurations revert to default
    if sf.BrokerURL == "" {
        sf.BrokerURL = DefaultBrokerURL
    }
    if sf.RelayURL == "" {
        sf.RelayURL = DefaultRelayURL
    }
    if sf.STUNURL == "" {
        sf.STUNURL = DefaultSTUNURL
    }
    if sf.NATProbeURL == "" {
        sf.NATProbeURL = DefaultNATProbeURL
    }
    if sf.ProxyType == "" {
        sf.ProxyType = DefaultProxyType
    }
    if sf.EventDispatcher == nil {
        sf.EventDispatcher = event.NewSnowflakeEventDispatcher()
    }

I would imagine this issue also must exist in iOS if you're running the new snowflake 2.5.1 proxy there too

bitmold commented 1 year ago

Created upstream issue: https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40254