Shivaram Lingamneni 3 лет назад
Родитель
Сommit
bcdf61bd7a
3 измененных файлов: 17 добавлений и 4 удалений
  1. 3
    0
      irc/getters.go
  2. 5
    4
      irc/nickserv.go
  3. 9
    0
      irc/utils/net.go

+ 3
- 0
irc/getters.go Просмотреть файл

@@ -11,6 +11,7 @@ import (
11 11
 
12 12
 	"github.com/oragono/oragono/irc/languages"
13 13
 	"github.com/oragono/oragono/irc/modes"
14
+	"github.com/oragono/oragono/irc/utils"
14 15
 )
15 16
 
16 17
 func (server *Server) Config() (config *Config) {
@@ -71,6 +72,7 @@ type SessionData struct {
71 72
 	hostname  string
72 73
 	certfp    string
73 74
 	deviceID  string
75
+	connInfo  string
74 76
 	sessionID int64
75 77
 }
76 78
 
@@ -91,6 +93,7 @@ func (client *Client) AllSessionData(currentSession *Session) (data []SessionDat
91 93
 			certfp:    session.certfp,
92 94
 			deviceID:  session.deviceID,
93 95
 			sessionID: session.sessionID,
96
+			connInfo:  utils.DescribeConn(session.socket.conn.UnderlyingConn().Conn),
94 97
 		}
95 98
 		if session.proxiedIP != nil {
96 99
 			data[i].ip = session.proxiedIP

+ 5
- 4
irc/nickserv.go Просмотреть файл

@@ -12,7 +12,6 @@ import (
12 12
 
13 13
 	"github.com/goshuirc/irc-go/ircfmt"
14 14
 
15
-	"github.com/oragono/oragono/irc/modes"
16 15
 	"github.com/oragono/oragono/irc/passwd"
17 16
 	"github.com/oragono/oragono/irc/sno"
18 17
 	"github.com/oragono/oragono/irc/utils"
@@ -1099,20 +1098,19 @@ func nsClientsHandler(server *Server, client *Client, command string, params []s
1099 1098
 		nsClientsLogoutHandler(server, client, params, rb)
1100 1099
 	default:
1101 1100
 		nsNotice(rb, client.t("Invalid parameters"))
1102
-		return
1103 1101
 	}
1104 1102
 }
1105 1103
 
1106 1104
 func nsClientsListHandler(server *Server, client *Client, params []string, rb *ResponseBuffer) {
1107 1105
 	target := client
1106
+	hasPrivs := client.HasRoleCapabs("accreg")
1108 1107
 	if 0 < len(params) {
1109 1108
 		target = server.clients.Get(params[0])
1110 1109
 		if target == nil {
1111 1110
 			nsNotice(rb, client.t("No such nick"))
1112 1111
 			return
1113 1112
 		}
1114
-		// same permissions check as RPL_WHOISACTUALLY for now:
1115
-		if target != client && !client.HasMode(modes.Operator) {
1113
+		if target != client && !hasPrivs {
1116 1114
 			nsNotice(rb, client.t("Command restricted"))
1117 1115
 			return
1118 1116
 		}
@@ -1131,6 +1129,9 @@ func nsClientsListHandler(server *Server, client *Client, params []string, rb *R
1131 1129
 		}
1132 1130
 		nsNotice(rb, fmt.Sprintf(client.t("IP address:  %s"), session.ip.String()))
1133 1131
 		nsNotice(rb, fmt.Sprintf(client.t("Hostname:    %s"), session.hostname))
1132
+		if hasPrivs {
1133
+			nsNotice(rb, fmt.Sprintf(client.t("Connection:  %s"), session.connInfo))
1134
+		}
1134 1135
 		nsNotice(rb, fmt.Sprintf(client.t("Created at:  %s"), session.ctime.Format(time.RFC1123)))
1135 1136
 		nsNotice(rb, fmt.Sprintf(client.t("Last active: %s"), session.atime.Format(time.RFC1123)))
1136 1137
 		if session.certfp != "" {

+ 9
- 0
irc/utils/net.go Просмотреть файл

@@ -5,6 +5,7 @@
5 5
 package utils
6 6
 
7 7
 import (
8
+	"fmt"
8 9
 	"net"
9 10
 	"regexp"
10 11
 	"strings"
@@ -193,3 +194,11 @@ func HandleXForwardedFor(remoteAddr string, xForwardedFor string, whitelist []ne
193 194
 	// or nil:
194 195
 	return
195 196
 }
197
+
198
+func DescribeConn(conn net.Conn) string {
199
+	// XXX for unix domain sockets, this is not informative enough for an operator
200
+	// to determine who holds the other side of the connection. there seems to be
201
+	// no way to get either the correct file descriptor of the connection, or the
202
+	// udiag_ino from `man 7 sock_diag`. maybe there's something else we can do?
203
+	return fmt.Sprintf("%s <-> %s", conn.LocalAddr().String(), conn.RemoteAddr().String())
204
+}

Загрузка…
Отмена
Сохранить