mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-26 05:49:25 +01:00
fix #1284
This commit is contained in:
parent
0ca27cfeda
commit
bcdf61bd7a
@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
"github.com/oragono/oragono/irc/languages"
|
"github.com/oragono/oragono/irc/languages"
|
||||||
"github.com/oragono/oragono/irc/modes"
|
"github.com/oragono/oragono/irc/modes"
|
||||||
|
"github.com/oragono/oragono/irc/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (server *Server) Config() (config *Config) {
|
func (server *Server) Config() (config *Config) {
|
||||||
@ -71,6 +72,7 @@ type SessionData struct {
|
|||||||
hostname string
|
hostname string
|
||||||
certfp string
|
certfp string
|
||||||
deviceID string
|
deviceID string
|
||||||
|
connInfo string
|
||||||
sessionID int64
|
sessionID int64
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +93,7 @@ func (client *Client) AllSessionData(currentSession *Session) (data []SessionDat
|
|||||||
certfp: session.certfp,
|
certfp: session.certfp,
|
||||||
deviceID: session.deviceID,
|
deviceID: session.deviceID,
|
||||||
sessionID: session.sessionID,
|
sessionID: session.sessionID,
|
||||||
|
connInfo: utils.DescribeConn(session.socket.conn.UnderlyingConn().Conn),
|
||||||
}
|
}
|
||||||
if session.proxiedIP != nil {
|
if session.proxiedIP != nil {
|
||||||
data[i].ip = session.proxiedIP
|
data[i].ip = session.proxiedIP
|
||||||
|
@ -12,7 +12,6 @@ import (
|
|||||||
|
|
||||||
"github.com/goshuirc/irc-go/ircfmt"
|
"github.com/goshuirc/irc-go/ircfmt"
|
||||||
|
|
||||||
"github.com/oragono/oragono/irc/modes"
|
|
||||||
"github.com/oragono/oragono/irc/passwd"
|
"github.com/oragono/oragono/irc/passwd"
|
||||||
"github.com/oragono/oragono/irc/sno"
|
"github.com/oragono/oragono/irc/sno"
|
||||||
"github.com/oragono/oragono/irc/utils"
|
"github.com/oragono/oragono/irc/utils"
|
||||||
@ -1099,20 +1098,19 @@ func nsClientsHandler(server *Server, client *Client, command string, params []s
|
|||||||
nsClientsLogoutHandler(server, client, params, rb)
|
nsClientsLogoutHandler(server, client, params, rb)
|
||||||
default:
|
default:
|
||||||
nsNotice(rb, client.t("Invalid parameters"))
|
nsNotice(rb, client.t("Invalid parameters"))
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func nsClientsListHandler(server *Server, client *Client, params []string, rb *ResponseBuffer) {
|
func nsClientsListHandler(server *Server, client *Client, params []string, rb *ResponseBuffer) {
|
||||||
target := client
|
target := client
|
||||||
|
hasPrivs := client.HasRoleCapabs("accreg")
|
||||||
if 0 < len(params) {
|
if 0 < len(params) {
|
||||||
target = server.clients.Get(params[0])
|
target = server.clients.Get(params[0])
|
||||||
if target == nil {
|
if target == nil {
|
||||||
nsNotice(rb, client.t("No such nick"))
|
nsNotice(rb, client.t("No such nick"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// same permissions check as RPL_WHOISACTUALLY for now:
|
if target != client && !hasPrivs {
|
||||||
if target != client && !client.HasMode(modes.Operator) {
|
|
||||||
nsNotice(rb, client.t("Command restricted"))
|
nsNotice(rb, client.t("Command restricted"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1131,6 +1129,9 @@ func nsClientsListHandler(server *Server, client *Client, params []string, rb *R
|
|||||||
}
|
}
|
||||||
nsNotice(rb, fmt.Sprintf(client.t("IP address: %s"), session.ip.String()))
|
nsNotice(rb, fmt.Sprintf(client.t("IP address: %s"), session.ip.String()))
|
||||||
nsNotice(rb, fmt.Sprintf(client.t("Hostname: %s"), session.hostname))
|
nsNotice(rb, fmt.Sprintf(client.t("Hostname: %s"), session.hostname))
|
||||||
|
if hasPrivs {
|
||||||
|
nsNotice(rb, fmt.Sprintf(client.t("Connection: %s"), session.connInfo))
|
||||||
|
}
|
||||||
nsNotice(rb, fmt.Sprintf(client.t("Created at: %s"), session.ctime.Format(time.RFC1123)))
|
nsNotice(rb, fmt.Sprintf(client.t("Created at: %s"), session.ctime.Format(time.RFC1123)))
|
||||||
nsNotice(rb, fmt.Sprintf(client.t("Last active: %s"), session.atime.Format(time.RFC1123)))
|
nsNotice(rb, fmt.Sprintf(client.t("Last active: %s"), session.atime.Format(time.RFC1123)))
|
||||||
if session.certfp != "" {
|
if session.certfp != "" {
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
@ -193,3 +194,11 @@ func HandleXForwardedFor(remoteAddr string, xForwardedFor string, whitelist []ne
|
|||||||
// or nil:
|
// or nil:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DescribeConn(conn net.Conn) string {
|
||||||
|
// XXX for unix domain sockets, this is not informative enough for an operator
|
||||||
|
// to determine who holds the other side of the connection. there seems to be
|
||||||
|
// no way to get either the correct file descriptor of the connection, or the
|
||||||
|
// udiag_ino from `man 7 sock_diag`. maybe there's something else we can do?
|
||||||
|
return fmt.Sprintf("%s <-> %s", conn.LocalAddr().String(), conn.RemoteAddr().String())
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user