ssrpanel

package module
v0.5.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2020 License: MIT Imports: 28 Imported by: 0

README

A buildin V2ray plugin for SSRPanel

Only one thing user should do is that setting up the database connection, without doing that user needn't do anything!

Features
  • Sync user from SSRPanel database to v2ray
  • Log user traffic
Benefits
  • No other requirements
    • It's able to run if you could launch v2ray core
  • Less memory usage
    • It just takes about 5MB to 10MB memories more than v2ray core
    • Small RAM VPS would be joyful
  • Simplicity configuration
Install on Linux

you may want to see docs, all the things as same as the official docs except install command.

V2ray installation

curl -L -s https://raw.githubusercontent.com/elvischao/v2ray-ssrpanel-plugin/master/install-release.sh | sudo bash
Uninstall
curl -L -s https://raw.githubusercontent.com/elvischao/v2ray-ssrpanel-plugin/master/uninstall.sh | sudo bash
V2ray Configuration demo
{
  "log": {
    "loglevel": "debug"
  },
  "api": {
    "tag": "api",
    "services": [
      "HandlerService",
      "LoggerService",
      "StatsService"
    ]
  },
  "stats": {},
  "inbounds": [{
    "port": 10086,
    "protocol": "vmess",
    "tag": "proxy"
  },{
    "listen": "127.0.0.1",
    "port": 10085,
    "protocol": "dokodemo-door",
    "settings": {
      "address": "127.0.0.1"
    },
    "tag": "api"
  }],
  "outbounds": [{
    "protocol": "freedom"
  }],
  "routing": {
    "rules": [{
      "type": "field",
      "inboundTag": [ "api" ],
      "outboundTag": "api"
    }],
    "strategy": "rules"
  },
  "policy": {
    "levels": {
      "0": {
        "statsUserUplink": true,
        "statsUserDownlink": true
      }
    },
    "system": {
      "statsInboundUplink": true,
      "statsInboundDownlink": true
    }
  },

  "ssrpanel": {
    // Node id on your SSR Panel
    "nodeId": 1,
    // every N seconds
    "checkRate": 60,
    // change this to true if you want to ignore users which has an empty vmess_id
    "ignoreEmptyVmessID": false,
    // user config
    "user": {
      // inbound tag, which inbound you would like add user to
      "inboundTag": "proxy",
      "level": 0,
      "alterId": 16,
      "security": "none"
    },
    // db connection
    "mysql": {
      "host": "127.0.0.1",
      "port": 3306,
      "user": "root",
      "password": "your_pwd",
      "dbname": "demo_db"
    }
  }



}
Contributing

Read WiKi carefully before submitting issues.

  • Test and report bugs
  • Share your needs/experiences in github issues
  • Enhance documentation
  • Contribute code by sending PR
References

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InStr

func InStr(s string, list []string) bool

Types

type Config

type Config struct {
	NodeID             uint         `json:"nodeId"`
	CheckRate          int          `json:"checkRate"`
	MySQL              *MySQLConfig `json:"mysql"`
	UserConfig         *UserConfig  `json:"user"`
	IgnoreEmptyVmessID bool         `json:"ignoreEmptyVmessID"`
	// contains filtered or unexported fields
}

type DB

type DB struct {
	DB         *gorm.DB
	RetryTimes int64
}

func NewMySQLConn

func NewMySQLConn(config *MySQLConfig) (*DB, error)

func (*DB) GetAllUsers

func (db *DB) GetAllUsers() ([]UserModel, error)

func (*DB) GetNode

func (db *DB) GetNode(id uint) (*Node, error)

type HandlerServiceClient

type HandlerServiceClient struct {
	command.HandlerServiceClient
	// contains filtered or unexported fields
}

func NewHandlerServiceClient

func NewHandlerServiceClient(client *grpc.ClientConn, inboundTag string) *HandlerServiceClient

func (*HandlerServiceClient) AddUser

func (h *HandlerServiceClient) AddUser(user *protocol.User) error

func (*HandlerServiceClient) AlterInbound

func (h *HandlerServiceClient) AlterInbound(req *command.AlterInboundRequest) error

func (*HandlerServiceClient) DelUser

func (h *HandlerServiceClient) DelUser(email string) error

type MySQLConfig

type MySQLConfig struct {
	Host     string `json:"host"`
	Port     int    `json:"port"`
	User     string `json:"user"`
	Password string `json:"password"`
	DBName   string `json:"dbname"`
}

func (*MySQLConfig) FormatDSN

func (c *MySQLConfig) FormatDSN() (string, error)

type Node

type Node struct {
	ID          uint `gorm:"primary_key"`
	TrafficRate float64
}

func (*Node) TableName

func (*Node) TableName() string

type NodeIP

type NodeIP struct {
	ID        uint `gorm:"primary_key"`
	NodeID    uint
	UserID    uint
	Port      int
	IPList    string `gorm:"column:ip"`
	CreatedAt int64
}

func (*NodeIP) BeforeCreate

func (n *NodeIP) BeforeCreate(scope *gorm.Scope) error

func (*NodeIP) TableName

func (*NodeIP) TableName() string

type NodeInfo

type NodeInfo struct {
	ID      uint `gorm:"primary_key"`
	NodeID  uint
	Uptime  time.Duration
	Load    string
	LogTime int64
}

func (*NodeInfo) BeforeCreate

func (l *NodeInfo) BeforeCreate(scope *gorm.Scope) error

func (*NodeInfo) TableName

func (*NodeInfo) TableName() string

type NodeOnlineLog

type NodeOnlineLog struct {
	ID         uint `gorm:"primary_key"`
	NodeID     uint
	OnlineUser int
	LogTime    int64
}

func (*NodeOnlineLog) BeforeCreate

func (l *NodeOnlineLog) BeforeCreate(scope *gorm.Scope) error

func (*NodeOnlineLog) TableName

func (*NodeOnlineLog) TableName() string

type Panel

type Panel struct {
	*Config
	// contains filtered or unexported fields
}

func NewPanel

func NewPanel(gRPCConn *grpc.ClientConn, db *DB, cfg *Config) (*Panel, error)

func (*Panel) Start

func (p *Panel) Start()

type StatsServiceClient

type StatsServiceClient struct {
	statsservice.StatsServiceClient
}

func NewStatsServiceClient

func NewStatsServiceClient(client *grpc.ClientConn) *StatsServiceClient

type UserConfig

type UserConfig struct {
	InboundTag  string `json:"inboundTag"`
	Level       uint32 `json:"level"`
	AlterID     uint32 `json:"alterId"`
	SecurityStr string `json:"securityConfig"`
	// contains filtered or unexported fields
}

func (*UserConfig) UnmarshalJSON

func (c *UserConfig) UnmarshalJSON(data []byte) error

type UserModel

type UserModel struct {
	ID      uint
	VmessID string `gorm:"column:uuid"`
	Email   string `gorm:"column:username"`
	Port    int
}

func (*UserModel) TableName

func (*UserModel) TableName() string

type UserTrafficLog

type UserTrafficLog struct {
	ID       uint `gorm:"primary_key"`
	UserID   uint
	Uplink   uint64 `gorm:"column:u"`
	Downlink uint64 `gorm:"column:d"`
	NodeID   uint
	Rate     float64
	Traffic  string
	LogTime  int64
}

func (*UserTrafficLog) BeforeCreate

func (l *UserTrafficLog) BeforeCreate(scope *gorm.Scope) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL