Giter Club home page Giter Club logo

goproxy-sdk's Introduction

Proxy SDK usage instructions

stable download_count download

Only commercial version is avaiable currentlly.

中文说明

Download

The following platforms are supported:

  • Android, .arr library
  • IOS, .framework library
  • Windows, .dll library
  • Linux, .so library
  • MacOS, .dylib library

proxy uses gombile to compile a copy of go code into an sdk library that can be called directly from the android and ios platforms, It also provides sdk support for linux and windows, MacOS,based on these libraries, APP developers can easily develop various forms of proxy tools.

The following sub-platform describes the use of the SDK

Android SDK

The sdk form provided in the Android system is a suffix.aar class library files, development time only need to ARR class library files into the android project can be.

Android-SDK usage examples

1. Importing packages

import snail007.proxy.Porxy

2. Start a service

String serviceID="http01";// Here serviceID is a custom unique identifier string, ensure that each start of the service is not the same
String serviceArgs="http -p :8080";
String err=Proxy.start(serviceID,serviceArgs,"");
if (!err.isEmpty()){
    // Failed to start
    System.out.println("start fail,error:"+err);
}else{
    // Successful launch
}

3. Stop service

String serviceID="http01";
Proxy.stop(serviceID);
// Stop over.

IOS SDK

The sdk form provided in IOS is a suffix.framework Class Library folder, the development of the class library files only need to be introduced into the project, and then call the method.

IOS-SDK usage examples

Importing packages

#import <Proxy/Proxy.objc.h>

2. Start a service

-(IBAction)doStart:(id)sender
{
	// Here serviceID is a custom unique identifier string, guaranteed to be different for each started service
	NSString *serviceID = @"http01";
    NSString *serviceArgs = @"http -p :8080";
    NSString *error = ProxyStart(serviceID,serviceArgs,"");
    
    if (error != nil && error.length > 0)
    {
        NSLog(@"start error %@",error);
    }else{
        NSLog(@"Successful launch");
    }
}

3. Stop service

-(IBAction)doStop:(id)sender
{
    NSString *serviceID = @"http01";
    ProxyStop(serviceID);
    // Stop over.
}

Windows SDK

The sdk form provided in the Windows system is a suffix.when developing,you only need to load the dll class library file, and then call the method.

Windows-SDK usage instance

C++examples, do not need to include header files, only need to load proxy-sdk.dll can, ieshims.dll needed and proxy-sdk.dll together.
Author: yjbdsky

#include <stdio.h>
#include<stdlib.h>
#include <string.h>
#include<pthread.h>
#include<Windows.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef char *(*GOSTART)(char *s);
typedef char *(*GOSTOP)(char *s);
typedef int(*GOISRUN)(char *s);
HMODULE GODLL = LoadLibrary("proxy-sdk.dll");

char * Start(char * p0,char * p1)
{
	if (GODLL != NULL)
	{
		GOSTART gostart = *(GOSTART)(GetProcAddress(GODLL, "Start"));
		if (gostart != NULL){
			printf("%s:%s\n",p0, p1);
			char *ret = gostart(p0,p1,"");
			return ret;
		}
	}
	return "Cannot Find dll";
}
char * Stop(char * p)
{
	if (GODLL != NULL)
	{
		GOSTOP gostop = *(GOSTOP)(GetProcAddress(GODLL, "Stop"));
		if (gostop != NULL){
			printf("%s\n", p);
			char *ret = gostop(p);
			return ret;
		}
	}
	return "Cannot Find dll";
}

int main()
{
	// Here p0 is a custom unique identifier string, guaranteed to be different for each started service
	char *p0 = "http01";
	char *p1 = "http -t tcp -p :38080";
	printf("This is demo application.\n");
	// Start the service, returns an empty string description starts successfully;returns a non-empty string description fails to start, the returned string is the cause of the error
	printf("start result %s\n", Start(p0,p1));
	// Stop service, no return value
	Stop(p0);
	return 0;
}


#ifdef __cplusplus
}
#endif

C++ Example 2, move step:GoProxyForC

Linux SDK

The sdk form provided in the Linux system is a suffix.so library files, development time only need to load the so library, you can call the method.

Linux-SDK usage examples

The SDK that is used below Linux is the so file i.e. libproxy-sdk. so,write a simple example of a C program that calls the method inside the so library.

vi test-proxy.c

#include <stdio.h>
#include "libproxy-sdk.h"

int main() {
     printf("This is demo application.\n");
	 // Here p0 is a custom unique identifier string, guaranteed to be different for each started service
	 char *p0 = "http01";
     char *p1 = "http -t tcp -p :38080";
     // Start the service, returns an empty string description starts successfully;returns a non-empty string description fails to start, the returned string is the cause of the error
     printf("start result %s\n",Start(p0,p1,""));
     // Stop service, no return value
     Stop(p0);
     return 0;
}

Compile test-proxy.c

export LD_LIBRARY_PATH=./ && gcc -o test-proxy test-proxy.c libproxy-sdk.so

Execution

./test-proxy

MacOS SDK

The sdk form provided in the MacOS system is a suffix.dylib library files, development time only need to load so library, you can call the method.

MacOS-SDK usage instance

The sdk used below for MacOS is the dylib file i.e. libproxy-sdk.dylib, write a simple Obj-C program example, call dylib library inside the method.

#import "libproxy-sdk.h"
-(IBAction)doStart:(id)sender
{
    char *result =  Start("http01", "http -t tcp -p :38080","");
    
    if (result)
    {
        printf("started");
    }else{
        printf("not started");
    }
  
}
-(IBAction)doStop:(id)sender
{
     Stop("http01");

}

About the service

There are 11 types of proxy services:

