plugin.proto 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. syntax = "proto3";
  2. package sub2api.plugin.v1;
  3. option go_package = "github.com/Wei-Shaw/sub2api/pkg/pluginapi/v1;pluginv1";
  4. service TransportPlugin {
  5. rpc GetInfo(GetInfoRequest) returns (GetInfoResponse);
  6. rpc Health(HealthRequest) returns (HealthResponse);
  7. rpc ValidateConfig(ValidateConfigRequest) returns (ValidateConfigResponse);
  8. rpc ApplyConfig(ApplyConfigRequest) returns (ApplyConfigResponse);
  9. rpc TestConfig(TestConfigRequest) returns (TestConfigResponse);
  10. rpc Forward(stream ForwardRequest) returns (stream ForwardResponse);
  11. }
  12. message GetInfoRequest {}
  13. message GetInfoResponse {
  14. string plugin_id = 1;
  15. string plugin_version = 2;
  16. uint32 protocol_version = 3;
  17. uint32 transport_api_version = 4;
  18. repeated string capabilities = 5;
  19. }
  20. message HealthRequest {}
  21. message HealthResponse {
  22. bool healthy = 1;
  23. string message = 2;
  24. }
  25. message ValidateConfigRequest {
  26. bytes config_json = 1;
  27. }
  28. message ValidateConfigResponse {
  29. bool valid = 1;
  30. string message = 2;
  31. bytes normalized_config_json = 3;
  32. }
  33. message ApplyConfigRequest {
  34. bytes config_json = 1;
  35. }
  36. message ApplyConfigResponse {
  37. bool applied = 1;
  38. string message = 2;
  39. }
  40. message TestConfigRequest {
  41. bytes config_json = 1;
  42. }
  43. message TestConfigResponse {
  44. bool success = 1;
  45. string message = 2;
  46. int64 latency_ms = 3;
  47. }
  48. message HeaderValues {
  49. repeated string values = 1;
  50. }
  51. message ForwardRequestStart {
  52. string request_id = 1;
  53. string method = 2;
  54. string url = 3;
  55. string host = 4;
  56. map<string, HeaderValues> headers = 5;
  57. string proxy_url = 6;
  58. int64 account_id = 7;
  59. int32 account_concurrency = 8;
  60. string platform = 9;
  61. string account_type = 10;
  62. int64 content_length = 11;
  63. bool has_body = 12;
  64. }
  65. message ForwardRequest {
  66. oneof frame {
  67. ForwardRequestStart start = 1;
  68. bytes body_chunk = 2;
  69. bool body_end = 3;
  70. }
  71. }
  72. message ForwardResponseStart {
  73. int32 status_code = 1;
  74. string status = 2;
  75. string protocol = 3;
  76. int32 protocol_major = 4;
  77. int32 protocol_minor = 5;
  78. map<string, HeaderValues> headers = 6;
  79. int64 content_length = 7;
  80. }
  81. message ForwardResponseEnd {
  82. int64 bytes_received = 1;
  83. int64 duration_ms = 2;
  84. }
  85. message ForwardResponseError {
  86. string code = 1;
  87. string message = 2;
  88. bool request_sent = 3;
  89. }
  90. message ForwardResponse {
  91. oneof frame {
  92. ForwardResponseStart start = 1;
  93. bytes body_chunk = 2;
  94. ForwardResponseEnd end = 3;
  95. ForwardResponseError error = 4;
  96. }
  97. }