Added /uptime command support
This commit is contained in:
parent
857dcd0a14
commit
e62755322d
|
@ -134,6 +134,8 @@ func (c *Client) handleShell(channel ssh.Channel) {
|
||||||
c.WriteLines(strings.Split(HELP_TEXT, "\n"))
|
c.WriteLines(strings.Split(HELP_TEXT, "\n"))
|
||||||
case "/about":
|
case "/about":
|
||||||
c.WriteLines(strings.Split(ABOUT_TEXT, "\n"))
|
c.WriteLines(strings.Split(ABOUT_TEXT, "\n"))
|
||||||
|
case "/uptime":
|
||||||
|
c.Write(c.Server.Uptime())
|
||||||
case "/me":
|
case "/me":
|
||||||
me := strings.TrimLeft(line, "/me")
|
me := strings.TrimLeft(line, "/me")
|
||||||
if me == "" {
|
if me == "" {
|
||||||
|
|
|
@ -30,6 +30,7 @@ type Server struct {
|
||||||
admins map[string]struct{} // fingerprint lookup
|
admins map[string]struct{} // fingerprint lookup
|
||||||
bannedPk map[string]*time.Time // fingerprint lookup
|
bannedPk map[string]*time.Time // fingerprint lookup
|
||||||
bannedIp map[net.Addr]*time.Time
|
bannedIp map[net.Addr]*time.Time
|
||||||
|
started time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServer(privateKey []byte) (*Server, error) {
|
func NewServer(privateKey []byte) (*Server, error) {
|
||||||
|
@ -46,6 +47,7 @@ func NewServer(privateKey []byte) (*Server, error) {
|
||||||
admins: map[string]struct{}{},
|
admins: map[string]struct{}{},
|
||||||
bannedPk: map[string]*time.Time{},
|
bannedPk: map[string]*time.Time{},
|
||||||
bannedIp: map[net.Addr]*time.Time{},
|
bannedIp: map[net.Addr]*time.Time{},
|
||||||
|
started: time.Now(),
|
||||||
}
|
}
|
||||||
|
|
||||||
config := ssh.ServerConfig{
|
config := ssh.ServerConfig{
|
||||||
|
@ -182,6 +184,10 @@ func (s *Server) Op(fingerprint string) {
|
||||||
s.lock.Unlock()
|
s.lock.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Server) Uptime() string {
|
||||||
|
return time.Now().Sub(s.started).String()
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Server) IsOp(client *Client) bool {
|
func (s *Server) IsOp(client *Client) bool {
|
||||||
_, r := s.admins[client.Fingerprint()]
|
_, r := s.admins[client.Fingerprint()]
|
||||||
return r
|
return r
|
||||||
|
|
Loading…
Reference in New Issue