|
@@ -111,8 +111,6 @@ var managedStartResult *C.char
|
|
|
// iOS:
|
|
// iOS:
|
|
|
// - https://github.com/Psiphon-Labs/psiphon-tunnel-core/blob/3d344194d21b250e0f18ededa4b4459a373b0690/MobileLibrary/iOS/PsiphonTunnel/PsiphonTunnel/PsiphonTunnel.m#L1105
|
|
// - https://github.com/Psiphon-Labs/psiphon-tunnel-core/blob/3d344194d21b250e0f18ededa4b4459a373b0690/MobileLibrary/iOS/PsiphonTunnel/PsiphonTunnel/PsiphonTunnel.m#L1105
|
|
|
func psiphon_tunnel_start(cConfigJSON, cEmbeddedServerEntryList, cClientPlatform, cNetworkID *C.char, timeout int64) *C.char {
|
|
func psiphon_tunnel_start(cConfigJSON, cEmbeddedServerEntryList, cClientPlatform, cNetworkID *C.char, timeout int64) *C.char {
|
|
|
- // NOTE: all arguments which are still referenced once Start returns should be copied onto the Go heap
|
|
|
|
|
- // to ensure that they don't disappear later on and cause Go to crash.
|
|
|
|
|
|
|
|
|
|
configJSON := C.GoString(cConfigJSON)
|
|
configJSON := C.GoString(cConfigJSON)
|
|
|
embeddedServerEntryList := C.GoString(cEmbeddedServerEntryList)
|
|
embeddedServerEntryList := C.GoString(cEmbeddedServerEntryList)
|
|
@@ -128,17 +126,11 @@ func psiphon_tunnel_start(cConfigJSON, cEmbeddedServerEntryList, cClientPlatform
|
|
|
|
|
|
|
|
// Set network ID
|
|
// Set network ID
|
|
|
|
|
|
|
|
- if networkID != "" {
|
|
|
|
|
- // Ensure config.NetworkID is on the Go heap
|
|
|
|
|
- config.NetworkID = deepCopy(networkID)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ config.NetworkID = networkID
|
|
|
|
|
|
|
|
// Set client platform
|
|
// Set client platform
|
|
|
|
|
|
|
|
- if clientPlatform != "" {
|
|
|
|
|
- // Ensure config.ClientPlatform is on the Go heap
|
|
|
|
|
- config.ClientPlatform = deepCopy(clientPlatform)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ config.ClientPlatform = clientPlatform
|
|
|
|
|
|
|
|
// All config fields should be set before calling commit
|
|
// All config fields should be set before calling commit
|
|
|
err = config.Commit()
|
|
err = config.Commit()
|
|
@@ -324,11 +316,6 @@ func startErrorJson(err error) *C.char {
|
|
|
return marshalStartResult(result)
|
|
return marshalStartResult(result)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// deepCopy copies a string's underlying buffer and returns a new string which references the new buffer.
|
|
|
|
|
-func deepCopy(s string) string {
|
|
|
|
|
- return string([]byte(s))
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
// freeManagedStartResult frees the memory on the heap pointed to by managedStartResult.
|
|
// freeManagedStartResult frees the memory on the heap pointed to by managedStartResult.
|
|
|
func freeManagedStartResult() {
|
|
func freeManagedStartResult() {
|
|
|
if managedStartResult != nil {
|
|
if managedStartResult != nil {
|