http  
socks  
sps  
tcp  
udp  
bridge  
server  
client  
tbridge  
tserver  
tclient  

When the service starts,if there is a service running with the same ID, then the previous service will be stopped and the previous service will be overwritten later.

So make sure that the first ID parameter is unique every time you start the service.

The specific usage and parameters of these services can be found in proxy manual the SDK service does not support the manual inside: -- daemon and -- forever parameters.

goproxy-sdk's People

Contributors

snail007 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

goproxy-sdk's Issues

安卓版sdk偶发性报错

@snail007

报错时日志如下:

08-18 16:00:30.918 625 0 E Go : panic: interface conversion: interface {} is nil, not string
08-18 16:00:30.918 625 0 E Go : goroutine 13852 [running]:
08-18 16:00:30.918 625 0 E Go : github.com/snail007/license/lic-checker.post(0x8bdd09a0, 0xab, 0x8be58fa0, 0xbf0e2008, 0xc8, 0x8bc994f0, 0x0, 0x0)
08-18 16:00:30.918 625 0 E Go : /Users/go/src/github.com/snail007/license/lic-checker/checker.go:411 +0xd58
08-18 16:00:30.918 625 0 E Go : github.com/snail007/license/lic-checker.Report.func1()
08-18 16:00:30.918 625 0 E Go : /Users/go/src/github.com/snail007/license/lic-checker/checker.go:291 +0x3c
08-18 16:00:30.918 625 0 E Go : created by time.goFunc
08-18 16:00:30.918 625 0 E Go : /usr/local/go1.13/src/time/sleep.go:168 +0x38
08-18 16:00:30.919 625 3276 E GoLog : panic: interface conversion: interface {} is nil, not string
08-18 16:00:30.946 23813 23821 W System : A resource failed to call close.

集成goproxy android-sdk 运行失败

小米8 安卓版本9.0 miui 10

03-23 14:22:19.121 4134-0/com.tencent.myapplication E/Go: panic: runtime error: index out of range
goroutine 17 [running, locked to thread]:
03-23 14:22:19.122 4134-0/com.tencent.myapplication E/Go: github.com/snail007/license/lic-checker/goinfo.GetInfoMap(0x71b2f6cfee)
/home/pengmeng/go/src/github.com/snail007/license/lic-checker/goinfo/goInfo_linux.go:25 +0x4e8
github.com/snail007/license/lic-checker.Report(0x442002ea30, 0x10, 0x442002e655, 0x3, 0x442002e8f0, 0xd, 0x34630b8a000)
/home/pengmeng/go/src/github.com/snail007/license/lic-checker/checker.go:179 +0x18
github.com/snail007/proxy/sdk/android-ios.StartWithLog(0x442002e8e0, 0x6, 0x442002e8f0, 0xd, 0x0, 0x0, 0x4420020070, 0xd)
/home/pengmeng/go/src/github.com/snail007/proxy/sdk/android-ios/sdk.go:92 +0xf4
github.com/snail007/proxy/sdk/android-ios.Start(0x442002e8e0, 0x6, 0x442002e8f0, 0xd, 0x7100000008, 0x4420062080)
/home/pengmeng/go/src/github.com/snail007/proxy/sdk/android-ios/sdk.go:66 +0x40
03-23 14:22:19.123 4134-0/com.tencent.myapplication E/Go: main.proxyproxy__Start(0x71b431a160, 0x6, 0x71b3c86680, 0xd, 0x0, 0x0)
/tmp/gomobile-work-022422383/src/gobind/go_proxymain.go:128 +0x64
main._cgoexpwrap_ef64ed5c78f1_proxyproxy__Start(0x71b431a160, 0x6, 0x71b3c86680, 0xd, 0x0, 0x0)
_cgo_gotypes.go:271 +0x64

--------- beginning of crash

03-23 14:22:19.124 4134-4134/com.tencent.myapplication A/libc: Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 4134 (t.myapplication), pid 4134 (t.myapplication)
03-23 14:22:19.270 4191-4191/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'Xiaomi/dipper/dipper:9/PKQ1.180729.001/V10.2.2.0.PEACNXM:user/release-keys'
Revision: '0'
ABI: 'arm64'
pid: 4134, tid: 4134, name: t.myapplication >>> com.tencent.myapplication <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
x0 0000000000000000 x1 0000000000000006 x2 0000000000000000 x3 0000000000000008
x4 0000000000000020 x5 0000000000000000 x6 0000000000000006 x7 0000000000000000
x8 0000000000000082 x9 00000071b33321f0 x10 000000000005eacf x11 0000004420000600
x12 0000000000000000 x13 0000000000000000 x14 0000000000000000 x15 0000000000000001
x16 0000007fc374bddc x17 00000071b3582ee0 x18 0000000000000008 x19 000000001d273a1d
x20 00000071b3c86680 x21 0000000000000006 x22 00000071b431a160 x23 0000000000000000
x24 0000000000000008 x25 00000072524665e0 x26 0000000000000000 x27 0000000000000000
x28 0000004420000480 x29 0000007fc374c4f0
sp 0000007fc374c280 lr 00000071b2b0c44c pc 00000071b2b21c48
03-23 14:22:19.271 4191-4191/? A/DEBUG: backtrace:
#00 pc 00000000002d3c48 /data/app/com.tencent.myapplication-2kccKH4ii9_qekSeiqLlKQ==/lib/arm64/libgojni.so

sdk执行tclient指令无返回结果。

谢谢sdk,使用上有个问题。

  1. 计划在手机端做内网穿透,在mainactivity中执行指令tclient -P "xx.xx.xx.xx:2030" -C proxy.crt -K proxy.key,

Proxysdk.start(serviceid, args,"")后不会返回结果,无法通过返回值判断执行是否存在错误。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.