ssrpanel

package module
v1.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2019 License: MIT Imports: 28 Imported by: 0

README

Poseidon -- A buildin V2ray plugin

Why change the name of the repo

The name have to be changed for these reasons:

  1. I've learnt that there are still many panels need to be adapt with V2ray
  • SSPanel-v3
  • WEBAPI SSRPanel(VNetPanel)
  1. I'd like to provide a new deployment way
  • Poseidon-Master node
    • Automatic install Poseidon-V2ray node on new nodes which you added to the server list in your panel
    • Automatic config Poseidon-V2ray node
    • Real-time script output of deployment can be seen in Web browsers
    • Any time and any where you can execute shell commands in your poseidon-v2ray node
  • Poseidon-V2ray node
  1. To config with ease, a bran-new v2ray config generator is going to be introduced to Poseidon-master.

Versions

Tenet

All features is going to be available for any version, the only one difference is user scale. They'll be in effect for users which user id is not greater than 50 for Community version. Contact us to get an Enterprise version which has no limit of user scale, if needed.

Contact

Get in touch via TG group: v2ray_poseidon

Updates

  • v1.0.0

    Breaking Changes:

    • config files structure has been changed, new structure is:
    {
    -  "ssrpanel": {
    +  "poseidon": {
        ... ... 
      }
    }
    
    • Added IP limit
      • It's a number that how many ip a user can use at the same moment
      • You can set user's protocol_param field on the database
    • Added rate limit
      • You should set user's speed_limit_per_user and speed_limit_per_conn fields on the database
    • Added closing user connections instantly after user has been deleted
      • By default the user's connections will not be disconnected after being deleted, but that is not we wanted.
    • !!!Warning: These two features are available if user's id is less or equal 50
    • To support all users, please contact with me via TG group: v2ray_poseidon

=========================

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/ColetteContreras/v2ray-ssrpanel-plugin/master/install-release.sh | sudo bash
Uninstall
curl -L -s https://raw.githubusercontent.com/ColetteContreras/v2ray-ssrpanel-plugin/master/uninstall.sh | sudo bash
V2ray Configuration demo
{
  "log": {
    "loglevel": "debug"
  },
  "api": {
    "tag": "api",
    "services": [
      "HandlerService",
      "LoggerService",
      "StatsService"
    ]
  },
  "stats": {
    "trackIp": true
  },
  "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": "ssrpanel",
      "dbname": "ssrpanel"
    }
  }



}
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
	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