mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-13 07:37:17 +03:00
now if both are ops it will be reflected in output of whois command
This commit is contained in:
parent
3c4d90cfc1
commit
5f201e0f20
3
host.go
3
host.go
@ -407,12 +407,11 @@ func (h *Host) InitCommands(c *chat.Commands) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("user not found")
|
return errors.New("user not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
id := target.Identifier.(*Identity)
|
id := target.Identifier.(*Identity)
|
||||||
var whois string
|
var whois string
|
||||||
switch room.IsOp(msg.From()) {
|
switch room.IsOp(msg.From()) {
|
||||||
case true:
|
case true:
|
||||||
whois = id.WhoisAdmin()
|
whois = id.WhoisAdmin(room, h)
|
||||||
case false:
|
case false:
|
||||||
whois = id.Whois()
|
whois = id.Whois()
|
||||||
}
|
}
|
||||||
|
11
identity.go
11
identity.go
@ -4,6 +4,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/shazow/ssh-chat/chat"
|
||||||
"github.com/shazow/ssh-chat/chat/message"
|
"github.com/shazow/ssh-chat/chat/message"
|
||||||
"github.com/shazow/ssh-chat/internal/humantime"
|
"github.com/shazow/ssh-chat/internal/humantime"
|
||||||
"github.com/shazow/ssh-chat/internal/sanitize"
|
"github.com/shazow/ssh-chat/internal/sanitize"
|
||||||
@ -59,13 +60,21 @@ func (i Identity) Whois() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WhoisAdmin returns a whois description for admin users.
|
// WhoisAdmin returns a whois description for admin users.
|
||||||
func (i Identity) WhoisAdmin() string {
|
func (i Identity) WhoisAdmin(room *chat.Room, host *Host) string {
|
||||||
ip, _, _ := net.SplitHostPort(i.RemoteAddr().String())
|
ip, _, _ := net.SplitHostPort(i.RemoteAddr().String())
|
||||||
fingerprint := "(no public key)"
|
fingerprint := "(no public key)"
|
||||||
if i.PublicKey() != nil {
|
if i.PublicKey() != nil {
|
||||||
fingerprint = sshd.Fingerprint(i.PublicKey())
|
fingerprint = sshd.Fingerprint(i.PublicKey())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isOp := ""
|
||||||
|
user, ok := host.GetUser(i.id)
|
||||||
|
if ok && room.IsOp(user) {
|
||||||
|
isOp = " > Op" + message.Newline
|
||||||
|
}
|
||||||
|
|
||||||
return "name: " + i.Name() + message.Newline +
|
return "name: " + i.Name() + message.Newline +
|
||||||
|
isOp +
|
||||||
" > ip: " + ip + message.Newline +
|
" > ip: " + ip + message.Newline +
|
||||||
" > fingerprint: " + fingerprint + message.Newline +
|
" > fingerprint: " + fingerprint + message.Newline +
|
||||||
" > client: " + sanitize.Data(string(i.ClientVersion()), 64) + message.Newline +
|
" > client: " + sanitize.Data(string(i.ClientVersion()), 64) + message.Newline +
|
||||||
|
Loading…
x
Reference in New Issue
Block a user