Skip to content

Commit

Permalink
添加trojan status命令
Browse files Browse the repository at this point in the history
  • Loading branch information
Jrohy committed Feb 23, 2020
1 parent daf3090 commit 5be159b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
35 changes: 35 additions & 0 deletions cmd/status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
Copyright © 2020 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd

import (
"trojan/trojan"

"github.com/spf13/cobra"
)

// statusCmd represents the status command
var statusCmd = &cobra.Command{
Use: "status",
Short: "查看trojan状态",
Run: func(cmd *cobra.Command, args []string) {
trojan.Status()
},
}

func init() {
rootCmd.AddCommand(statusCmd)
}
2 changes: 1 addition & 1 deletion trojan/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func UserList(ids ...string) *[]core.User {
fmt.Println("上传流量: " + util.Cyan(util.Bytefmt(k.Upload)))
fmt.Println("下载流量: " + util.Cyan(util.Bytefmt(k.Download)))
if k.Quota < 0 {
fmt.Println(util.Cyan("流量限额: 无限制"))
fmt.Println("流量限额: " + util.Cyan("无限制"))
} else {
fmt.Println("流量限额: " + util.Cyan(util.Bytefmt(uint64(k.Quota))))
}
Expand Down

0 comments on commit 5be159b

Please sign in to comment.