started_service.proto 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. syntax = "proto3";
  2. package daemon;
  3. option go_package = "github.com/sagernet/sing-box/daemon";
  4. import "google/protobuf/empty.proto";
  5. service StartedService {
  6. rpc StopService(google.protobuf.Empty) returns (google.protobuf.Empty);
  7. rpc ReloadService(google.protobuf.Empty) returns (google.protobuf.Empty);
  8. rpc SubscribeServiceStatus(google.protobuf.Empty) returns(stream ServiceStatus) {}
  9. rpc SubscribeLog(google.protobuf.Empty) returns(stream Log) {}
  10. rpc GetDefaultLogLevel(google.protobuf.Empty) returns(DefaultLogLevel) {}
  11. rpc ClearLogs(google.protobuf.Empty) returns(google.protobuf.Empty) {}
  12. rpc SubscribeStatus(SubscribeStatusRequest) returns(stream Status) {}
  13. rpc SubscribeGroups(google.protobuf.Empty) returns(stream Groups) {}
  14. rpc GetClashModeStatus(google.protobuf.Empty) returns(ClashModeStatus) {}
  15. rpc SubscribeClashMode(google.protobuf.Empty) returns(stream ClashMode) {}
  16. rpc SetClashMode(ClashMode) returns(google.protobuf.Empty) {}
  17. rpc URLTest(URLTestRequest) returns(google.protobuf.Empty) {}
  18. rpc SelectOutbound(SelectOutboundRequest) returns (google.protobuf.Empty) {}
  19. rpc SetGroupExpand(SetGroupExpandRequest) returns (google.protobuf.Empty) {}
  20. rpc GetSystemProxyStatus(google.protobuf.Empty) returns(SystemProxyStatus) {}
  21. rpc SetSystemProxyEnabled(SetSystemProxyEnabledRequest) returns(google.protobuf.Empty) {}
  22. rpc TriggerDebugCrash(DebugCrashRequest) returns(google.protobuf.Empty) {}
  23. rpc TriggerOOMReport(google.protobuf.Empty) returns(google.protobuf.Empty) {}
  24. rpc SubscribeConnections(SubscribeConnectionsRequest) returns(stream ConnectionEvents) {}
  25. rpc CloseConnection(CloseConnectionRequest) returns(google.protobuf.Empty) {}
  26. rpc CloseAllConnections(google.protobuf.Empty) returns(google.protobuf.Empty) {}
  27. rpc GetDeprecatedWarnings(google.protobuf.Empty) returns(DeprecatedWarnings) {}
  28. rpc GetStartedAt(google.protobuf.Empty) returns(StartedAt) {}
  29. rpc SubscribeOutbounds(google.protobuf.Empty) returns (stream OutboundList) {}
  30. rpc StartNetworkQualityTest(NetworkQualityTestRequest) returns (stream NetworkQualityTestProgress) {}
  31. rpc StartSTUNTest(STUNTestRequest) returns (stream STUNTestProgress) {}
  32. rpc SubscribeTailscaleStatus(google.protobuf.Empty) returns (stream TailscaleStatusUpdate) {}
  33. rpc StartTailscalePing(TailscalePingRequest) returns (stream TailscalePingResponse) {}
  34. }
  35. message ServiceStatus {
  36. enum Type {
  37. IDLE = 0;
  38. STARTING = 1;
  39. STARTED = 2;
  40. STOPPING = 3;
  41. FATAL = 4;
  42. }
  43. Type status = 1;
  44. string errorMessage = 2;
  45. }
  46. message ReloadServiceRequest {
  47. string newProfileContent = 1;
  48. }
  49. message SubscribeStatusRequest {
  50. int64 interval = 1;
  51. }
  52. enum LogLevel {
  53. PANIC = 0;
  54. FATAL = 1;
  55. ERROR = 2;
  56. WARN = 3;
  57. INFO = 4;
  58. DEBUG = 5;
  59. TRACE = 6;
  60. }
  61. message Log {
  62. repeated Message messages = 1;
  63. bool reset = 2;
  64. message Message {
  65. LogLevel level = 1;
  66. string message = 2;
  67. }
  68. }
  69. message DefaultLogLevel {
  70. LogLevel level = 1;
  71. }
  72. message Status {
  73. uint64 memory = 1;
  74. int32 goroutines = 2;
  75. int32 connectionsIn = 3;
  76. int32 connectionsOut = 4;
  77. bool trafficAvailable = 5;
  78. int64 uplink = 6;
  79. int64 downlink = 7;
  80. int64 uplinkTotal = 8;
  81. int64 downlinkTotal = 9;
  82. }
  83. message Groups {
  84. repeated Group group = 1;
  85. }
  86. message Group {
  87. string tag = 1;
  88. string type = 2;
  89. bool selectable = 3;
  90. string selected = 4;
  91. bool isExpand = 5;
  92. repeated GroupItem items = 6;
  93. }
  94. message GroupItem {
  95. string tag = 1;
  96. string type = 2;
  97. int64 urlTestTime = 3;
  98. int32 urlTestDelay = 4;
  99. }
  100. message URLTestRequest {
  101. string outboundTag = 1;
  102. }
  103. message SelectOutboundRequest {
  104. string groupTag = 1;
  105. string outboundTag = 2;
  106. }
  107. message SetGroupExpandRequest {
  108. string groupTag = 1;
  109. bool isExpand = 2;
  110. }
  111. message ClashMode {
  112. string mode = 3;
  113. }
  114. message ClashModeStatus {
  115. repeated string modeList = 1;
  116. string currentMode = 2;
  117. }
  118. message SystemProxyStatus {
  119. bool available = 1;
  120. bool enabled = 2;
  121. }
  122. message SetSystemProxyEnabledRequest {
  123. bool enabled = 1;
  124. }
  125. message DebugCrashRequest {
  126. enum Type {
  127. GO = 0;
  128. NATIVE = 1;
  129. }
  130. Type type = 1;
  131. }
  132. message SubscribeConnectionsRequest {
  133. int64 interval = 1;
  134. }
  135. enum ConnectionEventType {
  136. CONNECTION_EVENT_NEW = 0;
  137. CONNECTION_EVENT_UPDATE = 1;
  138. CONNECTION_EVENT_CLOSED = 2;
  139. }
  140. message ConnectionEvent {
  141. ConnectionEventType type = 1;
  142. string id = 2;
  143. Connection connection = 3;
  144. int64 uplinkDelta = 4;
  145. int64 downlinkDelta = 5;
  146. int64 closedAt = 6;
  147. }
  148. message ConnectionEvents {
  149. repeated ConnectionEvent events = 1;
  150. bool reset = 2;
  151. }
  152. message Connection {
  153. string id = 1;
  154. string inbound = 2;
  155. string inboundType = 3;
  156. int32 ipVersion = 4;
  157. string network = 5;
  158. string source = 6;
  159. string destination = 7;
  160. string domain = 8;
  161. string protocol = 9;
  162. string user = 10;
  163. string fromOutbound = 11;
  164. int64 createdAt = 12;
  165. int64 closedAt = 13;
  166. int64 uplink = 14;
  167. int64 downlink = 15;
  168. int64 uplinkTotal = 16;
  169. int64 downlinkTotal = 17;
  170. string rule = 18;
  171. string outbound = 19;
  172. string outboundType = 20;
  173. repeated string chainList = 21;
  174. ProcessInfo processInfo = 22;
  175. }
  176. message ProcessInfo {
  177. uint32 processId = 1;
  178. int32 userId = 2;
  179. string userName = 3;
  180. string processPath = 4;
  181. repeated string packageNames = 5;
  182. }
  183. message CloseConnectionRequest {
  184. string id = 1;
  185. }
  186. message DeprecatedWarnings {
  187. repeated DeprecatedWarning warnings = 1;
  188. }
  189. message DeprecatedWarning {
  190. string message = 1;
  191. bool impending = 2;
  192. string migrationLink = 3;
  193. string description = 4;
  194. string deprecatedVersion = 5;
  195. string scheduledVersion = 6;
  196. }
  197. message StartedAt {
  198. int64 startedAt = 1;
  199. }
  200. message OutboundList {
  201. repeated GroupItem outbounds = 1;
  202. }
  203. message NetworkQualityTestRequest {
  204. string configURL = 1;
  205. string outboundTag = 2;
  206. bool serial = 3;
  207. int32 maxRuntimeSeconds = 4;
  208. bool http3 = 5;
  209. }
  210. message NetworkQualityTestProgress {
  211. int32 phase = 1;
  212. int64 downloadCapacity = 2;
  213. int64 uploadCapacity = 3;
  214. int32 downloadRPM = 4;
  215. int32 uploadRPM = 5;
  216. int32 idleLatencyMs = 6;
  217. int64 elapsedMs = 7;
  218. bool isFinal = 8;
  219. string error = 9;
  220. int32 downloadCapacityAccuracy = 10;
  221. int32 uploadCapacityAccuracy = 11;
  222. int32 downloadRPMAccuracy = 12;
  223. int32 uploadRPMAccuracy = 13;
  224. }
  225. message STUNTestRequest {
  226. string server = 1;
  227. string outboundTag = 2;
  228. }
  229. message STUNTestProgress {
  230. int32 phase = 1;
  231. string externalAddr = 2;
  232. int32 latencyMs = 3;
  233. int32 natMapping = 4;
  234. int32 natFiltering = 5;
  235. bool isFinal = 6;
  236. string error = 7;
  237. bool natTypeSupported = 8;
  238. }
  239. message TailscaleStatusUpdate {
  240. repeated TailscaleEndpointStatus endpoints = 1;
  241. }
  242. message TailscaleEndpointStatus {
  243. string endpointTag = 1;
  244. string backendState = 2;
  245. string authURL = 3;
  246. string networkName = 4;
  247. string magicDNSSuffix = 5;
  248. TailscalePeer self = 6;
  249. repeated TailscaleUserGroup userGroups = 7;
  250. }
  251. message TailscaleUserGroup {
  252. int64 userID = 1;
  253. string loginName = 2;
  254. string displayName = 3;
  255. string profilePicURL = 4;
  256. repeated TailscalePeer peers = 5;
  257. }
  258. message TailscalePeer {
  259. string hostName = 1;
  260. string dnsName = 2;
  261. string os = 3;
  262. repeated string tailscaleIPs = 4;
  263. bool online = 5;
  264. bool exitNode = 6;
  265. bool exitNodeOption = 7;
  266. bool active = 8;
  267. int64 rxBytes = 9;
  268. int64 txBytes = 10;
  269. int64 keyExpiry = 11;
  270. }
  271. message TailscalePingRequest {
  272. string endpointTag = 1;
  273. string peerIP = 2;
  274. }
  275. message TailscalePingResponse {
  276. double latencyMs = 1;
  277. bool isDirect = 2;
  278. string endpoint = 3;
  279. int32 derpRegionID = 4;
  280. string derpRegionCode = 5;
  281. string error = 6;
  282. }