You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

nickserv.go 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. // Copyright (c) 2017 Daniel Oaks <daniel@danieloaks.net>
  2. // released under the MIT license
  3. package irc
  4. import (
  5. "fmt"
  6. "time"
  7. "github.com/goshuirc/irc-go/ircfmt"
  8. "github.com/oragono/oragono/irc/modes"
  9. )
  10. // "enabled" callbacks for specific nickserv commands
  11. func servCmdRequiresAccreg(config *Config) bool {
  12. return config.Accounts.Registration.Enabled
  13. }
  14. func servCmdRequiresAuthEnabled(config *Config) bool {
  15. return config.Accounts.AuthenticationEnabled
  16. }
  17. func servCmdRequiresNickRes(config *Config) bool {
  18. return config.Accounts.AuthenticationEnabled && config.Accounts.NickReservation.Enabled
  19. }
  20. func nsEnforceEnabled(config *Config) bool {
  21. return servCmdRequiresNickRes(config) && config.Accounts.NickReservation.AllowCustomEnforcement
  22. }
  23. func servCmdRequiresBouncerEnabled(config *Config) bool {
  24. return config.Accounts.Bouncer.Enabled
  25. }
  26. var (
  27. // ZNC's nickserv module will not detect this unless it is:
  28. // 1. sent with prefix `nickserv`
  29. // 2. contains the string "identify"
  30. // 3. contains at least one of several other magic strings ("msg" works)
  31. nsTimeoutNotice = `This nickname is reserved. Please login within %v (using $b/msg NickServ IDENTIFY <password>$b or SASL), or switch to a different nickname.`
  32. )
  33. const nickservHelp = `NickServ lets you register and login to an account.
  34. To see in-depth help for a specific NickServ command, try:
  35. $b/NS HELP <command>$b
  36. Here are the commands you can use:
  37. %s`
  38. var (
  39. nickservCommands = map[string]*serviceCommand{
  40. "drop": {
  41. handler: nsDropHandler,
  42. help: `Syntax: $bDROP [nickname]$b
  43. DROP de-links the given (or your current) nickname from your user account.`,
  44. helpShort: `$bDROP$b de-links your current (or the given) nickname from your user account.`,
  45. enabled: servCmdRequiresNickRes,
  46. authRequired: true,
  47. },
  48. "enforce": {
  49. handler: nsEnforceHandler,
  50. help: `Syntax: $bENFORCE [method]$b
  51. ENFORCE lets you specify a custom enforcement mechanism for your registered
  52. nicknames. Your options are:
  53. 1. 'none' [no enforcement, overriding the server default]
  54. 2. 'timeout' [anyone using the nick must authenticate before a deadline,
  55. or else they will be renamed]
  56. 3. 'strict' [you must already be authenticated to use the nick]
  57. 4. 'default' [use the server default]
  58. With no arguments, queries your current enforcement status.`,
  59. helpShort: `$bENFORCE$b lets you change how your nicknames are reserved.`,
  60. authRequired: true,
  61. enabled: nsEnforceEnabled,
  62. },
  63. "ghost": {
  64. handler: nsGhostHandler,
  65. help: `Syntax: $bGHOST <nickname>$b
  66. GHOST disconnects the given user from the network if they're logged in with the
  67. same user account, letting you reclaim your nickname.`,
  68. helpShort: `$bGHOST$b reclaims your nickname.`,
  69. authRequired: true,
  70. minParams: 1,
  71. },
  72. "group": {
  73. handler: nsGroupHandler,
  74. help: `Syntax: $bGROUP$b
  75. GROUP links your current nickname with your logged-in account, so other people
  76. will not be able to use it.`,
  77. helpShort: `$bGROUP$b links your current nickname to your user account.`,
  78. enabled: servCmdRequiresNickRes,
  79. authRequired: true,
  80. },
  81. "identify": {
  82. handler: nsIdentifyHandler,
  83. help: `Syntax: $bIDENTIFY <username> [password]$b
  84. IDENTIFY lets you login to the given username using either password auth, or
  85. certfp (your client certificate) if a password is not given.`,
  86. helpShort: `$bIDENTIFY$b lets you login to your account.`,
  87. minParams: 1,
  88. },
  89. "info": {
  90. handler: nsInfoHandler,
  91. help: `Syntax: $bINFO [username]$b
  92. INFO gives you information about the given (or your own) user account.`,
  93. helpShort: `$bINFO$b gives you information on a user account.`,
  94. },
  95. "register": {
  96. handler: nsRegisterHandler,
  97. // TODO: "email" is an oversimplification here; it's actually any callback, e.g.,
  98. // person@example.com, mailto:person@example.com, tel:16505551234.
  99. help: `Syntax: $bREGISTER <username> <email> [password]$b
  100. REGISTER lets you register a user account. If the server allows anonymous
  101. registration, you can send an asterisk (*) as the email address.
  102. If the password is left out, your account will be registered to your TLS client
  103. certificate (and you will need to use that certificate to login in future).`,
  104. helpShort: `$bREGISTER$b lets you register a user account.`,
  105. enabled: servCmdRequiresAccreg,
  106. minParams: 2,
  107. },
  108. "sadrop": {
  109. handler: nsDropHandler,
  110. help: `Syntax: $bSADROP <nickname>$b
  111. SADROP forcibly de-links the given nickname from the attached user account.`,
  112. helpShort: `$bSADROP$b forcibly de-links the given nickname from its user account.`,
  113. capabs: []string{"accreg"},
  114. enabled: servCmdRequiresNickRes,
  115. minParams: 1,
  116. },
  117. "saregister": {
  118. handler: nsSaregisterHandler,
  119. help: `Syntax: $bSAREGISTER <username> <password>$b
  120. SAREGISTER registers an account on someone else's behalf.
  121. This is for use in configurations that require SASL for all connections;
  122. an administrator can set use this command to set up user accounts.`,
  123. helpShort: `$bSAREGISTER$b registers an account on someone else's behalf.`,
  124. enabled: servCmdRequiresAuthEnabled,
  125. capabs: []string{"accreg"},
  126. minParams: 2,
  127. },
  128. "sessions": {
  129. handler: nsSessionsHandler,
  130. help: `Syntax: $bSESSIONS [nickname]$b
  131. SESSIONS lists information about the sessions currently attached, via
  132. the server's bouncer functionality, to your nickname. An administrator
  133. can use this command to list another user's sessions.`,
  134. helpShort: `$bSESSIONS$b lists the sessions attached to a nickname.`,
  135. enabled: servCmdRequiresBouncerEnabled,
  136. },
  137. "unregister": {
  138. handler: nsUnregisterHandler,
  139. help: `Syntax: $bUNREGISTER <username> [code]$b
  140. UNREGISTER lets you delete your user account (or someone else's, if you're an
  141. IRC operator with the correct permissions). To prevent accidental
  142. unregistrations, a verification code is required; invoking the command without
  143. a code will display the necessary code.`,
  144. helpShort: `$bUNREGISTER$b lets you delete your user account.`,
  145. enabled: servCmdRequiresAuthEnabled,
  146. minParams: 1,
  147. },
  148. "verify": {
  149. handler: nsVerifyHandler,
  150. help: `Syntax: $bVERIFY <username> <code>$b
  151. VERIFY lets you complete an account registration, if the server requires email
  152. or other verification.`,
  153. helpShort: `$bVERIFY$b lets you complete account registration.`,
  154. enabled: servCmdRequiresAccreg,
  155. minParams: 2,
  156. },
  157. "passwd": {
  158. handler: nsPasswdHandler,
  159. help: `Syntax: $bPASSWD <current> <new> <new_again>$b
  160. Or: $bPASSWD <username> <new>$b
  161. PASSWD lets you change your account password. You must supply your current
  162. password and confirm the new one by typing it twice. If you're an IRC operator
  163. with the correct permissions, you can use PASSWD to reset someone else's
  164. password by supplying their username and then the desired password.`,
  165. helpShort: `$bPASSWD$b lets you change your password.`,
  166. enabled: servCmdRequiresAuthEnabled,
  167. minParams: 2,
  168. },
  169. }
  170. )
  171. // nsNotice sends the client a notice from NickServ
  172. func nsNotice(rb *ResponseBuffer, text string) {
  173. rb.Add(nil, "NickServ", "NOTICE", rb.target.Nick(), text)
  174. }
  175. func nsDropHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  176. sadrop := command == "sadrop"
  177. var nick string
  178. if len(params) > 0 {
  179. nick = params[0]
  180. } else {
  181. nick = client.NickCasefolded()
  182. }
  183. err := server.accounts.SetNickReserved(client, nick, sadrop, false)
  184. if err == nil {
  185. nsNotice(rb, fmt.Sprintf(client.t("Successfully ungrouped nick %s with your account"), nick))
  186. } else if err == errAccountNotLoggedIn {
  187. nsNotice(rb, client.t("You're not logged into an account"))
  188. } else if err == errAccountCantDropPrimaryNick {
  189. nsNotice(rb, client.t("You can't ungroup your primary nickname (try unregistering your account instead)"))
  190. } else {
  191. nsNotice(rb, client.t("Could not ungroup nick"))
  192. }
  193. }
  194. func nsGhostHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  195. nick := params[0]
  196. ghost := server.clients.Get(nick)
  197. if ghost == nil {
  198. nsNotice(rb, client.t("No such nick"))
  199. return
  200. } else if ghost == client {
  201. nsNotice(rb, client.t("You can't GHOST yourself (try /QUIT instead)"))
  202. return
  203. }
  204. authorized := false
  205. account := client.Account()
  206. if account != "" {
  207. // the user must either own the nick, or the target client
  208. authorized = (server.accounts.NickToAccount(nick) == account) || (ghost.Account() == account)
  209. }
  210. if !authorized {
  211. nsNotice(rb, client.t("You don't own that nick"))
  212. return
  213. }
  214. ghost.Quit(fmt.Sprintf(ghost.t("GHOSTed by %s"), client.Nick()), nil)
  215. ghost.destroy(false, nil)
  216. }
  217. func nsGroupHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  218. nick := client.Nick()
  219. err := server.accounts.SetNickReserved(client, nick, false, true)
  220. if err == nil {
  221. nsNotice(rb, fmt.Sprintf(client.t("Successfully grouped nick %s with your account"), nick))
  222. } else if err == errAccountTooManyNicks {
  223. nsNotice(rb, client.t("You have too many nicks reserved already (you can remove some with /NS DROP)"))
  224. } else if err == errNicknameReserved {
  225. nsNotice(rb, client.t("That nickname is already reserved by someone else"))
  226. } else {
  227. nsNotice(rb, client.t("Error reserving nickname"))
  228. }
  229. }
  230. func nsLoginThrottleCheck(client *Client, rb *ResponseBuffer) (success bool) {
  231. throttled, remainingTime := client.loginThrottle.Touch()
  232. if throttled {
  233. nsNotice(rb, fmt.Sprintf(client.t("Please wait at least %v and try again"), remainingTime))
  234. return false
  235. }
  236. return true
  237. }
  238. func nsIdentifyHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  239. if client.LoggedIntoAccount() {
  240. nsNotice(rb, client.t("You're already logged into an account"))
  241. return
  242. }
  243. loginSuccessful := false
  244. var username, passphrase string
  245. if len(params) == 1 {
  246. if client.certfp != "" {
  247. username = params[0]
  248. } else {
  249. // XXX undocumented compatibility mode with other nickservs, allowing
  250. // /msg NickServ identify passphrase
  251. username = client.NickCasefolded()
  252. passphrase = params[0]
  253. }
  254. } else {
  255. username = params[0]
  256. passphrase = params[1]
  257. }
  258. // try passphrase
  259. if passphrase != "" {
  260. if !nsLoginThrottleCheck(client, rb) {
  261. return
  262. }
  263. err := server.accounts.AuthenticateByPassphrase(client, username, passphrase)
  264. loginSuccessful = (err == nil)
  265. }
  266. // try certfp
  267. if !loginSuccessful && client.certfp != "" {
  268. err := server.accounts.AuthenticateByCertFP(client)
  269. loginSuccessful = (err == nil)
  270. }
  271. if loginSuccessful {
  272. sendSuccessfulAccountAuth(client, rb, true, true)
  273. } else {
  274. nsNotice(rb, client.t("Could not login with your TLS certificate or supplied username/password"))
  275. }
  276. }
  277. func nsInfoHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  278. var accountName string
  279. if len(params) > 0 {
  280. nick := params[0]
  281. if server.AccountConfig().NickReservation.Enabled {
  282. accountName = server.accounts.NickToAccount(nick)
  283. if accountName == "" {
  284. nsNotice(rb, client.t("That nickname is not registered"))
  285. return
  286. }
  287. } else {
  288. accountName = nick
  289. }
  290. } else {
  291. accountName = client.Account()
  292. if accountName == "" {
  293. nsNotice(rb, client.t("You're not logged into an account"))
  294. return
  295. }
  296. }
  297. account, err := server.accounts.LoadAccount(accountName)
  298. if err != nil || !account.Verified {
  299. nsNotice(rb, client.t("Account does not exist"))
  300. return
  301. }
  302. nsNotice(rb, fmt.Sprintf(client.t("Account: %s"), account.Name))
  303. registeredAt := account.RegisteredAt.Format("Jan 02, 2006 15:04:05Z")
  304. nsNotice(rb, fmt.Sprintf(client.t("Registered at: %s"), registeredAt))
  305. // TODO nicer formatting for this
  306. for _, nick := range account.AdditionalNicks {
  307. nsNotice(rb, fmt.Sprintf(client.t("Additional grouped nick: %s"), nick))
  308. }
  309. for _, channel := range server.accounts.ChannelsForAccount(accountName) {
  310. nsNotice(rb, fmt.Sprintf(client.t("Registered channel: %s"), channel))
  311. }
  312. }
  313. func nsRegisterHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  314. // get params
  315. account, email := params[0], params[1]
  316. var passphrase string
  317. if len(params) > 2 {
  318. passphrase = params[2]
  319. }
  320. certfp := client.certfp
  321. if passphrase == "" && certfp == "" {
  322. nsNotice(rb, client.t("You need to either supply a passphrase or be connected via TLS with a client cert"))
  323. return
  324. }
  325. if client.LoggedIntoAccount() {
  326. nsNotice(rb, client.t("You're already logged into an account"))
  327. return
  328. }
  329. if !nsLoginThrottleCheck(client, rb) {
  330. return
  331. }
  332. // band-aid to let users know if they mix up the order of registration params
  333. if email == "*" {
  334. nsNotice(rb, client.t("Registering your account with no email address"))
  335. } else {
  336. nsNotice(rb, fmt.Sprintf(client.t("Registering your account with email address %s"), email))
  337. }
  338. config := server.AccountConfig()
  339. var callbackNamespace, callbackValue string
  340. noneCallbackAllowed := false
  341. for _, callback := range config.Registration.EnabledCallbacks {
  342. if callback == "*" {
  343. noneCallbackAllowed = true
  344. }
  345. }
  346. // XXX if ACC REGISTER allows registration with the `none` callback, then ignore
  347. // any callback that was passed here (to avoid confusion in the case where the ircd
  348. // has no mail server configured). otherwise, register using the provided callback:
  349. if noneCallbackAllowed {
  350. callbackNamespace = "*"
  351. } else {
  352. callbackNamespace, callbackValue = parseCallback(email, config)
  353. if callbackNamespace == "" {
  354. nsNotice(rb, client.t("Registration requires a valid e-mail address"))
  355. return
  356. }
  357. }
  358. err := server.accounts.Register(client, account, callbackNamespace, callbackValue, passphrase, client.certfp)
  359. if err == nil {
  360. if callbackNamespace == "*" {
  361. err = server.accounts.Verify(client, account, "")
  362. if err == nil {
  363. sendSuccessfulRegResponse(client, rb, true)
  364. }
  365. } else {
  366. messageTemplate := client.t("Account created, pending verification; verification code has been sent to %s")
  367. message := fmt.Sprintf(messageTemplate, fmt.Sprintf("%s:%s", callbackNamespace, callbackValue))
  368. nsNotice(rb, message)
  369. }
  370. }
  371. // details could not be stored and relevant numerics have been dispatched, abort
  372. message, _ := registrationErrorToMessageAndCode(err)
  373. if err != nil {
  374. nsNotice(rb, client.t(message))
  375. return
  376. }
  377. }
  378. func nsSaregisterHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  379. account, passphrase := params[0], params[1]
  380. err := server.accounts.Register(nil, account, "admin", "", passphrase, "")
  381. if err == nil {
  382. err = server.accounts.Verify(nil, account, "")
  383. }
  384. if err != nil {
  385. var errMsg string
  386. if err == errAccountAlreadyRegistered || err == errAccountAlreadyVerified {
  387. errMsg = client.t("Account already exists")
  388. } else if err == errAccountBadPassphrase {
  389. errMsg = client.t("Passphrase contains forbidden characters or is otherwise invalid")
  390. } else {
  391. server.logger.Error("services", "unknown error from saregister", err.Error())
  392. errMsg = client.t("Could not register")
  393. }
  394. nsNotice(rb, errMsg)
  395. } else {
  396. nsNotice(rb, fmt.Sprintf(client.t("Successfully registered account %s"), account))
  397. }
  398. }
  399. func nsUnregisterHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  400. username := params[0]
  401. var verificationCode string
  402. if len(params) > 1 {
  403. verificationCode = params[1]
  404. }
  405. if username == "" {
  406. nsNotice(rb, client.t("You must specify an account"))
  407. return
  408. }
  409. account, err := server.accounts.LoadAccount(username)
  410. if err == errAccountDoesNotExist {
  411. nsNotice(rb, client.t("Invalid account name"))
  412. return
  413. } else if err != nil {
  414. nsNotice(rb, client.t("Internal error"))
  415. return
  416. }
  417. cfname, _ := CasefoldName(username)
  418. if !(cfname == client.Account() || client.HasRoleCapabs("accreg")) {
  419. nsNotice(rb, client.t("Insufficient oper privs"))
  420. return
  421. }
  422. expectedCode := unregisterConfirmationCode(account.Name, account.RegisteredAt)
  423. if expectedCode != verificationCode {
  424. nsNotice(rb, ircfmt.Unescape(client.t("$bWarning: unregistering this account will remove its stored privileges.$b")))
  425. nsNotice(rb, fmt.Sprintf(client.t("To confirm account unregistration, type: /NS UNREGISTER %[1]s %[2]s"), cfname, expectedCode))
  426. return
  427. }
  428. err = server.accounts.Unregister(cfname)
  429. if err == errAccountDoesNotExist {
  430. nsNotice(rb, client.t(err.Error()))
  431. } else if err != nil {
  432. nsNotice(rb, client.t("Error while unregistering account"))
  433. } else {
  434. nsNotice(rb, fmt.Sprintf(client.t("Successfully unregistered account %s"), cfname))
  435. server.logger.Info("accounts", "client", client.Nick(), "unregistered account", cfname)
  436. }
  437. }
  438. func nsVerifyHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  439. username, code := params[0], params[1]
  440. err := server.accounts.Verify(client, username, code)
  441. var errorMessage string
  442. if err == errAccountVerificationInvalidCode || err == errAccountAlreadyVerified {
  443. errorMessage = err.Error()
  444. } else if err != nil {
  445. errorMessage = errAccountVerificationFailed.Error()
  446. }
  447. if errorMessage != "" {
  448. nsNotice(rb, client.t(errorMessage))
  449. return
  450. }
  451. sendSuccessfulRegResponse(client, rb, true)
  452. }
  453. func nsPasswdHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  454. var target string
  455. var newPassword string
  456. var errorMessage string
  457. hasPrivs := client.HasRoleCapabs("accreg")
  458. if !hasPrivs && !nsLoginThrottleCheck(client, rb) {
  459. return
  460. }
  461. switch len(params) {
  462. case 2:
  463. if !hasPrivs {
  464. errorMessage = "Insufficient privileges"
  465. } else {
  466. target, newPassword = params[0], params[1]
  467. }
  468. case 3:
  469. target = client.Account()
  470. if target == "" {
  471. errorMessage = "You're not logged into an account"
  472. } else if params[1] != params[2] {
  473. errorMessage = "Passwords do not match"
  474. } else {
  475. // check that they correctly supplied the preexisting password
  476. _, err := server.accounts.checkPassphrase(target, params[0])
  477. if err != nil {
  478. errorMessage = "Password incorrect"
  479. } else {
  480. newPassword = params[1]
  481. }
  482. }
  483. default:
  484. errorMessage = "Invalid parameters"
  485. }
  486. if errorMessage != "" {
  487. nsNotice(rb, client.t(errorMessage))
  488. return
  489. }
  490. err := server.accounts.setPassword(target, newPassword)
  491. if err == nil {
  492. nsNotice(rb, client.t("Password changed"))
  493. } else {
  494. server.logger.Error("internal", "could not upgrade user password:", err.Error())
  495. nsNotice(rb, client.t("Password could not be changed due to server error"))
  496. }
  497. }
  498. func nsEnforceHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  499. if len(params) == 0 {
  500. status := server.accounts.getStoredEnforcementStatus(client.Account())
  501. nsNotice(rb, fmt.Sprintf(client.t("Your current nickname enforcement is: %s"), status))
  502. } else {
  503. method, err := nickReservationFromString(params[0])
  504. if err != nil {
  505. nsNotice(rb, client.t("Invalid parameters"))
  506. return
  507. }
  508. err = server.accounts.SetEnforcementStatus(client.Account(), method)
  509. if err == nil {
  510. nsNotice(rb, client.t("Enforcement method set"))
  511. } else {
  512. server.logger.Error("internal", "couldn't store NS ENFORCE data", err.Error())
  513. nsNotice(rb, client.t("An error occurred"))
  514. }
  515. }
  516. }
  517. func nsSessionsHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
  518. target := client
  519. if 0 < len(params) {
  520. // same permissions check as RPL_WHOISACTUALLY for now:
  521. if !client.HasMode(modes.Operator) {
  522. nsNotice(rb, client.t("Command restricted"))
  523. return
  524. }
  525. target = server.clients.Get(params[0])
  526. if target == nil {
  527. nsNotice(rb, client.t("No such nick"))
  528. return
  529. }
  530. }
  531. sessionData, currentIndex := target.AllSessionData(rb.session)
  532. nsNotice(rb, fmt.Sprintf(client.t("Nickname %[1]s has %[2]d attached session(s)"), target.Nick(), len(sessionData)))
  533. for i, session := range sessionData {
  534. if currentIndex == i {
  535. nsNotice(rb, fmt.Sprintf(client.t("Session %d (currently attached session):"), i+1))
  536. } else {
  537. nsNotice(rb, fmt.Sprintf(client.t("Session %d:"), i+1))
  538. }
  539. nsNotice(rb, fmt.Sprintf(client.t("IP address: %s"), session.ip.String()))
  540. nsNotice(rb, fmt.Sprintf(client.t("Hostname: %s"), session.hostname))
  541. nsNotice(rb, fmt.Sprintf(client.t("Created at: %s"), session.ctime.Format(time.RFC1123)))
  542. nsNotice(rb, fmt.Sprintf(client.t("Last active: %s"), session.atime.Format(time.RFC1123)))
  543. }
  544. }