summaryrefslogtreecommitdiffhomepage
path: root/tunnel/src/main/proto/libwg.proto
blob: 2475894087620e23bd01b5b80dd1edcbeaac1a9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
syntax = "proto3";

option java_multiple_files = true;
option java_package = 'com.wireguard.android.backend.gen';
option java_outer_classname = "LibwgProto";
option java_generic_services = true;
option go_package = 'golang.zx2c4.com/wireguard/android/gen';

package api;

service Libwg {
	rpc StopGrpc(StopGrpcRequest) returns (StopGrpcResponse);
	rpc Version(VersionRequest) returns (VersionResponse);
	rpc StartHttpProxy(StartHttpProxyRequest) returns (StartHttpProxyResponse);
	rpc StopHttpProxy(StopHttpProxyRequest) returns (StopHttpProxyResponse);
	rpc Reverse(stream ReverseRequest) returns (stream ReverseResponse);
	rpc IpcSet(IpcSetRequest) returns (IpcSetResponse);
	rpc TurnOn(TurnOnRequest) returns (TurnOnResponse);
}

message TunnelHandle { int32 handle = 1; }

message Error {
	enum Code {
		NO_ERROR = 0;
		UNSPECIFIED = 1;
		INVALID_PROTOCOL_BUFFER = 2;
		INVALID_RESPONSE = 3;
	}
	Code code = 1;
	string message = 2;
}

message InetAddress {
	bytes address = 1;
}

message InetSocketAddress {
	InetAddress address = 1;
	uint32 port = 2;
}

message InetPrefix {
	InetAddress address = 1;
        uint32 prefixLenght = 2;
}

enum TurnOnFlags {
	NONE = 0x00;
	ENABLE_DHCP = 0x01;
	ENABLE_FOOBAR = 0x04;
} 

message StopGrpcRequest {
}

message StopGrpcResponse {
}

message VersionRequest {
}

message VersionResponse {
	string version = 1;
}

message StartHttpProxyRequest {
	string pacFileUrl = 1;
}

message StartHttpProxyResponse {
	uint32 listen_port = 1;
	Error error = 2;
}

message StopHttpProxyRequest {
}

message StopHttpProxyResponse {
	Error error = 1;
}

message ReverseRequest {
	oneof response {
		GetConnectionOwnerUidResponse uid = 1;
	}
}

message ReverseResponse {
	oneof request {
		GetConnectionOwnerUidRequest uid = 1;
	}
}

message GetConnectionOwnerUidRequest {
	// ConnectivityManager.getConnectionOwnerUid(int protocol,
	//     InetSocketAddress local, InetSocketAddress remote)
	int32 protocol = 1;
	InetSocketAddress local = 2;
	InetSocketAddress remote = 3;
}

message GetConnectionOwnerUidResponse {
	int32 uid = 1;
	string package = 2; // context.getPackageManager().getNameForUid()
}

message IpcSetRequest {
	TunnelHandle tunnel = 1;
	string config = 2;
}

message IpcSetResponse {
	Error error = 1;
}

message TurnOnRequest {
	string interfaceName = 1;
        int32 tunFd = 2;
        string settings = 3;
        // Bitwise-OR of TurnOnFlags.
        optional uint32 flags = 4;
        optional InetAddress linkLocalAddr = 5;
}

message TurnOnResponse {
        Error error = 1;
	TunnelHandle tunnel = 2;
        repeated InetPrefix addresses = 3;
        // TODO add dns servers etc.
}