mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-05-20 11:28:25 +03:00
Add new admin panel, failover, dns fallback, providers, limiters. Update XHTTP
This commit is contained in:
1556
service/node_manager_api/manager/manager.pb.go
Normal file
1556
service/node_manager_api/manager/manager.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
155
service/node_manager_api/manager/manager.proto
Normal file
155
service/node_manager_api/manager/manager.proto
Normal file
@@ -0,0 +1,155 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option go_package = "github.com/sagernet/sing-box/service/node_manager_api/manager";
|
||||
|
||||
package node_manager_api.v1;
|
||||
|
||||
service Manager {
|
||||
rpc AddNode (Node) returns (stream NodeData);
|
||||
rpc AcquireLock(AcquireLockRequest) returns (LockData);
|
||||
rpc RefreshLock(LockData) returns (Empty);
|
||||
rpc ReleaseLock(LockData) returns (Empty);
|
||||
rpc AddTrafficUsage(TrafficUsageRequest) returns (TrafficUsageReply);
|
||||
}
|
||||
|
||||
message Node {
|
||||
string uuid = 1;
|
||||
}
|
||||
|
||||
enum OpType {
|
||||
updateUsers = 0;
|
||||
updateUser = 1;
|
||||
deleteUser = 2;
|
||||
|
||||
updateBandwidthLimiters = 3;
|
||||
updateBandwidthLimiter = 4;
|
||||
deleteBandwidthLimiter = 5;
|
||||
|
||||
updateConnectionLimiters = 6;
|
||||
updateConnectionLimiter = 7;
|
||||
deleteConnectionLimiter = 8;
|
||||
|
||||
updateTrafficLimiters = 9;
|
||||
updateTrafficLimiter = 10;
|
||||
deleteTrafficLimiter = 11;
|
||||
|
||||
updateRateLimiters = 12;
|
||||
updateRateLimiter = 13;
|
||||
deleteRateLimiter = 14;
|
||||
}
|
||||
|
||||
message User {
|
||||
int32 id = 1;
|
||||
string username = 2;
|
||||
string inbound = 3;
|
||||
string type = 4;
|
||||
string uuid = 5;
|
||||
string password = 6;
|
||||
string secret = 7;
|
||||
string flow = 8;
|
||||
int32 alter_id = 9;
|
||||
}
|
||||
|
||||
message UserList {
|
||||
repeated User values = 1;
|
||||
}
|
||||
|
||||
message BandwidthLimiter {
|
||||
int32 id = 1;
|
||||
string username = 2;
|
||||
string outbound = 3;
|
||||
string strategy = 4;
|
||||
string connection_type = 5;
|
||||
string mode = 6;
|
||||
repeated string flow_keys = 7;
|
||||
string speed = 8;
|
||||
uint64 raw_speed = 9;
|
||||
}
|
||||
|
||||
message BandwidthLimiterList {
|
||||
repeated BandwidthLimiter values = 1;
|
||||
}
|
||||
|
||||
message ConnectionLimiter {
|
||||
int32 id = 1;
|
||||
string username = 2;
|
||||
string outbound = 3;
|
||||
string strategy = 4;
|
||||
string connection_type = 5;
|
||||
string lock_type = 6;
|
||||
uint32 count = 7;
|
||||
}
|
||||
|
||||
message ConnectionLimiterList {
|
||||
repeated ConnectionLimiter values = 1;
|
||||
}
|
||||
|
||||
message TrafficLimiter {
|
||||
int32 id = 1;
|
||||
string username = 2;
|
||||
string outbound = 3;
|
||||
string strategy = 4;
|
||||
string mode = 5;
|
||||
uint64 raw_used = 6;
|
||||
string quota = 7;
|
||||
uint64 raw_quota = 8;
|
||||
}
|
||||
|
||||
message TrafficLimiterList {
|
||||
repeated TrafficLimiter values = 1;
|
||||
}
|
||||
|
||||
message RateLimiter {
|
||||
int32 id = 1;
|
||||
string username = 2;
|
||||
string outbound = 3;
|
||||
string strategy = 4;
|
||||
string connection_type = 5;
|
||||
uint32 count = 6;
|
||||
string interval = 7;
|
||||
}
|
||||
|
||||
message RateLimiterList {
|
||||
repeated RateLimiter values = 1;
|
||||
}
|
||||
|
||||
message NodeData {
|
||||
|
||||
OpType op = 1;
|
||||
|
||||
oneof data {
|
||||
UserList users = 2;
|
||||
User user = 3;
|
||||
BandwidthLimiterList bandwidth_limiters = 4;
|
||||
BandwidthLimiter bandwidth_limiter = 5;
|
||||
ConnectionLimiterList connection_limiters = 6;
|
||||
ConnectionLimiter connection_limiter = 7;
|
||||
TrafficLimiterList traffic_limiters = 8;
|
||||
TrafficLimiter traffic_limiter = 9;
|
||||
RateLimiterList rate_limiters = 10;
|
||||
RateLimiter rate_limiter = 11;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
message AcquireLockRequest {
|
||||
int32 limiter_id = 1;
|
||||
string id = 2;
|
||||
}
|
||||
|
||||
message LockData {
|
||||
int32 limiter_id = 1;
|
||||
string id = 2;
|
||||
string handleId = 3;
|
||||
}
|
||||
|
||||
message TrafficUsageRequest {
|
||||
int32 limiter_id = 1;
|
||||
uint64 n = 2;
|
||||
}
|
||||
|
||||
message TrafficUsageReply {
|
||||
uint64 remaining = 1;
|
||||
}
|
||||
|
||||
message Empty {}
|
||||
277
service/node_manager_api/manager/manager_grpc.pb.go
Normal file
277
service/node_manager_api/manager/manager_grpc.pb.go
Normal file
@@ -0,0 +1,277 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.6.1
|
||||
// - protoc v6.31.1
|
||||
// source: service/node_manager_api/manager/manager.proto
|
||||
|
||||
package manager
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
Manager_AddNode_FullMethodName = "/node_manager_api.v1.Manager/AddNode"
|
||||
Manager_AcquireLock_FullMethodName = "/node_manager_api.v1.Manager/AcquireLock"
|
||||
Manager_RefreshLock_FullMethodName = "/node_manager_api.v1.Manager/RefreshLock"
|
||||
Manager_ReleaseLock_FullMethodName = "/node_manager_api.v1.Manager/ReleaseLock"
|
||||
Manager_AddTrafficUsage_FullMethodName = "/node_manager_api.v1.Manager/AddTrafficUsage"
|
||||
)
|
||||
|
||||
// ManagerClient is the client API for Manager service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type ManagerClient interface {
|
||||
AddNode(ctx context.Context, in *Node, opts ...grpc.CallOption) (grpc.ServerStreamingClient[NodeData], error)
|
||||
AcquireLock(ctx context.Context, in *AcquireLockRequest, opts ...grpc.CallOption) (*LockData, error)
|
||||
RefreshLock(ctx context.Context, in *LockData, opts ...grpc.CallOption) (*Empty, error)
|
||||
ReleaseLock(ctx context.Context, in *LockData, opts ...grpc.CallOption) (*Empty, error)
|
||||
AddTrafficUsage(ctx context.Context, in *TrafficUsageRequest, opts ...grpc.CallOption) (*TrafficUsageReply, error)
|
||||
}
|
||||
|
||||
type managerClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewManagerClient(cc grpc.ClientConnInterface) ManagerClient {
|
||||
return &managerClient{cc}
|
||||
}
|
||||
|
||||
func (c *managerClient) AddNode(ctx context.Context, in *Node, opts ...grpc.CallOption) (grpc.ServerStreamingClient[NodeData], error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
stream, err := c.cc.NewStream(ctx, &Manager_ServiceDesc.Streams[0], Manager_AddNode_FullMethodName, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &grpc.GenericClientStream[Node, NodeData]{ClientStream: stream}
|
||||
if err := x.ClientStream.SendMsg(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := x.ClientStream.CloseSend(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type Manager_AddNodeClient = grpc.ServerStreamingClient[NodeData]
|
||||
|
||||
func (c *managerClient) AcquireLock(ctx context.Context, in *AcquireLockRequest, opts ...grpc.CallOption) (*LockData, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(LockData)
|
||||
err := c.cc.Invoke(ctx, Manager_AcquireLock_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *managerClient) RefreshLock(ctx context.Context, in *LockData, opts ...grpc.CallOption) (*Empty, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(Empty)
|
||||
err := c.cc.Invoke(ctx, Manager_RefreshLock_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *managerClient) ReleaseLock(ctx context.Context, in *LockData, opts ...grpc.CallOption) (*Empty, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(Empty)
|
||||
err := c.cc.Invoke(ctx, Manager_ReleaseLock_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *managerClient) AddTrafficUsage(ctx context.Context, in *TrafficUsageRequest, opts ...grpc.CallOption) (*TrafficUsageReply, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(TrafficUsageReply)
|
||||
err := c.cc.Invoke(ctx, Manager_AddTrafficUsage_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// ManagerServer is the server API for Manager service.
|
||||
// All implementations must embed UnimplementedManagerServer
|
||||
// for forward compatibility.
|
||||
type ManagerServer interface {
|
||||
AddNode(*Node, grpc.ServerStreamingServer[NodeData]) error
|
||||
AcquireLock(context.Context, *AcquireLockRequest) (*LockData, error)
|
||||
RefreshLock(context.Context, *LockData) (*Empty, error)
|
||||
ReleaseLock(context.Context, *LockData) (*Empty, error)
|
||||
AddTrafficUsage(context.Context, *TrafficUsageRequest) (*TrafficUsageReply, error)
|
||||
mustEmbedUnimplementedManagerServer()
|
||||
}
|
||||
|
||||
// UnimplementedManagerServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedManagerServer struct{}
|
||||
|
||||
func (UnimplementedManagerServer) AddNode(*Node, grpc.ServerStreamingServer[NodeData]) error {
|
||||
return status.Error(codes.Unimplemented, "method AddNode not implemented")
|
||||
}
|
||||
func (UnimplementedManagerServer) AcquireLock(context.Context, *AcquireLockRequest) (*LockData, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method AcquireLock not implemented")
|
||||
}
|
||||
func (UnimplementedManagerServer) RefreshLock(context.Context, *LockData) (*Empty, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method RefreshLock not implemented")
|
||||
}
|
||||
func (UnimplementedManagerServer) ReleaseLock(context.Context, *LockData) (*Empty, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ReleaseLock not implemented")
|
||||
}
|
||||
func (UnimplementedManagerServer) AddTrafficUsage(context.Context, *TrafficUsageRequest) (*TrafficUsageReply, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method AddTrafficUsage not implemented")
|
||||
}
|
||||
func (UnimplementedManagerServer) mustEmbedUnimplementedManagerServer() {}
|
||||
func (UnimplementedManagerServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeManagerServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to ManagerServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeManagerServer interface {
|
||||
mustEmbedUnimplementedManagerServer()
|
||||
}
|
||||
|
||||
func RegisterManagerServer(s grpc.ServiceRegistrar, srv ManagerServer) {
|
||||
// If the following call panics, it indicates UnimplementedManagerServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&Manager_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Manager_AddNode_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
m := new(Node)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
}
|
||||
return srv.(ManagerServer).AddNode(m, &grpc.GenericServerStream[Node, NodeData]{ServerStream: stream})
|
||||
}
|
||||
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type Manager_AddNodeServer = grpc.ServerStreamingServer[NodeData]
|
||||
|
||||
func _Manager_AcquireLock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(AcquireLockRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ManagerServer).AcquireLock(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Manager_AcquireLock_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ManagerServer).AcquireLock(ctx, req.(*AcquireLockRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Manager_RefreshLock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(LockData)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ManagerServer).RefreshLock(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Manager_RefreshLock_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ManagerServer).RefreshLock(ctx, req.(*LockData))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Manager_ReleaseLock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(LockData)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ManagerServer).ReleaseLock(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Manager_ReleaseLock_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ManagerServer).ReleaseLock(ctx, req.(*LockData))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Manager_AddTrafficUsage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(TrafficUsageRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ManagerServer).AddTrafficUsage(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Manager_AddTrafficUsage_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ManagerServer).AddTrafficUsage(ctx, req.(*TrafficUsageRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Manager_ServiceDesc is the grpc.ServiceDesc for Manager service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Manager_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "node_manager_api.v1.Manager",
|
||||
HandlerType: (*ManagerServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "AcquireLock",
|
||||
Handler: _Manager_AcquireLock_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "RefreshLock",
|
||||
Handler: _Manager_RefreshLock_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ReleaseLock",
|
||||
Handler: _Manager_ReleaseLock_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "AddTrafficUsage",
|
||||
Handler: _Manager_AddTrafficUsage_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "AddNode",
|
||||
Handler: _Manager_AddNode_Handler,
|
||||
ServerStreams: true,
|
||||
},
|
||||
},
|
||||
Metadata: "service/node_manager_api/manager/manager.proto",
|
||||
}
|
||||
Reference in New Issue
Block a user