選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

server.go 40KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118
  1. // Copyright (c) 2012-2014 Jeremy Latt
  2. // Copyright (c) 2014-2015 Edmund Huber
  3. // Copyright (c) 2016-2017 Daniel Oaks <daniel@danieloaks.net>
  4. // released under the MIT license
  5. package irc
  6. import (
  7. "fmt"
  8. "net"
  9. "net/http"
  10. _ "net/http/pprof"
  11. "os"
  12. "os/signal"
  13. "strconv"
  14. "strings"
  15. "sync"
  16. "syscall"
  17. "time"
  18. "unsafe"
  19. "github.com/ergochat/irc-go/ircfmt"
  20. "github.com/okzk/sdnotify"
  21. "github.com/ergochat/ergo/irc/caps"
  22. "github.com/ergochat/ergo/irc/connection_limits"
  23. "github.com/ergochat/ergo/irc/flatip"
  24. "github.com/ergochat/ergo/irc/flock"
  25. "github.com/ergochat/ergo/irc/history"
  26. "github.com/ergochat/ergo/irc/logger"
  27. "github.com/ergochat/ergo/irc/modes"
  28. "github.com/ergochat/ergo/irc/mysql"
  29. "github.com/ergochat/ergo/irc/sno"
  30. "github.com/ergochat/ergo/irc/utils"
  31. "github.com/tidwall/buntdb"
  32. )
  33. const (
  34. alwaysOnMaintenanceInterval = 30 * time.Minute
  35. )
  36. var (
  37. // common error line to sub values into
  38. errorMsg = "ERROR :%s\r\n"
  39. // three final parameters of 004 RPL_MYINFO, enumerating our supported modes
  40. rplMyInfo1, rplMyInfo2, rplMyInfo3 = modes.RplMyInfo()
  41. // CHANMODES isupport token
  42. chanmodesToken = modes.ChanmodesToken()
  43. // whitelist of caps to serve on the STS-only listener. In particular,
  44. // never advertise SASL, to discourage people from sending their passwords:
  45. stsOnlyCaps = caps.NewSet(caps.STS, caps.MessageTags, caps.ServerTime, caps.Batch, caps.LabeledResponse, caps.EchoMessage, caps.Nope)
  46. // we only have standard channels for now. TODO: any updates to this
  47. // will also need to be reflected in CasefoldChannel
  48. chanTypes = "#"
  49. throttleMessage = "You have attempted to connect too many times within a short duration. Wait a while, and you will be able to connect."
  50. )
  51. // Server is the main Oragono server.
  52. type Server struct {
  53. accounts AccountManager
  54. channels ChannelManager
  55. channelRegistry ChannelRegistry
  56. clients ClientManager
  57. config unsafe.Pointer
  58. configFilename string
  59. connectionLimiter connection_limits.Limiter
  60. ctime time.Time
  61. dlines *DLineManager
  62. helpIndexManager HelpIndexManager
  63. klines *KLineManager
  64. listeners map[string]IRCListener
  65. logger *logger.Manager
  66. monitorManager MonitorManager
  67. name string
  68. nameCasefolded string
  69. rehashMutex sync.Mutex // tier 4
  70. rehashSignal chan os.Signal
  71. pprofServer *http.Server
  72. exitSignals chan os.Signal
  73. snomasks SnoManager
  74. store *buntdb.DB
  75. historyDB mysql.MySQL
  76. torLimiter connection_limits.TorLimiter
  77. whoWas WhoWasList
  78. stats Stats
  79. semaphores ServerSemaphores
  80. flock flock.Flocker
  81. defcon uint32
  82. }
  83. // NewServer returns a new Oragono server.
  84. func NewServer(config *Config, logger *logger.Manager) (*Server, error) {
  85. // initialize data structures
  86. server := &Server{
  87. ctime: time.Now().UTC(),
  88. listeners: make(map[string]IRCListener),
  89. logger: logger,
  90. rehashSignal: make(chan os.Signal, 1),
  91. exitSignals: make(chan os.Signal, len(utils.ServerExitSignals)),
  92. defcon: 5,
  93. }
  94. server.clients.Initialize()
  95. server.semaphores.Initialize()
  96. server.whoWas.Initialize(config.Limits.WhowasEntries)
  97. server.monitorManager.Initialize()
  98. server.snomasks.Initialize()
  99. if err := server.applyConfig(config); err != nil {
  100. return nil, err
  101. }
  102. // Attempt to clean up when receiving these signals.
  103. signal.Notify(server.exitSignals, utils.ServerExitSignals...)
  104. signal.Notify(server.rehashSignal, syscall.SIGHUP)
  105. time.AfterFunc(alwaysOnMaintenanceInterval, server.periodicAlwaysOnMaintenance)
  106. return server, nil
  107. }
  108. // Shutdown shuts down the server.
  109. func (server *Server) Shutdown() {
  110. sdnotify.Stopping()
  111. server.logger.Info("server", "Stopping server")
  112. //TODO(dan): Make sure we disallow new nicks
  113. for _, client := range server.clients.AllClients() {
  114. client.Notice("Server is shutting down")
  115. }
  116. // flush data associated with always-on clients:
  117. server.performAlwaysOnMaintenance(false, true)
  118. if err := server.store.Close(); err != nil {
  119. server.logger.Error("shutdown", fmt.Sprintln("Could not close datastore:", err))
  120. }
  121. server.historyDB.Close()
  122. server.logger.Info("server", fmt.Sprintf("%s exiting", Ver))
  123. }
  124. // Run starts the server.
  125. func (server *Server) Run() {
  126. defer server.Shutdown()
  127. for {
  128. select {
  129. case <-server.exitSignals:
  130. return
  131. case <-server.rehashSignal:
  132. server.logger.Info("server", "Rehashing due to SIGHUP")
  133. go server.rehash()
  134. }
  135. }
  136. }
  137. func (server *Server) checkBans(config *Config, ipaddr net.IP, checkScripts bool) (banned bool, requireSASL bool, message string) {
  138. // #671: do not enforce bans against loopback, as a failsafe
  139. // note that this function is not used for Tor connections (checkTorLimits is used instead)
  140. if ipaddr.IsLoopback() {
  141. return
  142. }
  143. if server.Defcon() == 1 {
  144. if !utils.IPInNets(ipaddr, server.Config().Server.secureNets) {
  145. return true, false, "New connections to this server are temporarily restricted"
  146. }
  147. }
  148. flat := flatip.FromNetIP(ipaddr)
  149. // check DLINEs
  150. isBanned, info := server.dlines.CheckIP(flat)
  151. if isBanned {
  152. if info.RequireSASL {
  153. server.logger.Info("connect-ip", "Requiring SASL from client due to d-line", ipaddr.String())
  154. return false, true, info.BanMessage("You must authenticate with SASL to connect from this IP (%s)")
  155. } else {
  156. server.logger.Info("connect-ip", "Client rejected by d-line", ipaddr.String())
  157. return true, false, info.BanMessage("You are banned from this server (%s)")
  158. }
  159. }
  160. // check connection limits
  161. err := server.connectionLimiter.AddClient(flat)
  162. if err == connection_limits.ErrLimitExceeded {
  163. // too many connections from one client, tell the client and close the connection
  164. server.logger.Info("connect-ip", "Client rejected for connection limit", ipaddr.String())
  165. return true, false, "Too many clients from your network"
  166. } else if err == connection_limits.ErrThrottleExceeded {
  167. server.logger.Info("connect-ip", "Client exceeded connection throttle", ipaddr.String())
  168. return true, false, throttleMessage
  169. } else if err != nil {
  170. server.logger.Warning("internal", "unexpected ban result", err.Error())
  171. }
  172. if checkScripts && config.Server.IPCheckScript.Enabled && !config.Server.IPCheckScript.ExemptSASL {
  173. output, err := CheckIPBan(server.semaphores.IPCheckScript, config.Server.IPCheckScript, ipaddr)
  174. if err != nil {
  175. server.logger.Error("internal", "couldn't check IP ban script", ipaddr.String(), err.Error())
  176. return false, false, ""
  177. }
  178. // TODO: currently no way to cache IPAccepted
  179. if (output.Result == IPBanned || output.Result == IPRequireSASL) && output.CacheSeconds != 0 {
  180. network, err := flatip.ParseToNormalizedNet(output.CacheNet)
  181. if err != nil {
  182. server.logger.Error("internal", "invalid dline net from IP ban script", ipaddr.String(), output.CacheNet)
  183. } else {
  184. dlineDuration := time.Duration(output.CacheSeconds) * time.Second
  185. err := server.dlines.AddNetwork(network, dlineDuration, output.Result == IPRequireSASL, output.BanMessage, "", "")
  186. if err != nil {
  187. server.logger.Error("internal", "couldn't set dline from IP ban script", ipaddr.String(), err.Error())
  188. }
  189. }
  190. }
  191. if output.Result == IPBanned {
  192. // XXX roll back IP connection/throttling addition for the IP
  193. server.connectionLimiter.RemoveClient(flat)
  194. server.logger.Info("connect-ip", "Rejected client due to ip-check-script", ipaddr.String())
  195. return true, false, output.BanMessage
  196. } else if output.Result == IPRequireSASL {
  197. server.logger.Info("connect-ip", "Requiring SASL from client due to ip-check-script", ipaddr.String())
  198. return false, true, output.BanMessage
  199. }
  200. }
  201. return false, false, ""
  202. }
  203. func (server *Server) checkTorLimits() (banned bool, message string) {
  204. switch server.torLimiter.AddClient() {
  205. case connection_limits.ErrLimitExceeded:
  206. return true, "Too many clients from the Tor network"
  207. case connection_limits.ErrThrottleExceeded:
  208. return true, "Exceeded connection throttle for the Tor network"
  209. default:
  210. return false, ""
  211. }
  212. }
  213. func (server *Server) periodicAlwaysOnMaintenance() {
  214. defer func() {
  215. // reschedule whether or not there was a panic
  216. time.AfterFunc(alwaysOnMaintenanceInterval, server.periodicAlwaysOnMaintenance)
  217. }()
  218. defer server.HandlePanic()
  219. server.logger.Info("accounts", "Performing periodic always-on client checks")
  220. server.performAlwaysOnMaintenance(true, true)
  221. }
  222. func (server *Server) performAlwaysOnMaintenance(checkExpiration, flushTimestamps bool) {
  223. config := server.Config()
  224. for _, client := range server.clients.AllClients() {
  225. if checkExpiration && client.IsExpiredAlwaysOn(config) {
  226. // TODO save the channels list, use it for autojoin if/when they return?
  227. server.logger.Info("accounts", "Expiring always-on client", client.AccountName())
  228. client.destroy(nil)
  229. continue
  230. }
  231. if flushTimestamps && client.shouldFlushTimestamps() {
  232. account := client.Account()
  233. server.accounts.saveLastSeen(account, client.copyLastSeen())
  234. server.accounts.saveReadMarkers(account, client.copyReadMarkers())
  235. }
  236. }
  237. }
  238. // handles server.ip-check-script.exempt-sasl:
  239. // run the ip check script at the end of the handshake, only for anonymous connections
  240. func (server *Server) checkBanScriptExemptSASL(config *Config, session *Session) (outcome AuthOutcome) {
  241. // TODO add caching for this; see related code in (*server).checkBans;
  242. // we should probably just put an LRU around this instead of using the DLINE system
  243. ipaddr := session.IP()
  244. output, err := CheckIPBan(server.semaphores.IPCheckScript, config.Server.IPCheckScript, ipaddr)
  245. if err != nil {
  246. server.logger.Error("internal", "couldn't check IP ban script", ipaddr.String(), err.Error())
  247. return authSuccess
  248. }
  249. if output.Result == IPBanned || output.Result == IPRequireSASL {
  250. server.logger.Info("connect-ip", "Rejecting unauthenticated client due to ip-check-script", ipaddr.String())
  251. if output.BanMessage != "" {
  252. session.client.requireSASLMessage = output.BanMessage
  253. }
  254. return authFailSaslRequired
  255. }
  256. return authSuccess
  257. }
  258. func (server *Server) tryRegister(c *Client, session *Session) (exiting bool) {
  259. // XXX PROXY or WEBIRC MUST be sent as the first line of the session;
  260. // if we are here at all that means we have the final value of the IP
  261. if session.rawHostname == "" {
  262. session.client.lookupHostname(session, false)
  263. }
  264. // try to complete registration normally
  265. // XXX(#1057) username can be filled in by an ident query without the client
  266. // having sent USER: check for both username and realname to ensure they did
  267. if c.preregNick == "" || c.username == "" || c.realname == "" || session.capState == caps.NegotiatingState {
  268. return
  269. }
  270. if c.isSTSOnly {
  271. server.playSTSBurst(session)
  272. return true
  273. }
  274. // client MUST send PASS if necessary, or authenticate with SASL if necessary,
  275. // before completing the other registration commands
  276. config := server.Config()
  277. authOutcome := c.isAuthorized(server, config, session, c.requireSASL)
  278. if authOutcome == authSuccess && c.account == "" &&
  279. config.Server.IPCheckScript.Enabled && config.Server.IPCheckScript.ExemptSASL {
  280. authOutcome = server.checkBanScriptExemptSASL(config, session)
  281. }
  282. var quitMessage string
  283. switch authOutcome {
  284. case authFailPass:
  285. quitMessage = c.t("Password incorrect")
  286. c.Send(nil, server.name, ERR_PASSWDMISMATCH, "*", quitMessage)
  287. case authFailSaslRequired, authFailTorSaslRequired:
  288. quitMessage = c.requireSASLMessage
  289. if quitMessage == "" {
  290. quitMessage = c.t("You must log in with SASL to join this server")
  291. }
  292. c.Send(nil, c.server.name, "FAIL", "*", "ACCOUNT_REQUIRED", quitMessage)
  293. }
  294. if authOutcome != authSuccess {
  295. c.Quit(quitMessage, nil)
  296. return true
  297. }
  298. c.requireSASLMessage = ""
  299. rb := NewResponseBuffer(session)
  300. nickError := performNickChange(server, c, c, session, c.preregNick, rb)
  301. rb.Send(true)
  302. if nickError == errInsecureReattach {
  303. c.Quit(c.t("You can't mix secure and insecure connections to this account"), nil)
  304. return true
  305. } else if nickError != nil {
  306. c.preregNick = ""
  307. return false
  308. }
  309. if session.client != c {
  310. // reattached, bail out.
  311. // we'll play the reg burst later, on the new goroutine associated with
  312. // (thisSession, otherClient). This is to avoid having to transfer state
  313. // like nickname, hostname, etc. to show the correct values in the reg burst.
  314. return false
  315. }
  316. // Apply default user modes (without updating the invisible counter)
  317. // The number of invisible users will be updated by server.stats.Register
  318. // if we're using default user mode +i.
  319. for _, defaultMode := range config.Accounts.defaultUserModes {
  320. c.SetMode(defaultMode, true)
  321. }
  322. // count new user in statistics (before checking KLINEs, see #1303)
  323. server.stats.Register(c.HasMode(modes.Invisible))
  324. // check KLINEs (#671: ignore KLINEs for loopback connections)
  325. if !session.IP().IsLoopback() || session.isTor {
  326. isBanned, info := server.klines.CheckMasks(c.AllNickmasks()...)
  327. if isBanned {
  328. c.Quit(info.BanMessage(c.t("You are banned from this server (%s)")), nil)
  329. return true
  330. }
  331. }
  332. server.playRegistrationBurst(session)
  333. return false
  334. }
  335. func (server *Server) playSTSBurst(session *Session) {
  336. nick := utils.SafeErrorParam(session.client.preregNick)
  337. session.Send(nil, server.name, RPL_WELCOME, nick, fmt.Sprintf("Welcome to the Internet Relay Network %s", nick))
  338. session.Send(nil, server.name, RPL_YOURHOST, nick, fmt.Sprintf("Your host is %[1]s, running version %[2]s", server.name, "ergo"))
  339. session.Send(nil, server.name, RPL_CREATED, nick, fmt.Sprintf("This server was created %s", time.Time{}.Format(time.RFC1123)))
  340. session.Send(nil, server.name, RPL_MYINFO, nick, server.name, "ergo", "o", "o", "o")
  341. session.Send(nil, server.name, RPL_ISUPPORT, nick, "CASEMAPPING=ascii", "are supported by this server")
  342. session.Send(nil, server.name, ERR_NOMOTD, nick, "MOTD is unavailable")
  343. for _, line := range server.Config().Server.STS.bannerLines {
  344. session.Send(nil, server.name, "NOTICE", nick, line)
  345. }
  346. }
  347. func (server *Server) playRegistrationBurst(session *Session) {
  348. c := session.client
  349. // continue registration
  350. d := c.Details()
  351. server.logger.Info("connect", fmt.Sprintf("Client connected [%s] [u:%s] [r:%s]", d.nick, d.username, d.realname))
  352. server.snomasks.Send(sno.LocalConnects, fmt.Sprintf("Client connected [%s] [u:%s] [h:%s] [ip:%s] [r:%s]", d.nick, d.username, session.rawHostname, session.IP().String(), d.realname))
  353. if d.account != "" {
  354. server.sendLoginSnomask(d.nickMask, d.accountName)
  355. }
  356. // send welcome text
  357. //NOTE(dan): we specifically use the NICK here instead of the nickmask
  358. // see http://modern.ircdocs.horse/#rplwelcome-001 for details on why we avoid using the nickmask
  359. config := server.Config()
  360. session.Send(nil, server.name, RPL_WELCOME, d.nick, fmt.Sprintf(c.t("Welcome to the %s IRC Network %s"), config.Network.Name, d.nick))
  361. session.Send(nil, server.name, RPL_YOURHOST, d.nick, fmt.Sprintf(c.t("Your host is %[1]s, running version %[2]s"), server.name, Ver))
  362. session.Send(nil, server.name, RPL_CREATED, d.nick, fmt.Sprintf(c.t("This server was created %s"), server.ctime.Format(time.RFC1123)))
  363. session.Send(nil, server.name, RPL_MYINFO, d.nick, server.name, Ver, rplMyInfo1, rplMyInfo2, rplMyInfo3)
  364. rb := NewResponseBuffer(session)
  365. server.RplISupport(c, rb)
  366. server.Lusers(c, rb)
  367. server.MOTD(c, rb)
  368. rb.Send(true)
  369. modestring := c.ModeString()
  370. if modestring != "+" {
  371. session.Send(nil, server.name, RPL_UMODEIS, d.nick, modestring)
  372. }
  373. c.attemptAutoOper(session)
  374. if server.logger.IsLoggingRawIO() {
  375. session.Send(nil, c.server.name, "NOTICE", d.nick, c.t("This server is in debug mode and is logging all user I/O. If you do not wish for everything you send to be readable by the server owner(s), please disconnect."))
  376. }
  377. }
  378. // RplISupport outputs our ISUPPORT lines to the client. This is used on connection and in VERSION responses.
  379. func (server *Server) RplISupport(client *Client, rb *ResponseBuffer) {
  380. translatedISupport := client.t("are supported by this server")
  381. nick := client.Nick()
  382. config := server.Config()
  383. for _, cachedTokenLine := range config.Server.isupport.CachedReply {
  384. length := len(cachedTokenLine) + 2
  385. tokenline := make([]string, length)
  386. tokenline[0] = nick
  387. copy(tokenline[1:], cachedTokenLine)
  388. tokenline[length-1] = translatedISupport
  389. rb.Add(nil, server.name, RPL_ISUPPORT, tokenline...)
  390. }
  391. }
  392. func (server *Server) Lusers(client *Client, rb *ResponseBuffer) {
  393. nick := client.Nick()
  394. config := server.Config()
  395. var stats StatsValues
  396. var numChannels int
  397. if !config.Server.SuppressLusers || client.HasRoleCapabs("ban") {
  398. stats = server.stats.GetValues()
  399. numChannels = server.channels.Len()
  400. }
  401. rb.Add(nil, server.name, RPL_LUSERCLIENT, nick, fmt.Sprintf(client.t("There are %[1]d users and %[2]d invisible on %[3]d server(s)"), stats.Total-stats.Invisible, stats.Invisible, 1))
  402. rb.Add(nil, server.name, RPL_LUSEROP, nick, strconv.Itoa(stats.Operators), client.t("IRC Operators online"))
  403. rb.Add(nil, server.name, RPL_LUSERUNKNOWN, nick, strconv.Itoa(stats.Unknown), client.t("unregistered connections"))
  404. rb.Add(nil, server.name, RPL_LUSERCHANNELS, nick, strconv.Itoa(numChannels), client.t("channels formed"))
  405. rb.Add(nil, server.name, RPL_LUSERME, nick, fmt.Sprintf(client.t("I have %[1]d clients and %[2]d servers"), stats.Total, 0))
  406. total := strconv.Itoa(stats.Total)
  407. max := strconv.Itoa(stats.Max)
  408. rb.Add(nil, server.name, RPL_LOCALUSERS, nick, total, max, fmt.Sprintf(client.t("Current local users %[1]s, max %[2]s"), total, max))
  409. rb.Add(nil, server.name, RPL_GLOBALUSERS, nick, total, max, fmt.Sprintf(client.t("Current global users %[1]s, max %[2]s"), total, max))
  410. }
  411. // MOTD serves the Message of the Day.
  412. func (server *Server) MOTD(client *Client, rb *ResponseBuffer) {
  413. motdLines := server.Config().Server.motdLines
  414. if len(motdLines) < 1 {
  415. rb.Add(nil, server.name, ERR_NOMOTD, client.nick, client.t("MOTD File is missing"))
  416. return
  417. }
  418. rb.Add(nil, server.name, RPL_MOTDSTART, client.nick, fmt.Sprintf(client.t("- %s Message of the day - "), server.name))
  419. for _, line := range motdLines {
  420. rb.Add(nil, server.name, RPL_MOTD, client.nick, line)
  421. }
  422. rb.Add(nil, server.name, RPL_ENDOFMOTD, client.nick, client.t("End of MOTD command"))
  423. }
  424. func (client *Client) whoisChannelsNames(target *Client, multiPrefix bool, hasPrivs bool) []string {
  425. var chstrs []string
  426. targetInvis := target.HasMode(modes.Invisible)
  427. for _, channel := range target.Channels() {
  428. if !hasPrivs && (targetInvis || channel.flags.HasMode(modes.Secret)) && !channel.hasClient(client) {
  429. // client can't see *this* channel membership
  430. continue
  431. }
  432. chstrs = append(chstrs, channel.ClientPrefixes(target, multiPrefix)+channel.name)
  433. }
  434. return chstrs
  435. }
  436. func (client *Client) getWhoisOf(target *Client, hasPrivs bool, rb *ResponseBuffer) {
  437. oper := client.Oper()
  438. cnick := client.Nick()
  439. targetInfo := target.Details()
  440. rb.Add(nil, client.server.name, RPL_WHOISUSER, cnick, targetInfo.nick, targetInfo.username, targetInfo.hostname, "*", targetInfo.realname)
  441. tnick := targetInfo.nick
  442. whoischannels := client.whoisChannelsNames(target, rb.session.capabilities.Has(caps.MultiPrefix), oper.HasRoleCapab("sajoin"))
  443. if whoischannels != nil {
  444. rb.Add(nil, client.server.name, RPL_WHOISCHANNELS, cnick, tnick, strings.Join(whoischannels, " "))
  445. }
  446. if target.HasMode(modes.Operator) && operStatusVisible(client, target, oper != nil) {
  447. tOper := target.Oper()
  448. if tOper != nil {
  449. rb.Add(nil, client.server.name, RPL_WHOISOPERATOR, cnick, tnick, tOper.WhoisLine)
  450. }
  451. }
  452. if client == target || oper.HasRoleCapab("ban") {
  453. ip, hostname := target.getWhoisActually()
  454. rb.Add(nil, client.server.name, RPL_WHOISACTUALLY, cnick, tnick, fmt.Sprintf("%s@%s", targetInfo.username, hostname), utils.IPStringToHostname(ip.String()), client.t("Actual user@host, Actual IP"))
  455. }
  456. if client == target || oper.HasRoleCapab("samode") {
  457. rb.Add(nil, client.server.name, RPL_WHOISMODES, cnick, tnick, fmt.Sprintf(client.t("is using modes +%s"), target.modes.String()))
  458. }
  459. if target.HasMode(modes.TLS) {
  460. rb.Add(nil, client.server.name, RPL_WHOISSECURE, cnick, tnick, client.t("is using a secure connection"))
  461. }
  462. if targetInfo.accountName != "*" {
  463. rb.Add(nil, client.server.name, RPL_WHOISACCOUNT, cnick, tnick, targetInfo.accountName, client.t("is logged in as"))
  464. }
  465. if target.HasMode(modes.Bot) {
  466. rb.Add(nil, client.server.name, RPL_WHOISBOT, cnick, tnick, fmt.Sprintf(ircfmt.Unescape(client.t("is a $bBot$b on %s")), client.server.Config().Network.Name))
  467. }
  468. if client == target || oper.HasRoleCapab("ban") {
  469. for _, session := range target.Sessions() {
  470. if session.certfp != "" {
  471. rb.Add(nil, client.server.name, RPL_WHOISCERTFP, cnick, tnick, fmt.Sprintf(client.t("has client certificate fingerprint %s"), session.certfp))
  472. }
  473. }
  474. }
  475. rb.Add(nil, client.server.name, RPL_WHOISIDLE, cnick, tnick, strconv.FormatUint(target.IdleSeconds(), 10), strconv.FormatInt(target.SignonTime(), 10), client.t("seconds idle, signon time"))
  476. if away, awayMessage := target.Away(); away {
  477. rb.Add(nil, client.server.name, RPL_AWAY, cnick, tnick, awayMessage)
  478. }
  479. }
  480. // rehash reloads the config and applies the changes from the config file.
  481. func (server *Server) rehash() error {
  482. // #1570; this needs its own panic handling because it can be invoked via SIGHUP
  483. defer server.HandlePanic()
  484. server.logger.Info("server", "Attempting rehash")
  485. // only let one REHASH go on at a time
  486. server.rehashMutex.Lock()
  487. defer server.rehashMutex.Unlock()
  488. sdnotify.Reloading()
  489. defer sdnotify.Ready()
  490. config, err := LoadConfig(server.configFilename)
  491. if err != nil {
  492. server.logger.Error("server", "failed to load config file", err.Error())
  493. return err
  494. }
  495. err = server.applyConfig(config)
  496. if err != nil {
  497. server.logger.Error("server", "Failed to rehash", err.Error())
  498. return err
  499. }
  500. server.logger.Info("server", "Rehash completed successfully")
  501. return nil
  502. }
  503. func (server *Server) applyConfig(config *Config) (err error) {
  504. oldConfig := server.Config()
  505. initial := oldConfig == nil
  506. if initial {
  507. server.configFilename = config.Filename
  508. server.name = config.Server.Name
  509. server.nameCasefolded = config.Server.nameCasefolded
  510. globalCasemappingSetting = config.Server.Casemapping
  511. globalUtf8EnforcementSetting = config.Server.EnforceUtf8
  512. MaxLineLen = config.Server.MaxLineLen
  513. } else {
  514. // enforce configs that can't be changed after launch:
  515. if server.name != config.Server.Name {
  516. return fmt.Errorf("Server name cannot be changed after launching the server, rehash aborted")
  517. } else if oldConfig.Datastore.Path != config.Datastore.Path {
  518. return fmt.Errorf("Datastore path cannot be changed after launching the server, rehash aborted")
  519. } else if globalCasemappingSetting != config.Server.Casemapping {
  520. return fmt.Errorf("Casemapping cannot be changed after launching the server, rehash aborted")
  521. } else if globalUtf8EnforcementSetting != config.Server.EnforceUtf8 {
  522. return fmt.Errorf("UTF-8 enforcement cannot be changed after launching the server, rehash aborted")
  523. } else if oldConfig.Accounts.Multiclient.AlwaysOn != config.Accounts.Multiclient.AlwaysOn {
  524. return fmt.Errorf("Default always-on setting cannot be changed after launching the server, rehash aborted")
  525. } else if oldConfig.Server.Relaymsg.Enabled != config.Server.Relaymsg.Enabled {
  526. return fmt.Errorf("Cannot enable or disable relaying after launching the server, rehash aborted")
  527. } else if oldConfig.Server.Relaymsg.Separators != config.Server.Relaymsg.Separators {
  528. return fmt.Errorf("Cannot change relaying separators after launching the server, rehash aborted")
  529. } else if oldConfig.Server.IPCheckScript.MaxConcurrency != config.Server.IPCheckScript.MaxConcurrency ||
  530. oldConfig.Accounts.AuthScript.MaxConcurrency != config.Accounts.AuthScript.MaxConcurrency {
  531. return fmt.Errorf("Cannot change max-concurrency for scripts after launching the server, rehash aborted")
  532. } else if oldConfig.Server.OverrideServicesHostname != config.Server.OverrideServicesHostname {
  533. return fmt.Errorf("Cannot change override-services-hostname after launching the server, rehash aborted")
  534. } else if !oldConfig.Datastore.MySQL.Enabled && config.Datastore.MySQL.Enabled {
  535. return fmt.Errorf("Cannot enable MySQL after launching the server, rehash aborted")
  536. } else if oldConfig.Server.MaxLineLen != config.Server.MaxLineLen {
  537. return fmt.Errorf("Cannot change max-line-len after launching the server, rehash aborted")
  538. }
  539. }
  540. server.logger.Info("server", "Using config file", server.configFilename)
  541. if initial {
  542. if config.LockFile != "" {
  543. server.flock, err = flock.TryAcquireFlock(config.LockFile)
  544. if err != nil {
  545. return fmt.Errorf("failed to acquire flock on %s: %w",
  546. config.LockFile, err)
  547. }
  548. }
  549. // the lock is never released until quit; we need to save a pointer
  550. // to the (*flock.Flock) object so it doesn't get GC'ed, which would
  551. // close the file and surrender the lock
  552. }
  553. // first, reload config sections for functionality implemented in subpackages:
  554. wasLoggingRawIO := !initial && server.logger.IsLoggingRawIO()
  555. err = server.logger.ApplyConfig(config.Logging)
  556. if err != nil {
  557. return err
  558. }
  559. nowLoggingRawIO := server.logger.IsLoggingRawIO()
  560. // notify existing clients if raw i/o logging was enabled by a rehash
  561. sendRawOutputNotice := !wasLoggingRawIO && nowLoggingRawIO
  562. server.connectionLimiter.ApplyConfig(&config.Server.IPLimits)
  563. tlConf := &config.Server.TorListeners
  564. server.torLimiter.Configure(tlConf.MaxConnections, tlConf.ThrottleDuration, tlConf.MaxConnectionsPerDuration)
  565. // Translations
  566. server.logger.Debug("server", "Regenerating HELP indexes for new languages")
  567. server.helpIndexManager.GenerateIndices(config.languageManager)
  568. if initial {
  569. maxIPConc := int(config.Server.IPCheckScript.MaxConcurrency)
  570. if maxIPConc != 0 {
  571. server.semaphores.IPCheckScript = utils.NewSemaphore(maxIPConc)
  572. }
  573. maxAuthConc := int(config.Accounts.AuthScript.MaxConcurrency)
  574. if maxAuthConc != 0 {
  575. server.semaphores.AuthScript = utils.NewSemaphore(maxAuthConc)
  576. }
  577. if err := overrideServicePrefixes(config.Server.OverrideServicesHostname); err != nil {
  578. return err
  579. }
  580. }
  581. if oldConfig != nil {
  582. // if certain features were enabled by rehash, we need to load the corresponding data
  583. // from the store
  584. if !oldConfig.Accounts.NickReservation.Enabled {
  585. server.accounts.buildNickToAccountIndex(config)
  586. }
  587. if !oldConfig.Channels.Registration.Enabled {
  588. server.channels.loadRegisteredChannels(config)
  589. }
  590. // resize history buffers as needed
  591. if config.historyChangedFrom(oldConfig) {
  592. for _, channel := range server.channels.Channels() {
  593. channel.resizeHistory(config)
  594. }
  595. for _, client := range server.clients.AllClients() {
  596. client.resizeHistory(config)
  597. }
  598. }
  599. if oldConfig.Accounts.Registration.Throttling != config.Accounts.Registration.Throttling {
  600. server.accounts.resetRegisterThrottle(config)
  601. }
  602. }
  603. server.logger.Info("server", "Using datastore", config.Datastore.Path)
  604. if initial {
  605. if err := server.loadDatastore(config); err != nil {
  606. return err
  607. }
  608. } else {
  609. if config.Datastore.MySQL.Enabled && config.Datastore.MySQL != oldConfig.Datastore.MySQL {
  610. server.historyDB.SetConfig(config.Datastore.MySQL)
  611. }
  612. }
  613. // now that the datastore is initialized, we can load the cloak secret from it
  614. // XXX this modifies config after the initial load, which is naughty,
  615. // but there's no data race because we haven't done SetConfig yet
  616. config.Server.Cloaks.SetSecret(LoadCloakSecret(server.store))
  617. // activate the new config
  618. server.SetConfig(config)
  619. // load [dk]-lines, registered users and channels, etc.
  620. if initial {
  621. if err := server.loadFromDatastore(config); err != nil {
  622. return err
  623. }
  624. }
  625. // burst new and removed caps
  626. addedCaps, removedCaps := config.Diff(oldConfig)
  627. var capBurstSessions []*Session
  628. added := make(map[caps.Version][]string)
  629. var removed []string
  630. if !addedCaps.Empty() || !removedCaps.Empty() {
  631. capBurstSessions = server.clients.AllWithCapsNotify()
  632. added[caps.Cap301] = addedCaps.Strings(caps.Cap301, config.Server.capValues, 0)
  633. added[caps.Cap302] = addedCaps.Strings(caps.Cap302, config.Server.capValues, 0)
  634. // removed never has values, so we leave it as Cap301
  635. removed = removedCaps.Strings(caps.Cap301, config.Server.capValues, 0)
  636. }
  637. for _, sSession := range capBurstSessions {
  638. // DEL caps and then send NEW ones so that updated caps get removed/added correctly
  639. if !removedCaps.Empty() {
  640. for _, capStr := range removed {
  641. sSession.Send(nil, server.name, "CAP", sSession.client.Nick(), "DEL", capStr)
  642. }
  643. }
  644. if !addedCaps.Empty() {
  645. for _, capStr := range added[sSession.capVersion] {
  646. sSession.Send(nil, server.name, "CAP", sSession.client.Nick(), "NEW", capStr)
  647. }
  648. }
  649. }
  650. server.setupPprofListener(config)
  651. // set RPL_ISUPPORT
  652. var newISupportReplies [][]string
  653. if oldConfig != nil {
  654. newISupportReplies = oldConfig.Server.isupport.GetDifference(&config.Server.isupport)
  655. }
  656. if len(config.Server.ProxyAllowedFrom) != 0 {
  657. server.logger.Info("server", "Proxied IPs will be accepted from", strings.Join(config.Server.ProxyAllowedFrom, ", "))
  658. }
  659. // we are now ready to receive connections:
  660. err = server.setupListeners(config)
  661. if initial && err == nil {
  662. server.logger.Info("server", "Server running")
  663. sdnotify.Ready()
  664. }
  665. if !initial {
  666. // push new info to all of our clients
  667. for _, sClient := range server.clients.AllClients() {
  668. for _, tokenline := range newISupportReplies {
  669. sClient.Send(nil, server.name, RPL_ISUPPORT, append([]string{sClient.nick}, tokenline...)...)
  670. }
  671. if sendRawOutputNotice {
  672. sClient.Notice(sClient.t("This server is in debug mode and is logging all user I/O. If you do not wish for everything you send to be readable by the server owner(s), please disconnect."))
  673. }
  674. }
  675. }
  676. // send other config warnings
  677. if config.Accounts.RequireSasl.Enabled && config.Accounts.Registration.Enabled {
  678. server.logger.Warning("server", "Warning: although require-sasl is enabled, users can still register accounts. If your server is not intended to be public, you must set accounts.registration.enabled to false.")
  679. }
  680. return err
  681. }
  682. func (server *Server) setupPprofListener(config *Config) {
  683. pprofListener := config.Debug.PprofListener
  684. if server.pprofServer != nil {
  685. if pprofListener == "" || (pprofListener != server.pprofServer.Addr) {
  686. server.logger.Info("server", "Stopping pprof listener", server.pprofServer.Addr)
  687. server.pprofServer.Close()
  688. server.pprofServer = nil
  689. }
  690. }
  691. if pprofListener != "" && server.pprofServer == nil {
  692. ps := http.Server{
  693. Addr: pprofListener,
  694. }
  695. go func() {
  696. if err := ps.ListenAndServe(); err != nil {
  697. server.logger.Error("server", "pprof listener failed", err.Error())
  698. }
  699. }()
  700. server.pprofServer = &ps
  701. server.logger.Info("server", "Started pprof listener", server.pprofServer.Addr)
  702. }
  703. }
  704. func (server *Server) loadDatastore(config *Config) error {
  705. // open the datastore and load server state for which it (rather than config)
  706. // is the source of truth
  707. _, err := os.Stat(config.Datastore.Path)
  708. if os.IsNotExist(err) {
  709. server.logger.Warning("server", "database does not exist, creating it", config.Datastore.Path)
  710. err = initializeDB(config.Datastore.Path)
  711. if err != nil {
  712. return err
  713. }
  714. }
  715. db, err := OpenDatabase(config)
  716. if err == nil {
  717. server.store = db
  718. return nil
  719. } else {
  720. return fmt.Errorf("Failed to open datastore: %s", err.Error())
  721. }
  722. }
  723. func (server *Server) loadFromDatastore(config *Config) (err error) {
  724. // load *lines (from the datastores)
  725. server.logger.Debug("server", "Loading D/Klines")
  726. server.loadDLines()
  727. server.loadKLines()
  728. server.channelRegistry.Initialize(server)
  729. server.channels.Initialize(server)
  730. server.accounts.Initialize(server)
  731. if config.Datastore.MySQL.Enabled {
  732. server.historyDB.Initialize(server.logger, config.Datastore.MySQL)
  733. err = server.historyDB.Open()
  734. if err != nil {
  735. server.logger.Error("internal", "could not connect to mysql", err.Error())
  736. return err
  737. }
  738. }
  739. return nil
  740. }
  741. func (server *Server) setupListeners(config *Config) (err error) {
  742. logListener := func(addr string, config utils.ListenerConfig) {
  743. server.logger.Info("listeners",
  744. fmt.Sprintf("now listening on %s, tls=%t, proxy=%t, tor=%t, websocket=%t.", addr, (config.TLSConfig != nil), config.RequireProxy, config.Tor, config.WebSocket),
  745. )
  746. }
  747. // update or destroy all existing listeners
  748. for addr := range server.listeners {
  749. currentListener := server.listeners[addr]
  750. newConfig, stillConfigured := config.Server.trueListeners[addr]
  751. if stillConfigured {
  752. if reloadErr := currentListener.Reload(newConfig); reloadErr == nil {
  753. logListener(addr, newConfig)
  754. } else {
  755. // stop the listener; we will attempt to replace it below
  756. currentListener.Stop()
  757. delete(server.listeners, addr)
  758. }
  759. } else {
  760. currentListener.Stop()
  761. delete(server.listeners, addr)
  762. server.logger.Info("listeners", fmt.Sprintf("stopped listening on %s.", addr))
  763. }
  764. }
  765. publicPlaintextListener := ""
  766. // create new listeners that were not previously configured,
  767. // or that couldn't be reloaded above:
  768. for newAddr, newConfig := range config.Server.trueListeners {
  769. if strings.HasPrefix(newAddr, ":") && !newConfig.Tor && !newConfig.STSOnly && newConfig.TLSConfig == nil {
  770. publicPlaintextListener = newAddr
  771. }
  772. _, exists := server.listeners[newAddr]
  773. if !exists {
  774. // make a new listener
  775. newListener, newErr := NewListener(server, newAddr, newConfig, config.Server.UnixBindMode)
  776. if newErr == nil {
  777. server.listeners[newAddr] = newListener
  778. logListener(newAddr, newConfig)
  779. } else {
  780. server.logger.Error("server", "couldn't listen on", newAddr, newErr.Error())
  781. err = newErr
  782. }
  783. }
  784. }
  785. if publicPlaintextListener != "" {
  786. server.logger.Warning("listeners", fmt.Sprintf("Warning: your server is configured with public plaintext listener %s. Consider disabling it for improved security and privacy.", publicPlaintextListener))
  787. }
  788. return
  789. }
  790. // Gets the abstract sequence from which we're going to query history;
  791. // we may already know the channel we're querying, or we may have
  792. // to look it up via a string query. This function is responsible for
  793. // privilege checking.
  794. // XXX: call this with providedChannel==nil and query=="" to get a sequence
  795. // suitable for ListCorrespondents (i.e., this function is still used to
  796. // decide whether the ringbuf or mysql is authoritative about the client's
  797. // message history).
  798. func (server *Server) GetHistorySequence(providedChannel *Channel, client *Client, query string) (channel *Channel, sequence history.Sequence, err error) {
  799. config := server.Config()
  800. // 4 cases: {persistent, ephemeral} x {normal, conversation}
  801. // with ephemeral history, target is implicit in the choice of `hist`,
  802. // and correspondent is "" if we're retrieving a channel or *, and the correspondent's name
  803. // if we're retrieving a DM conversation ("query buffer"). with persistent history,
  804. // target is always nonempty, and correspondent is either empty or nonempty as before.
  805. var status HistoryStatus
  806. var target, correspondent string
  807. var hist *history.Buffer
  808. restriction := HistoryCutoffNone
  809. channel = providedChannel
  810. if channel == nil {
  811. if strings.HasPrefix(query, "#") {
  812. channel = server.channels.Get(query)
  813. if channel == nil {
  814. return
  815. }
  816. }
  817. }
  818. var joinTimeCutoff time.Time
  819. if channel != nil {
  820. if present, cutoff := channel.joinTimeCutoff(client); present {
  821. joinTimeCutoff = cutoff
  822. } else {
  823. err = errInsufficientPrivs
  824. return
  825. }
  826. status, target, restriction = channel.historyStatus(config)
  827. switch status {
  828. case HistoryEphemeral:
  829. hist = &channel.history
  830. case HistoryPersistent:
  831. // already set `target`
  832. default:
  833. return
  834. }
  835. } else {
  836. status, target = client.historyStatus(config)
  837. if query != "" {
  838. correspondent, err = CasefoldName(query)
  839. if err != nil {
  840. return
  841. }
  842. }
  843. switch status {
  844. case HistoryEphemeral:
  845. hist = &client.history
  846. case HistoryPersistent:
  847. // already set `target`, and `correspondent` if necessary
  848. default:
  849. return
  850. }
  851. }
  852. var cutoff time.Time
  853. if config.History.Restrictions.ExpireTime != 0 {
  854. cutoff = time.Now().UTC().Add(-time.Duration(config.History.Restrictions.ExpireTime))
  855. }
  856. // #836: registration date cutoff is always enforced for DMs
  857. // either way, take the later of the two cutoffs
  858. if restriction == HistoryCutoffRegistrationTime || channel == nil {
  859. regCutoff := client.historyCutoff()
  860. if regCutoff.After(cutoff) {
  861. cutoff = regCutoff
  862. }
  863. } else if restriction == HistoryCutoffJoinTime {
  864. if joinTimeCutoff.After(cutoff) {
  865. cutoff = joinTimeCutoff
  866. }
  867. }
  868. // #836 again: grace period is never applied to DMs
  869. if !cutoff.IsZero() && channel != nil && restriction != HistoryCutoffJoinTime {
  870. cutoff = cutoff.Add(-time.Duration(config.History.Restrictions.GracePeriod))
  871. }
  872. if hist != nil {
  873. sequence = hist.MakeSequence(correspondent, cutoff)
  874. } else if target != "" {
  875. sequence = server.historyDB.MakeSequence(target, correspondent, cutoff)
  876. }
  877. return
  878. }
  879. func (server *Server) ForgetHistory(accountName string) {
  880. // sanity check
  881. if accountName == "*" {
  882. return
  883. }
  884. config := server.Config()
  885. if !config.History.Enabled {
  886. return
  887. }
  888. if cfAccount, err := CasefoldName(accountName); err == nil {
  889. server.historyDB.Forget(cfAccount)
  890. }
  891. persistent := config.History.Persistent
  892. if persistent.Enabled && persistent.UnregisteredChannels && persistent.RegisteredChannels == PersistentMandatory && persistent.DirectMessages == PersistentMandatory {
  893. return
  894. }
  895. predicate := func(item *history.Item) bool { return item.AccountName == accountName }
  896. for _, channel := range server.channels.Channels() {
  897. channel.history.Delete(predicate)
  898. }
  899. for _, client := range server.clients.AllClients() {
  900. client.history.Delete(predicate)
  901. }
  902. }
  903. // deletes a message. target is a hint about what buffer it's in (not required for
  904. // persistent history, where all the msgids are indexed together). if accountName
  905. // is anything other than "*", it must match the recorded AccountName of the message
  906. func (server *Server) DeleteMessage(target, msgid, accountName string) (err error) {
  907. config := server.Config()
  908. var hist *history.Buffer
  909. if target != "" {
  910. if target[0] == '#' {
  911. channel := server.channels.Get(target)
  912. if channel != nil {
  913. if status, _, _ := channel.historyStatus(config); status == HistoryEphemeral {
  914. hist = &channel.history
  915. }
  916. }
  917. } else {
  918. client := server.clients.Get(target)
  919. if client != nil {
  920. if status, _ := client.historyStatus(config); status == HistoryEphemeral {
  921. hist = &client.history
  922. }
  923. }
  924. }
  925. }
  926. if hist == nil {
  927. err = server.historyDB.DeleteMsgid(msgid, accountName)
  928. } else {
  929. count := hist.Delete(func(item *history.Item) bool {
  930. return item.Message.Msgid == msgid && (accountName == "*" || item.AccountName == accountName)
  931. })
  932. if count == 0 {
  933. err = errNoop
  934. }
  935. }
  936. return
  937. }
  938. func (server *Server) UnfoldName(cfname string) (name string) {
  939. if strings.HasPrefix(cfname, "#") {
  940. return server.channels.UnfoldName(cfname)
  941. }
  942. return server.clients.UnfoldNick(cfname)
  943. }
  944. // elistMatcher takes and matches ELIST conditions
  945. type elistMatcher struct {
  946. MinClientsActive bool
  947. MinClients int
  948. MaxClientsActive bool
  949. MaxClients int
  950. }
  951. // Matches checks whether the given channel matches our matches.
  952. func (matcher *elistMatcher) Matches(channel *Channel) bool {
  953. if matcher.MinClientsActive {
  954. if len(channel.Members()) < matcher.MinClients {
  955. return false
  956. }
  957. }
  958. if matcher.MaxClientsActive {
  959. if len(channel.Members()) < len(channel.members) {
  960. return false
  961. }
  962. }
  963. return true
  964. }
  965. var (
  966. infoString1 = strings.Split(`
  967. __ __ ______ ___ ______ ___
  968. __/ // /_/ ____/ __ \/ ____/ __ \
  969. /_ // __/ __/ / /_/ / / __/ / / /
  970. /_ // __/ /___/ _, _/ /_/ / /_/ /
  971. /_//_/ /_____/_/ |_|\____/\____/
  972. https://ergo.chat/
  973. https://github.com/ergochat/ergo
  974. `, "\n")[1:] // XXX: cut off initial blank line
  975. infoString2 = strings.Split(` Daniel Oakley, DanielOaks, <daniel@danieloaks.net>
  976. Shivaram Lingamneni, slingamn, <slingamn@cs.stanford.edu>
  977. `, "\n")
  978. infoString3 = strings.Split(` Jeremy Latt, jlatt
  979. Edmund Huber, edmund-huber
  980. `, "\n")
  981. )