started_service.proto 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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 SubscribeConnections(SubscribeConnectionsRequest) returns(stream ConnectionEvents) {}
  23. rpc CloseConnection(CloseConnectionRequest) returns(google.protobuf.Empty) {}
  24. rpc CloseAllConnections(google.protobuf.Empty) returns(google.protobuf.Empty) {}
  25. rpc GetDeprecatedWarnings(google.protobuf.Empty) returns(DeprecatedWarnings) {}
  26. rpc GetStartedAt(google.protobuf.Empty) returns(StartedAt) {}
  27. }
  28. message ServiceStatus {
  29. enum Type {
  30. IDLE = 0;
  31. STARTING = 1;
  32. STARTED = 2;
  33. STOPPING = 3;
  34. FATAL = 4;
  35. }
  36. Type status = 1;
  37. string errorMessage = 2;
  38. }
  39. message ReloadServiceRequest {
  40. string newProfileContent = 1;
  41. }
  42. message SubscribeStatusRequest {
  43. int64 interval = 1;
  44. }
  45. enum LogLevel {
  46. PANIC = 0;
  47. FATAL = 1;
  48. ERROR = 2;
  49. WARN = 3;
  50. INFO = 4;
  51. DEBUG = 5;
  52. TRACE = 6;
  53. }
  54. message Log {
  55. repeated Message messages = 1;
  56. bool reset = 2;
  57. message Message {
  58. LogLevel level = 1;
  59. string message = 2;
  60. }
  61. }
  62. message DefaultLogLevel {
  63. LogLevel level = 1;
  64. }
  65. message Status {
  66. uint64 memory = 1;
  67. int32 goroutines = 2;
  68. int32 connectionsIn = 3;
  69. int32 connectionsOut = 4;
  70. bool trafficAvailable = 5;
  71. int64 uplink = 6;
  72. int64 downlink = 7;
  73. int64 uplinkTotal = 8;
  74. int64 downlinkTotal = 9;
  75. }
  76. message Groups {
  77. repeated Group group = 1;
  78. }
  79. message Group {
  80. string tag = 1;
  81. string type = 2;
  82. bool selectable = 3;
  83. string selected = 4;
  84. bool isExpand = 5;
  85. repeated GroupItem items = 6;
  86. }
  87. message GroupItem {
  88. string tag = 1;
  89. string type = 2;
  90. int64 urlTestTime = 3;
  91. int32 urlTestDelay = 4;
  92. }
  93. message URLTestRequest {
  94. string outboundTag = 1;
  95. }
  96. message SelectOutboundRequest {
  97. string groupTag = 1;
  98. string outboundTag = 2;
  99. }
  100. message SetGroupExpandRequest {
  101. string groupTag = 1;
  102. bool isExpand = 2;
  103. }
  104. message ClashMode {
  105. string mode = 3;
  106. }
  107. message ClashModeStatus {
  108. repeated string modeList = 1;
  109. string currentMode = 2;
  110. }
  111. message SystemProxyStatus {
  112. bool available = 1;
  113. bool enabled = 2;
  114. }
  115. message SetSystemProxyEnabledRequest {
  116. bool enabled = 1;
  117. }
  118. message SubscribeConnectionsRequest {
  119. int64 interval = 1;
  120. }
  121. enum ConnectionEventType {
  122. CONNECTION_EVENT_NEW = 0;
  123. CONNECTION_EVENT_UPDATE = 1;
  124. CONNECTION_EVENT_CLOSED = 2;
  125. }
  126. message ConnectionEvent {
  127. ConnectionEventType type = 1;
  128. string id = 2;
  129. Connection connection = 3;
  130. int64 uplinkDelta = 4;
  131. int64 downlinkDelta = 5;
  132. int64 closedAt = 6;
  133. }
  134. message ConnectionEvents {
  135. repeated ConnectionEvent events = 1;
  136. bool reset = 2;
  137. }
  138. message Connection {
  139. string id = 1;
  140. string inbound = 2;
  141. string inboundType = 3;
  142. int32 ipVersion = 4;
  143. string network = 5;
  144. string source = 6;
  145. string destination = 7;
  146. string domain = 8;
  147. string protocol = 9;
  148. string user = 10;
  149. string fromOutbound = 11;
  150. int64 createdAt = 12;
  151. int64 closedAt = 13;
  152. int64 uplink = 14;
  153. int64 downlink = 15;
  154. int64 uplinkTotal = 16;
  155. int64 downlinkTotal = 17;
  156. string rule = 18;
  157. string outbound = 19;
  158. string outboundType = 20;
  159. repeated string chainList = 21;
  160. ProcessInfo processInfo = 22;
  161. }
  162. message ProcessInfo {
  163. uint32 processId = 1;
  164. int32 userId = 2;
  165. string userName = 3;
  166. string processPath = 4;
  167. repeated string packageNames = 5;
  168. }
  169. message CloseConnectionRequest {
  170. string id = 1;
  171. }
  172. message DeprecatedWarnings {
  173. repeated DeprecatedWarning warnings = 1;
  174. }
  175. message DeprecatedWarning {
  176. string message = 1;
  177. bool impending = 2;
  178. string migrationLink = 3;
  179. }
  180. message StartedAt {
  181. int64 startedAt = 1;
  182. }