Просмотр исходного кода

ClientLibrary: add prefix to psiphon APIs

As discussed with @mirokuratczyk, it's probably best to use
snake case since that is gonna be used from C code.
Simone Basso 7 лет назад
Родитель
Сommit
ffd6f29455
2 измененных файлов с 7 добавлено и 6 удалено
  1. 5 4
      ClientLibrary/PsiphonTunnel.go
  2. 2 2
      ClientLibrary/example/main.c

+ 5 - 4
ClientLibrary/PsiphonTunnel.go

@@ -51,7 +51,7 @@ var tunnel psiphonTunnel
 // Memory managed by PsiphonTunnel which is allocated in Start and freed in Stop
 var managedStartResult *C.char
 
-//export Start
+//export psiphon_tunnel_start
 //
 // ******************************* WARNING ********************************
 // The underlying memory referenced by the return value of Start is managed
@@ -110,7 +110,7 @@ var managedStartResult *C.char
 //     - https://github.com/Psiphon-Labs/psiphon-tunnel-core/blob/3d344194d21b250e0f18ededa4b4459a373b0690/MobileLibrary/Android/PsiphonTunnel/PsiphonTunnel.java#L371
 //   iOS:
 //     - https://github.com/Psiphon-Labs/psiphon-tunnel-core/blob/3d344194d21b250e0f18ededa4b4459a373b0690/MobileLibrary/iOS/PsiphonTunnel/PsiphonTunnel/PsiphonTunnel.m#L1105
-func Start(configJSON, embeddedServerEntryList, clientPlatform, networkID string, timeout int64) *C.char {
+func psiphon_tunnel_start(configJSON, embeddedServerEntryList, clientPlatform, networkID string, 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.
 
@@ -267,12 +267,13 @@ func Start(configJSON, embeddedServerEntryList, clientPlatform, networkID string
 	return managedStartResult
 }
 
-//export Stop
+//export psiphon_tunnel_stop
+//
 // Stop stops the controller if it is running and waits for it to clean up and exit.
 //
 // Stop should always be called after a successful call to Start to ensure the
 // controller is not left running.
-func Stop() {
+func psiphon_tunnel_stop() {
 	freeManagedStartResult()
 
 	if tunnel.stopController != nil {

+ 2 - 2
ClientLibrary/example/main.c

@@ -67,13 +67,13 @@ int main(int argc, char *argv[]) {
     // connect 5 times
     for (int i = 0; i < 5; i++) {
         // start will return once Psiphon connects or does not connect for timeout seconds
-        char *result = Start(psiphon_config, serverList, client_platform, network_id, timeout);
+        char *result = psiphon_tunnel_start(psiphon_config, serverList, client_platform, network_id, timeout);
 
         // print results
         printf("Result: %s\n", result);
 
         // The underlying memory of `result` is managed by PsiphonTunnel and is freed in Stop
-        Stop();
+        psiphon_tunnel_stop();
     }
 }