Skip to content

Commit

Permalink
fix: typo
Browse files Browse the repository at this point in the history
  • Loading branch information
Septrum101 committed Nov 8, 2022
1 parent 209f5a1 commit ddce3fa
Show file tree
Hide file tree
Showing 27 changed files with 149 additions and 164 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,30 @@ A Xray backend framework that can easily support many panels.

## 功能介绍

| 功能 | v2ray | trojan | shadowsocks |
| --------------- | ----- | ------ | ----------- |
| 功能 | v2ray | trojan | shadowsocks |
|-----------|-------|--------|-------------|
| 获取节点信息 ||||
| 获取用户信息 ||||
| 用户流量统计 ||||
| 服务器信息上报 ||||
| 服务器信息上报 ||||
| 自动申请tls证书 ||||
| 自动续签tls证书 ||||
| 在线人数统计 ||||
| 在线用户限制 ||||
| 审计规则 ||||
| 审计规则 ||||
| 节点端口限速 ||||
| 按照用户限速 ||||
| 自定义DNS ||||
| 自定义DNS ||||

## 支持前端

| 前端 | v2ray | trojan | shadowsocks |
| ------------------------------------------------------ | ----- | ------ | ------------------------------ |
| 前端 | v2ray | trojan | shadowsocks |
|--------------------------------------------------------|-------|--------|-------------------------|
| sspanel-uim ||| √ (单端口多用户和V2ray-Plugin) |
| v2board ||| |
| [PMPanel](https://github.com/ByteInternetHK/PMPanel) ||| |
| [ProxyPanel](https://github.com/ProxyPanel/ProxyPanel) ||| |
| [WHMCS (V2RaySocks)](https://v2raysocks.doxtex.com/) ||| |
| v2board ||||
| [PMPanel](https://github.com/ByteInternetHK/PMPanel) ||||
| [ProxyPanel](https://github.com/ProxyPanel/ProxyPanel) ||||
| [WHMCS (V2RaySocks)](https://v2raysocks.doxtex.com/) ||||

## 软件安装

Expand Down
4 changes: 2 additions & 2 deletions api/apimodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"regexp"
)

// API config
// Config API config
type Config struct {
APIHost string `mapstructure:"ApiHost"`
NodeID int `mapstructure:"NodeID"`
Expand All @@ -20,7 +20,7 @@ type Config struct {
DisableCustomConfig bool `mapstructure:"DisableCustomConfig"`
}

// Node status
// NodeStatus Node status
type NodeStatus struct {
CPU float64
Mem float64
Expand Down
2 changes: 1 addition & 1 deletion api/pmpanel/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type NodeInfoResponse struct {
Host string `json:"host"`
Path string `json:"path"`
Grpc bool `json:"grpc"`
Sni string `json:sni`
Sni string `json:"sni"`
}

// UserResponse is the response of user
Expand Down
16 changes: 8 additions & 8 deletions api/pmpanel/pmpanel.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func readLocalRuleList(path string) (LocalRuleList []api.DetectRule) {
// handle first encountered error while reading
if err := fileScanner.Err(); err != nil {
log.Fatalf("Error while reading file: %s", err)
return make([]api.DetectRule, 0)
return
}

file.Close()
Expand Down Expand Up @@ -131,7 +131,7 @@ func (c *APIClient) parseResponse(res *resty.Response, path string, err error) (

if response.Ret != 200 {
res, _ := json.Marshal(&response)
return nil, fmt.Errorf("Ret %s invalid", string(res))
return nil, fmt.Errorf("ret %s invalid", string(res))
}
return response, nil
}
Expand Down Expand Up @@ -168,7 +168,7 @@ func (c *APIClient) GetNodeInfo() (nodeInfo *api.NodeInfo, err error) {
nodeInfoResponse := new(NodeInfoResponse)

if err := json.Unmarshal(response.Data, nodeInfoResponse); err != nil {
return nil, fmt.Errorf("Unmarshal %s failed: %s", reflect.TypeOf(nodeInfoResponse), err)
return nil, fmt.Errorf("unmarshal %s failed: %s", reflect.TypeOf(nodeInfoResponse), err)
}
switch c.NodeType {
case "V2ray":
Expand All @@ -178,7 +178,7 @@ func (c *APIClient) GetNodeInfo() (nodeInfo *api.NodeInfo, err error) {
case "Shadowsocks":
nodeInfo, err = c.ParseSSNodeResponse(nodeInfoResponse)
default:
return nil, fmt.Errorf("Unsupported Node type: %s", c.NodeType)
return nil, fmt.Errorf("unsupported Node type: %s", c.NodeType)
}

if err != nil {
Expand Down Expand Up @@ -220,12 +220,12 @@ func (c *APIClient) GetUserList() (UserList *[]api.UserInfo, err error) {

var userListResponse *[]UserResponse
if err := json.Unmarshal(response.Data, &userListResponse); err != nil {
return nil, fmt.Errorf("Unmarshal %s failed: %s", reflect.TypeOf(userListResponse), err)
return nil, fmt.Errorf("unmarshal %s failed: %s", reflect.TypeOf(userListResponse), err)
}
userList, err := c.ParseUserListResponse(userListResponse)
if err != nil {
res, _ := json.Marshal(userListResponse)
return nil, fmt.Errorf("Parse user list failed: %s", string(res))
return nil, fmt.Errorf("parse user list failed: %s", string(res))
}
return userList, nil
}
Expand Down Expand Up @@ -339,7 +339,7 @@ func (c *APIClient) GetNodeRule() (*[]api.DetectRule, error) {
ruleListResponse := new([]RuleItem)

if err := json.Unmarshal(response.Data, ruleListResponse); err != nil {
return nil, fmt.Errorf("Unmarshal %s failed: %s", reflect.TypeOf(ruleListResponse), err)
return nil, fmt.Errorf("unmarshal %s failed: %s", reflect.TypeOf(ruleListResponse), err)
}

for _, r := range *ruleListResponse {
Expand Down Expand Up @@ -473,7 +473,7 @@ func (c *APIClient) ParseTrojanNodeResponse(nodeInfoResponse *NodeInfoResponse)

// ParseUserListResponse parse the response for the given nodeinfo format
func (c *APIClient) ParseUserListResponse(userInfoResponse *[]UserResponse) (*[]api.UserInfo, error) {
var deviceLimit int = 0
var deviceLimit = 0
var speedlimit uint64 = 0
userList := make([]api.UserInfo, len(*userInfoResponse))
for i, user := range *userInfoResponse {
Expand Down
6 changes: 3 additions & 3 deletions api/pmpanel/pmpanel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestGetUserList(t *testing.T) {
func TestReportNodeStatus(t *testing.T) {
client := CreateClient()
nodeStatus := &api.NodeStatus{
1, 1, 1, 256,
CPU: 1, Mem: 1, Disk: 1, Uptime: 256,
}
err := client.ReportNodeStatus(nodeStatus)
if err != nil {
Expand Down Expand Up @@ -150,8 +150,8 @@ func TestReportIllegal(t *testing.T) {
client := CreateClient()

detectResult := []api.DetectResult{
api.DetectResult{1, 2},
api.DetectResult{1, 3},
{1, 2},
{1, 3},
}
client.Debug()
err := client.ReportIllegal(&detectResult)
Expand Down
3 changes: 1 addition & 2 deletions api/proxypanel/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type TrojanNodeInfo struct {
TrojanPort uint32 `json:"trojan_port"`
}

// Node status report
// NodeStatus Node status report
type NodeStatus struct {
CPU string `json:"cpu"`
Mem string `json:"mem"`
Expand Down Expand Up @@ -98,7 +98,6 @@ type NodeRuleItem struct {
Pattern string `json:"pattern"`
}

// IllegalReport
type IllegalReport struct {
UID int `json:"uid"`
RuleID int `json:"rule_id"`
Expand Down
50 changes: 25 additions & 25 deletions api/proxypanel/proxypanel.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func readLocalRuleList(path string) (LocalRuleList []api.DetectRule) {
// handle first encountered error while reading
if err := fileScanner.Err(); err != nil {
log.Fatalf("Error while reading file: %s", err)
return make([]api.DetectRule, 0)
return
}

file.Close()
Expand Down Expand Up @@ -135,7 +135,7 @@ func (c *APIClient) parseResponse(res *resty.Response, path string, err error) (

if response.Status != "success" {
res, _ := json.Marshal(&response)
return nil, fmt.Errorf("Ret %s invalid", string(res))
return nil, fmt.Errorf("ret %s invalid", string(res))
}
return response, nil
}
Expand All @@ -151,7 +151,7 @@ func (c *APIClient) GetNodeInfo() (nodeInfo *api.NodeInfo, err error) {
case "Shadowsocks":
path = fmt.Sprintf("/api/ss/v1/node/%d", c.NodeID)
default:
return nil, fmt.Errorf("Unsupported Node type: %s", c.NodeType)
return nil, fmt.Errorf("unsupported Node type: %s", c.NodeType)
}

res, err := c.createCommonRequest().
Expand All @@ -172,7 +172,7 @@ func (c *APIClient) GetNodeInfo() (nodeInfo *api.NodeInfo, err error) {
case "Shadowsocks":
nodeInfo, err = c.ParseSSNodeResponse(&response.Data)
default:
return nil, fmt.Errorf("Unsupported Node type: %s", c.NodeType)
return nil, fmt.Errorf("unsupported Node type: %s", c.NodeType)
}

if err != nil {
Expand All @@ -194,7 +194,7 @@ func (c *APIClient) GetUserList() (UserList *[]api.UserInfo, err error) {
case "Shadowsocks":
path = fmt.Sprintf("/api/ss/v1/userList/%d", c.NodeID)
default:
return nil, fmt.Errorf("Unsupported Node type: %s", c.NodeType)
return nil, fmt.Errorf("unsupported Node type: %s", c.NodeType)
}

res, err := c.createCommonRequest().
Expand All @@ -215,11 +215,11 @@ func (c *APIClient) GetUserList() (UserList *[]api.UserInfo, err error) {
case "Shadowsocks":
userList, err = c.ParseSSUserListResponse(&response.Data)
default:
return nil, fmt.Errorf("Unsupported Node type: %s", c.NodeType)
return nil, fmt.Errorf("unsupported Node type: %s", c.NodeType)
}
if err != nil {
res, _ := json.Marshal(response.Data)
return nil, fmt.Errorf("Parse user list failed: %s", string(res))
return nil, fmt.Errorf("parse user list failed: %s", string(res))
}
return userList, nil
}
Expand All @@ -235,7 +235,7 @@ func (c *APIClient) ReportNodeStatus(nodeStatus *api.NodeStatus) (err error) {
case "Shadowsocks":
path = fmt.Sprintf("/api/ss/v1/nodeStatus/%d", c.NodeID)
default:
return fmt.Errorf("Unsupported Node type: %s", c.NodeType)
return fmt.Errorf("unsupported Node type: %s", c.NodeType)
}

systemload := NodeStatus{
Expand Down Expand Up @@ -271,7 +271,7 @@ func (c *APIClient) ReportNodeOnlineUsers(onlineUserList *[]api.OnlineUser) erro
case "Shadowsocks":
path = fmt.Sprintf("/api/ss/v1/nodeOnline/%d", c.NodeID)
default:
return fmt.Errorf("Unsupported Node type: %s", c.NodeType)
return fmt.Errorf("unsupported Node type: %s", c.NodeType)
}

data := make([]NodeOnline, len(*onlineUserList))
Expand Down Expand Up @@ -304,7 +304,7 @@ func (c *APIClient) ReportUserTraffic(userTraffic *[]api.UserTraffic) error {
case "Shadowsocks":
path = fmt.Sprintf("/api/ss/v1/userTraffic/%d", c.NodeID)
default:
return fmt.Errorf("Unsupported Node type: %s", c.NodeType)
return fmt.Errorf("unsupported Node type: %s", c.NodeType)
}

data := make([]UserTraffic, len(*userTraffic))
Expand Down Expand Up @@ -339,7 +339,7 @@ func (c *APIClient) GetNodeRule() (*[]api.DetectRule, error) {
case "Shadowsocks":
path = fmt.Sprintf("/api/ss/v1/nodeRule/%d", c.NodeID)
default:
return nil, fmt.Errorf("Unsupported Node type: %s", c.NodeType)
return nil, fmt.Errorf("unsupported Node type: %s", c.NodeType)
}

res, err := c.createCommonRequest().
Expand All @@ -355,7 +355,7 @@ func (c *APIClient) GetNodeRule() (*[]api.DetectRule, error) {
ruleListResponse := new(NodeRule)

if err := json.Unmarshal(response.Data, ruleListResponse); err != nil {
return nil, fmt.Errorf("Unmarshal %s failed: %s", reflect.TypeOf(ruleListResponse), err)
return nil, fmt.Errorf("unmarshal %s failed: %s", reflect.TypeOf(ruleListResponse), err)
}
ruleList := c.LocalRuleList
// Only support reject rule type
Expand Down Expand Up @@ -387,7 +387,7 @@ func (c *APIClient) ReportIllegal(detectResultList *[]api.DetectResult) error {
case "Shadowsocks":
path = fmt.Sprintf("/api/ss/v1/trigger/%d", c.NodeID)
default:
return fmt.Errorf("Unsupported Node type: %s", c.NodeType)
return fmt.Errorf("unsupported Node type: %s", c.NodeType)
}

for _, r := range *detectResultList {
Expand Down Expand Up @@ -422,13 +422,13 @@ func (c *APIClient) ParseV2rayNodeResponse(nodeInfoResponse *json.RawMessage) (*

v2rayNodeInfo := new(V2rayNodeInfo)
if err := json.Unmarshal(*nodeInfoResponse, v2rayNodeInfo); err != nil {
return nil, fmt.Errorf("Unmarshal %s failed: %s", reflect.TypeOf(*nodeInfoResponse), err)
return nil, fmt.Errorf("unmarshal %s failed: %s", reflect.TypeOf(*nodeInfoResponse), err)
}

if c.SpeedLimit > 0 {
speedlimit = uint64((c.SpeedLimit * 1000000) / 8)
} else {
speedlimit = uint64((v2rayNodeInfo.SpeedLimit * 1000000) / 8)
speedlimit = (v2rayNodeInfo.SpeedLimit * 1000000) / 8
}

if c.DeviceLimit == 0 && v2rayNodeInfo.ClientLimit > 0 {
Expand Down Expand Up @@ -459,12 +459,12 @@ func (c *APIClient) ParseSSNodeResponse(nodeInfoResponse *json.RawMessage) (*api
var speedlimit uint64 = 0
shadowsocksNodeInfo := new(ShadowsocksNodeInfo)
if err := json.Unmarshal(*nodeInfoResponse, shadowsocksNodeInfo); err != nil {
return nil, fmt.Errorf("Unmarshal %s failed: %s", reflect.TypeOf(*nodeInfoResponse), err)
return nil, fmt.Errorf("unmarshal %s failed: %s", reflect.TypeOf(*nodeInfoResponse), err)
}
if c.SpeedLimit > 0 {
speedlimit = uint64((c.SpeedLimit * 1000000) / 8)
} else {
speedlimit = uint64((shadowsocksNodeInfo.SpeedLimit * 1000000) / 8)
speedlimit = (shadowsocksNodeInfo.SpeedLimit * 1000000) / 8
}

if c.DeviceLimit == 0 && shadowsocksNodeInfo.ClientLimit > 0 {
Expand Down Expand Up @@ -496,12 +496,12 @@ func (c *APIClient) ParseTrojanNodeResponse(nodeInfoResponse *json.RawMessage) (

trojanNodeInfo := new(TrojanNodeInfo)
if err := json.Unmarshal(*nodeInfoResponse, trojanNodeInfo); err != nil {
return nil, fmt.Errorf("Unmarshal %s failed: %s", reflect.TypeOf(*nodeInfoResponse), err)
return nil, fmt.Errorf("unmarshal %s failed: %s", reflect.TypeOf(*nodeInfoResponse), err)
}
if c.SpeedLimit > 0 {
speedlimit = uint64((c.SpeedLimit * 1000000) / 8)
} else {
speedlimit = uint64((trojanNodeInfo.SpeedLimit * 1000000) / 8)
speedlimit = (trojanNodeInfo.SpeedLimit * 1000000) / 8
}

if c.DeviceLimit == 0 && trojanNodeInfo.ClientLimit > 0 {
Expand All @@ -528,15 +528,15 @@ func (c *APIClient) ParseV2rayUserListResponse(userInfoResponse *json.RawMessage

vmessUserList := new([]*VMessUser)
if err := json.Unmarshal(*userInfoResponse, vmessUserList); err != nil {
return nil, fmt.Errorf("Unmarshal %s failed: %s", reflect.TypeOf(*userInfoResponse), err)
return nil, fmt.Errorf("unmarshal %s failed: %s", reflect.TypeOf(*userInfoResponse), err)
}

userList := make([]api.UserInfo, len(*vmessUserList))
for i, user := range *vmessUserList {
if c.SpeedLimit > 0 {
speedlimit = uint64((c.SpeedLimit * 1000000) / 8)
} else {
speedlimit = uint64((user.SpeedLimit * 1000000) / 8)
speedlimit = (user.SpeedLimit * 1000000) / 8
}
userList[i] = api.UserInfo{
UID: user.UID,
Expand All @@ -556,15 +556,15 @@ func (c *APIClient) ParseTrojanUserListResponse(userInfoResponse *json.RawMessag

trojanUserList := new([]*TrojanUser)
if err := json.Unmarshal(*userInfoResponse, trojanUserList); err != nil {
return nil, fmt.Errorf("Unmarshal %s failed: %s", reflect.TypeOf(*userInfoResponse), err)
return nil, fmt.Errorf("unmarshal %s failed: %s", reflect.TypeOf(*userInfoResponse), err)
}

userList := make([]api.UserInfo, len(*trojanUserList))
for i, user := range *trojanUserList {
if c.SpeedLimit > 0 {
speedlimit = uint64((c.SpeedLimit * 1000000) / 8)
} else {
speedlimit = uint64((user.SpeedLimit * 1000000) / 8)
speedlimit = (user.SpeedLimit * 1000000) / 8
}
userList[i] = api.UserInfo{
UID: user.UID,
Expand All @@ -584,15 +584,15 @@ func (c *APIClient) ParseSSUserListResponse(userInfoResponse *json.RawMessage) (

ssUserList := new([]*SSUser)
if err := json.Unmarshal(*userInfoResponse, ssUserList); err != nil {
return nil, fmt.Errorf("Unmarshal %s failed: %s", reflect.TypeOf(*userInfoResponse), err)
return nil, fmt.Errorf("unmarshal %s failed: %s", reflect.TypeOf(*userInfoResponse), err)
}

userList := make([]api.UserInfo, len(*ssUserList))
for i, user := range *ssUserList {
if c.SpeedLimit > 0 {
speedlimit = uint64((c.SpeedLimit * 1000000) / 8)
} else {
speedlimit = uint64((user.SpeedLimit * 1000000) / 8)
speedlimit = (user.SpeedLimit * 1000000) / 8
}
userList[i] = api.UserInfo{
UID: user.UID,
Expand Down
Loading

0 comments on commit ddce3fa

Please sign in to comment.