Browse Source

Merge pull request #1347 from slingamn/issue1346.1

fix #1346
tags/v2.4.0-rc1
Shivaram Lingamneni 3 years ago
parent
commit
c2c5fe7cf8
No account linked to committer's email address
8 changed files with 35 additions and 393 deletions
  1. 0
    17
      conventional.yaml
  2. 0
    17
      default.yaml
  3. 4
    200
      irc/accounts.go
  4. 4
    9
      irc/config.go
  5. 24
    1
      irc/database.go
  6. 1
    144
      irc/hostserv.go
  7. 2
    2
      irc/import.go
  8. 0
    3
      irc/server.go

+ 0
- 17
conventional.yaml View File

@@ -475,23 +475,6 @@ accounts:
475 475
         # (make sure any changes you make here are RFC-compliant)
476 476
         valid-regexp: '^[0-9A-Za-z.\-_/]+$'
477 477
 
478
-        # options controlling users requesting vhosts:
479
-        user-requests:
480
-            # can users request vhosts at all? if this is false, operators with the
481
-            # 'vhosts' capability can still assign vhosts manually
482
-            enabled: false
483
-
484
-            # if uncommented, all new vhost requests will be dumped into the given
485
-            # channel, so opers can review them as they are sent in. ensure that you
486
-            # have registered and restricted the channel appropriately before you
487
-            # uncomment this.
488
-            #channel: "#vhosts"
489
-
490
-            # after a user's vhost has been approved or rejected, they need to wait
491
-            # this long (starting from the time of their original request)
492
-            # before they can request a new one.
493
-            cooldown: 168h
494
-
495 478
     # modes that are set by default when a user connects
496 479
     # if unset, no user modes will be set by default
497 480
     # +i is invisible (a user's channels are hidden from whois replies)

+ 0
- 17
default.yaml View File

@@ -503,23 +503,6 @@ accounts:
503 503
         # (make sure any changes you make here are RFC-compliant)
504 504
         valid-regexp: '^[0-9A-Za-z.\-_/]+$'
505 505
 
506
-        # options controlling users requesting vhosts:
507
-        user-requests:
508
-            # can users request vhosts at all? if this is false, operators with the
509
-            # 'vhosts' capability can still assign vhosts manually
510
-            enabled: false
511
-
512
-            # if uncommented, all new vhost requests will be dumped into the given
513
-            # channel, so opers can review them as they are sent in. ensure that you
514
-            # have registered and restricted the channel appropriately before you
515
-            # uncomment this.
516
-            #channel: "#vhosts"
517
-
518
-            # after a user's vhost has been approved or rejected, they need to wait
519
-            # this long (starting from the time of their original request)
520
-            # before they can request a new one.
521
-            cooldown: 168h
522
-
523 506
     # modes that are set by default when a user connects
524 507
     # if unset, no user modes will be set by default
525 508
     # +i is invisible (a user's channels are hidden from whois replies)

+ 4
- 200
irc/accounts.go View File

@@ -12,7 +12,6 @@ import (
12 12
 	"strconv"
13 13
 	"strings"
14 14
 	"sync"
15
-	"sync/atomic"
16 15
 	"time"
17 16
 	"unicode"
18 17
 
@@ -44,23 +43,14 @@ const (
44 43
 	keyAccountModes            = "account.modes %s"    // user modes for the always-on client as a string
45 44
 	keyAccountRealname         = "account.realname %s" // client realname stored as string
46 45
 
47
-	keyVHostQueueAcctToId = "vhostQueue %s"
48
-	vhostRequestIdx       = "vhostQueue"
49
-
50 46
 	maxCertfpsPerAccount = 5
51 47
 )
52 48
 
53 49
 // everything about accounts is persistent; therefore, the database is the authoritative
54 50
 // source of truth for all account information. anything on the heap is just a cache
55 51
 type AccountManager struct {
56
-	// XXX these are up here so they can be aligned to a 64-bit boundary, please forgive me
57
-	// autoincrementing ID for vhost requests:
58
-	vhostRequestID           uint64
59
-	vhostRequestPendingCount uint64
60
-
61 52
 	sync.RWMutex                      // tier 2
62 53
 	serialCacheUpdateMutex sync.Mutex // tier 3
63
-	vHostUpdateMutex       sync.Mutex // tier 3
64 54
 
65 55
 	server *Server
66 56
 	// track clients logged in to accounts
@@ -80,7 +70,6 @@ func (am *AccountManager) Initialize(server *Server) {
80 70
 
81 71
 	config := server.Config()
82 72
 	am.buildNickToAccountIndex(config)
83
-	am.initVHostRequestQueue(config)
84 73
 	am.createAlwaysOnClients(config)
85 74
 	am.resetRegisterThrottle(config)
86 75
 }
@@ -225,44 +214,6 @@ func (am *AccountManager) buildNickToAccountIndex(config *Config) {
225 214
 	}
226 215
 }
227 216
 
228
-func (am *AccountManager) initVHostRequestQueue(config *Config) {
229
-	if !config.Accounts.VHosts.Enabled {
230
-		return
231
-	}
232
-
233
-	am.vHostUpdateMutex.Lock()
234
-	defer am.vHostUpdateMutex.Unlock()
235
-
236
-	// the db maps the account name to the autoincrementing integer ID of its request
237
-	// create an numerically ordered index on ID, so we can list the oldest requests
238
-	// finally, collect the integer id of the newest request and the total request count
239
-	var total uint64
240
-	var lastIDStr string
241
-	err := am.server.store.Update(func(tx *buntdb.Tx) error {
242
-		err := tx.CreateIndex(vhostRequestIdx, fmt.Sprintf(keyVHostQueueAcctToId, "*"), buntdb.IndexInt)
243
-		if err != nil {
244
-			return err
245
-		}
246
-		return tx.Descend(vhostRequestIdx, func(key, value string) bool {
247
-			if lastIDStr == "" {
248
-				lastIDStr = value
249
-			}
250
-			total++
251
-			return true
252
-		})
253
-	})
254
-
255
-	if err != nil {
256
-		am.server.logger.Error("internal", "could not create vhost queue index", err.Error())
257
-	}
258
-
259
-	lastID, _ := strconv.ParseUint(lastIDStr, 10, 64)
260
-	am.server.logger.Debug("services", fmt.Sprintf("vhost queue length is %d, autoincrementing id is %d", total, lastID))
261
-
262
-	atomic.StoreUint64(&am.vhostRequestID, lastID)
263
-	atomic.StoreUint64(&am.vhostRequestPendingCount, total)
264
-}
265
-
266 217
 func (am *AccountManager) NickToAccount(nick string) string {
267 218
 	cfnick, err := CasefoldName(nick)
268 219
 	if err != nil {
@@ -1394,7 +1345,6 @@ func (am *AccountManager) Unregister(account string, erase bool) error {
1394 1345
 	nicksKey := fmt.Sprintf(keyAccountAdditionalNicks, casefoldedAccount)
1395 1346
 	settingsKey := fmt.Sprintf(keyAccountSettings, casefoldedAccount)
1396 1347
 	vhostKey := fmt.Sprintf(keyAccountVHost, casefoldedAccount)
1397
-	vhostQueueKey := fmt.Sprintf(keyVHostQueueAcctToId, casefoldedAccount)
1398 1348
 	channelsKey := fmt.Sprintf(keyAccountChannels, casefoldedAccount)
1399 1349
 	joinedChannelsKey := fmt.Sprintf(keyAccountJoinedChannels, casefoldedAccount)
1400 1350
 	lastSeenKey := fmt.Sprintf(keyAccountLastSeen, casefoldedAccount)
@@ -1461,8 +1411,6 @@ func (am *AccountManager) Unregister(account string, erase bool) error {
1461 1411
 		tx.Delete(modesKey)
1462 1412
 		tx.Delete(realnameKey)
1463 1413
 
1464
-		_, err := tx.Delete(vhostQueueKey)
1465
-		am.decrementVHostQueueCount(casefoldedAccount, err)
1466 1414
 		return nil
1467 1415
 	})
1468 1416
 
@@ -1635,42 +1583,8 @@ func (am *AccountManager) ModifyAccountSettings(account string, munger settingsM
1635 1583
 
1636 1584
 // represents someone's status in hostserv
1637 1585
 type VHostInfo struct {
1638
-	ApprovedVHost   string
1639
-	Enabled         bool
1640
-	RequestedVHost  string
1641
-	RejectedVHost   string
1642
-	RejectionReason string
1643
-	LastRequestTime time.Time
1644
-}
1645
-
1646
-// pair type, <VHostInfo, accountName>
1647
-type PendingVHostRequest struct {
1648
-	VHostInfo
1649
-	Account string
1650
-}
1651
-
1652
-type vhostThrottleExceeded struct {
1653
-	timeRemaining time.Duration
1654
-}
1655
-
1656
-func (vhe *vhostThrottleExceeded) Error() string {
1657
-	return fmt.Sprintf("Wait at least %v and try again", vhe.timeRemaining)
1658
-}
1659
-
1660
-func (vh *VHostInfo) checkThrottle(cooldown time.Duration) (err error) {
1661
-	if cooldown == 0 {
1662
-		return nil
1663
-	}
1664
-
1665
-	now := time.Now().UTC()
1666
-	elapsed := now.Sub(vh.LastRequestTime)
1667
-	if elapsed > cooldown {
1668
-		// success
1669
-		vh.LastRequestTime = now
1670
-		return nil
1671
-	} else {
1672
-		return &vhostThrottleExceeded{timeRemaining: cooldown - elapsed}
1673
-	}
1586
+	ApprovedVHost string
1587
+	Enabled       bool
1674 1588
 }
1675 1589
 
1676 1590
 // callback type implementing the actual business logic of vhost operations
@@ -1687,52 +1601,6 @@ func (am *AccountManager) VHostSet(account string, vhost string) (result VHostIn
1687 1601
 	return am.performVHostChange(account, munger)
1688 1602
 }
1689 1603
 
1690
-func (am *AccountManager) VHostRequest(account string, vhost string, cooldown time.Duration) (result VHostInfo, err error) {
1691
-	munger := func(input VHostInfo) (output VHostInfo, err error) {
1692
-		output = input
1693
-		// you can update your existing request, but if you were approved or rejected,
1694
-		// you can't spam a new request
1695
-		if output.RequestedVHost == "" {
1696
-			err = output.checkThrottle(cooldown)
1697
-		}
1698
-		if err != nil {
1699
-			return
1700
-		}
1701
-		output.RequestedVHost = vhost
1702
-		output.RejectedVHost = ""
1703
-		output.RejectionReason = ""
1704
-		output.LastRequestTime = time.Now().UTC()
1705
-		return
1706
-	}
1707
-
1708
-	return am.performVHostChange(account, munger)
1709
-}
1710
-
1711
-func (am *AccountManager) VHostApprove(account string) (result VHostInfo, err error) {
1712
-	munger := func(input VHostInfo) (output VHostInfo, err error) {
1713
-		output = input
1714
-		output.Enabled = true
1715
-		output.ApprovedVHost = input.RequestedVHost
1716
-		output.RequestedVHost = ""
1717
-		output.RejectionReason = ""
1718
-		return
1719
-	}
1720
-
1721
-	return am.performVHostChange(account, munger)
1722
-}
1723
-
1724
-func (am *AccountManager) VHostReject(account string, reason string) (result VHostInfo, err error) {
1725
-	munger := func(input VHostInfo) (output VHostInfo, err error) {
1726
-		output = input
1727
-		output.RejectedVHost = output.RequestedVHost
1728
-		output.RequestedVHost = ""
1729
-		output.RejectionReason = reason
1730
-		return
1731
-	}
1732
-
1733
-	return am.performVHostChange(account, munger)
1734
-}
1735
-
1736 1604
 func (am *AccountManager) VHostSetEnabled(client *Client, enabled bool) (result VHostInfo, err error) {
1737 1605
 	munger := func(input VHostInfo) (output VHostInfo, err error) {
1738 1606
 		if input.ApprovedVHost == "" {
@@ -1759,9 +1627,6 @@ func (am *AccountManager) performVHostChange(account string, munger vhostMunger)
1759 1627
 		return
1760 1628
 	}
1761 1629
 
1762
-	am.vHostUpdateMutex.Lock()
1763
-	defer am.vHostUpdateMutex.Unlock()
1764
-
1765 1630
 	clientAccount, err := am.LoadAccount(account)
1766 1631
 	if err != nil {
1767 1632
 		err = errAccountDoesNotExist
@@ -1784,25 +1649,9 @@ func (am *AccountManager) performVHostChange(account string, munger vhostMunger)
1784 1649
 	vhstr := string(vhtext)
1785 1650
 
1786 1651
 	key := fmt.Sprintf(keyAccountVHost, account)
1787
-	queueKey := fmt.Sprintf(keyVHostQueueAcctToId, account)
1788 1652
 	err = am.server.store.Update(func(tx *buntdb.Tx) error {
1789
-		if _, _, err := tx.Set(key, vhstr, nil); err != nil {
1790
-			return err
1791
-		}
1792
-
1793
-		// update request queue
1794
-		if clientAccount.VHost.RequestedVHost == "" && result.RequestedVHost != "" {
1795
-			id := atomic.AddUint64(&am.vhostRequestID, 1)
1796
-			if _, _, err = tx.Set(queueKey, strconv.FormatUint(id, 10), nil); err != nil {
1797
-				return err
1798
-			}
1799
-			atomic.AddUint64(&am.vhostRequestPendingCount, 1)
1800
-		} else if clientAccount.VHost.RequestedVHost != "" && result.RequestedVHost == "" {
1801
-			_, err = tx.Delete(queueKey)
1802
-			am.decrementVHostQueueCount(account, err)
1803
-		}
1804
-
1805
-		return nil
1653
+		_, _, err := tx.Set(key, vhstr, nil)
1654
+		return err
1806 1655
 	})
1807 1656
 
1808 1657
 	if err != nil {
@@ -1814,51 +1663,6 @@ func (am *AccountManager) performVHostChange(account string, munger vhostMunger)
1814 1663
 	return result, nil
1815 1664
 }
1816 1665
 
1817
-// XXX annoying helper method for keeping the queue count in sync with the DB
1818
-// `err` is the buntdb error returned from deleting the queue key
1819
-func (am *AccountManager) decrementVHostQueueCount(account string, err error) {
1820
-	if err == nil {
1821
-		// successfully deleted a queue entry, do a 2's complement decrement:
1822
-		atomic.AddUint64(&am.vhostRequestPendingCount, ^uint64(0))
1823
-	} else if err != buntdb.ErrNotFound {
1824
-		am.server.logger.Error("internal", "buntdb dequeue error", account, err.Error())
1825
-	}
1826
-}
1827
-
1828
-func (am *AccountManager) VHostListRequests(limit int) (requests []PendingVHostRequest, total int) {
1829
-	am.vHostUpdateMutex.Lock()
1830
-	defer am.vHostUpdateMutex.Unlock()
1831
-
1832
-	total = int(atomic.LoadUint64(&am.vhostRequestPendingCount))
1833
-
1834
-	prefix := fmt.Sprintf(keyVHostQueueAcctToId, "")
1835
-	accounts := make([]string, 0, limit)
1836
-	err := am.server.store.View(func(tx *buntdb.Tx) error {
1837
-		return tx.Ascend(vhostRequestIdx, func(key, value string) bool {
1838
-			accounts = append(accounts, strings.TrimPrefix(key, prefix))
1839
-			return len(accounts) < limit
1840
-		})
1841
-	})
1842
-
1843
-	if err != nil {
1844
-		am.server.logger.Error("internal", "couldn't traverse vhost queue", err.Error())
1845
-		return
1846
-	}
1847
-
1848
-	for _, account := range accounts {
1849
-		accountInfo, err := am.LoadAccount(account)
1850
-		if err == nil {
1851
-			requests = append(requests, PendingVHostRequest{
1852
-				Account:   account,
1853
-				VHostInfo: accountInfo.VHost,
1854
-			})
1855
-		} else {
1856
-			am.server.logger.Error("internal", "corrupt account", account, err.Error())
1857
-		}
1858
-	}
1859
-	return
1860
-}
1861
-
1862 1666
 func (am *AccountManager) applyVHostInfo(client *Client, info VHostInfo) {
1863 1667
 	// if hostserv is disabled in config, then don't grant vhosts
1864 1668
 	// that were previously approved while it was enabled

+ 4
- 9
irc/config.go View File

@@ -316,12 +316,7 @@ type VHostConfig struct {
316 316
 	Enabled        bool
317 317
 	MaxLength      int    `yaml:"max-length"`
318 318
 	ValidRegexpRaw string `yaml:"valid-regexp"`
319
-	ValidRegexp    *regexp.Regexp
320
-	UserRequests   struct {
321
-		Enabled  bool
322
-		Channel  string
323
-		Cooldown custime.Duration
324
-	} `yaml:"user-requests"`
319
+	validRegexp    *regexp.Regexp
325 320
 }
326 321
 
327 322
 type NickEnforcementMethod int
@@ -1109,13 +1104,13 @@ func LoadConfig(filename string) (config *Config, err error) {
1109 1104
 	if rawRegexp != "" {
1110 1105
 		regexp, err := regexp.Compile(rawRegexp)
1111 1106
 		if err == nil {
1112
-			config.Accounts.VHosts.ValidRegexp = regexp
1107
+			config.Accounts.VHosts.validRegexp = regexp
1113 1108
 		} else {
1114 1109
 			log.Printf("invalid vhost regexp: %s\n", err.Error())
1115 1110
 		}
1116 1111
 	}
1117
-	if config.Accounts.VHosts.ValidRegexp == nil {
1118
-		config.Accounts.VHosts.ValidRegexp = defaultValidVhostRegex
1112
+	if config.Accounts.VHosts.validRegexp == nil {
1113
+		config.Accounts.VHosts.validRegexp = defaultValidVhostRegex
1119 1114
 	}
1120 1115
 
1121 1116
 	config.Server.capValues[caps.SASL] = "PLAIN,EXTERNAL"

+ 24
- 1
irc/database.go View File

@@ -24,7 +24,7 @@ const (
24 24
 	// 'version' of the database schema
25 25
 	keySchemaVersion = "db.version"
26 26
 	// latest schema of the db
27
-	latestDbSchema = "16"
27
+	latestDbSchema = "17"
28 28
 
29 29
 	keyCloakSecret = "crypto.cloak_secret"
30 30
 )
@@ -835,6 +835,24 @@ func schemaChangeV15ToV16(config *Config, tx *buntdb.Tx) error {
835 835
 	return nil
836 836
 }
837 837
 
838
+// #1346: remove vhost request queue
839
+func schemaChangeV16ToV17(config *Config, tx *buntdb.Tx) error {
840
+	prefix := "vhostQueue "
841
+	var keys []string
842
+	tx.AscendGreaterOrEqual("", prefix, func(key, value string) bool {
843
+		if !strings.HasPrefix(key, prefix) {
844
+			return false
845
+		}
846
+		keys = append(keys, key)
847
+		return true
848
+	})
849
+
850
+	for _, key := range keys {
851
+		tx.Delete(key)
852
+	}
853
+	return nil
854
+}
855
+
838 856
 func init() {
839 857
 	allChanges := []SchemaChange{
840 858
 		{
@@ -912,6 +930,11 @@ func init() {
912 930
 			TargetVersion:  "16",
913 931
 			Changer:        schemaChangeV15ToV16,
914 932
 		},
933
+		{
934
+			InitialVersion: "16",
935
+			TargetVersion:  "17",
936
+			Changer:        schemaChangeV16ToV17,
937
+		},
915 938
 	}
916 939
 
917 940
 	// build the index

+ 1
- 144
irc/hostserv.go View File

@@ -7,11 +7,9 @@ import (
7 7
 	"errors"
8 8
 	"fmt"
9 9
 	"regexp"
10
-	"time"
11 10
 
12 11
 	"github.com/goshuirc/irc-go/ircfmt"
13 12
 
14
-	"github.com/oragono/oragono/irc/sno"
15 13
 	"github.com/oragono/oragono/irc/utils"
16 14
 )
17 15
 
@@ -32,10 +30,6 @@ func hostservEnabled(config *Config) bool {
32 30
 	return config.Accounts.VHosts.Enabled
33 31
 }
34 32
 
35
-func hostservRequestsEnabled(config *Config) bool {
36
-	return config.Accounts.VHosts.Enabled && config.Accounts.VHosts.UserRequests.Enabled
37
-}
38
-
39 33
 var (
40 34
 	hostservCommands = map[string]*serviceCommand{
41 35
 		"on": {
@@ -56,17 +50,6 @@ OFF disables your vhost, if you have one approved.`,
56 50
 			authRequired: true,
57 51
 			enabled:      hostservEnabled,
58 52
 		},
59
-		"request": {
60
-			handler: hsRequestHandler,
61
-			help: `Syntax: $bREQUEST <vhost>$b
62
-
63
-REQUEST requests that a new vhost by assigned to your account. The request must
64
-then be approved by a server operator.`,
65
-			helpShort:    `$bREQUEST$b requests a new vhost, pending operator approval.`,
66
-			authRequired: true,
67
-			enabled:      hostservRequestsEnabled,
68
-			minParams:    1,
69
-		},
70 53
 		"status": {
71 54
 			handler: hsStatusHandler,
72 55
 			help: `Syntax: $bSTATUS [user]$b
@@ -96,39 +79,6 @@ DEL deletes a user's vhost.`,
96 79
 			enabled:   hostservEnabled,
97 80
 			minParams: 1,
98 81
 		},
99
-		"waiting": {
100
-			handler: hsWaitingHandler,
101
-			help: `Syntax: $bWAITING$b
102
-
103
-WAITING shows a list of pending vhost requests, which can then be approved
104
-or rejected.`,
105
-			helpShort: `$bWAITING$b shows a list of pending vhost requests.`,
106
-			capabs:    []string{"vhosts"},
107
-			enabled:   hostservEnabled,
108
-		},
109
-		"approve": {
110
-			handler: hsApproveHandler,
111
-			help: `Syntax: $bAPPROVE <user>$b
112
-
113
-APPROVE approves a user's vhost request.`,
114
-			helpShort: `$bAPPROVE$b approves a user's vhost request.`,
115
-			capabs:    []string{"vhosts"},
116
-			enabled:   hostservEnabled,
117
-			minParams: 1,
118
-		},
119
-		"reject": {
120
-			handler: hsRejectHandler,
121
-			help: `Syntax: $bREJECT <user> [<reason>]$b
122
-
123
-REJECT rejects a user's vhost request, optionally giving them a reason
124
-for the rejection.`,
125
-			helpShort:         `$bREJECT$b rejects a user's vhost request.`,
126
-			capabs:            []string{"vhosts"},
127
-			enabled:           hostservEnabled,
128
-			minParams:         1,
129
-			maxParams:         2,
130
-			unsplitFinalParam: true,
131
-		},
132 82
 		"setcloaksecret": {
133 83
 			handler: hsSetCloakSecretHandler,
134 84
 			help: `Syntax: $bSETCLOAKSECRET$b <secret> [code]
@@ -150,19 +100,6 @@ func hsNotice(rb *ResponseBuffer, text string) {
150 100
 	rb.Add(nil, hsNickMask, "NOTICE", rb.target.Nick(), text)
151 101
 }
152 102
 
153
-// hsNotifyChannel notifies the designated channel of new vhost activity
154
-func hsNotifyChannel(server *Server, message string) {
155
-	chname := server.Config().Accounts.VHosts.UserRequests.Channel
156
-	channel := server.channels.Get(chname)
157
-	if channel == nil {
158
-		return
159
-	}
160
-	chname = channel.Name()
161
-	for _, client := range channel.Members() {
162
-		client.Send(nil, hsNickMask, "PRIVMSG", chname, message)
163
-	}
164
-}
165
-
166 103
 func hsOnOffHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
167 104
 	enable := false
168 105
 	if command == "on" {
@@ -181,29 +118,6 @@ func hsOnOffHandler(server *Server, client *Client, command string, params []str
181 118
 	}
182 119
 }
183 120
 
184
-func hsRequestHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
185
-	vhost := params[0]
186
-	if validateVhost(server, vhost, false) != nil {
187
-		hsNotice(rb, client.t("Invalid vhost"))
188
-		return
189
-	}
190
-
191
-	accountName := client.Account()
192
-	_, err := server.accounts.VHostRequest(accountName, vhost, time.Duration(server.Config().Accounts.VHosts.UserRequests.Cooldown))
193
-	if err != nil {
194
-		if throttled, ok := err.(*vhostThrottleExceeded); ok {
195
-			hsNotice(rb, fmt.Sprintf(client.t("You must wait an additional %v before making another request"), throttled.timeRemaining))
196
-		} else {
197
-			hsNotice(rb, client.t("An error occurred"))
198
-		}
199
-	} else {
200
-		hsNotice(rb, client.t("Your vhost request will be reviewed by an administrator"))
201
-		chanMsg := fmt.Sprintf("Account %s requests vhost %s", accountName, vhost)
202
-		hsNotifyChannel(server, chanMsg)
203
-		server.snomasks.Send(sno.LocalVhosts, chanMsg)
204
-	}
205
-}
206
-
207 121
 func hsStatusHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
208 122
 	var accountName string
209 123
 	if len(params) > 0 {
@@ -237,13 +151,6 @@ func hsStatusHandler(server *Server, client *Client, command string, params []st
237 151
 	} else {
238 152
 		hsNotice(rb, fmt.Sprintf(client.t("Account %s has no vhost"), accountName))
239 153
 	}
240
-	if account.VHost.RequestedVHost != "" {
241
-		hsNotice(rb, fmt.Sprintf(client.t("A request is pending for vhost: %s"), account.VHost.RequestedVHost))
242
-	}
243
-	if account.VHost.RejectedVHost != "" {
244
-		hsNotice(rb, fmt.Sprintf(client.t("A request was previously made for vhost: %s"), account.VHost.RejectedVHost))
245
-		hsNotice(rb, fmt.Sprintf(client.t("It was rejected for reason: %s"), account.VHost.RejectionReason))
246
-	}
247 154
 }
248 155
 
249 156
 func validateVhost(server *Server, vhost string, oper bool) error {
@@ -251,7 +158,7 @@ func validateVhost(server *Server, vhost string, oper bool) error {
251 158
 	if len(vhost) > config.Accounts.VHosts.MaxLength {
252 159
 		return errVHostTooLong
253 160
 	}
254
-	if !config.Accounts.VHosts.ValidRegexp.MatchString(vhost) {
161
+	if !config.Accounts.VHosts.validRegexp.MatchString(vhost) {
255 162
 		return errVHostBadCharacters
256 163
 	}
257 164
 	return nil
@@ -280,56 +187,6 @@ func hsSetHandler(server *Server, client *Client, command string, params []strin
280 187
 	}
281 188
 }
282 189
 
283
-func hsWaitingHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
284
-	requests, total := server.accounts.VHostListRequests(10)
285
-	hsNotice(rb, fmt.Sprintf(client.t("There are %[1]d pending requests for vhosts (%[2]d displayed)"), total, len(requests)))
286
-	for i, request := range requests {
287
-		hsNotice(rb, fmt.Sprintf(client.t("%[1]d. User %[2]s requests vhost: %[3]s"), i+1, request.Account, request.RequestedVHost))
288
-	}
289
-}
290
-
291
-func hsApproveHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
292
-	user := params[0]
293
-
294
-	vhostInfo, err := server.accounts.VHostApprove(user)
295
-	if err != nil {
296
-		hsNotice(rb, client.t("An error occurred"))
297
-	} else {
298
-		hsNotice(rb, fmt.Sprintf(client.t("Successfully approved vhost request for %s"), user))
299
-		chanMsg := fmt.Sprintf("Oper %[1]s approved vhost %[2]s for account %[3]s", client.Nick(), vhostInfo.ApprovedVHost, user)
300
-		hsNotifyChannel(server, chanMsg)
301
-		server.snomasks.Send(sno.LocalVhosts, chanMsg)
302
-		for _, client := range server.accounts.AccountToClients(user) {
303
-			client.Send(nil, hsNickMask, "NOTICE", client.Nick(), client.t("Your vhost request was approved by an administrator"))
304
-		}
305
-	}
306
-}
307
-
308
-func hsRejectHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
309
-	var reason string
310
-	user := params[0]
311
-	if len(params) > 1 {
312
-		reason = params[1]
313
-	}
314
-
315
-	vhostInfo, err := server.accounts.VHostReject(user, reason)
316
-	if err != nil {
317
-		hsNotice(rb, client.t("An error occurred"))
318
-	} else {
319
-		hsNotice(rb, fmt.Sprintf(client.t("Successfully rejected vhost request for %s"), user))
320
-		chanMsg := fmt.Sprintf("Oper %s rejected vhost %s for account %s, with the reason: %v", client.Nick(), vhostInfo.RejectedVHost, user, reason)
321
-		hsNotifyChannel(server, chanMsg)
322
-		server.snomasks.Send(sno.LocalVhosts, chanMsg)
323
-		for _, client := range server.accounts.AccountToClients(user) {
324
-			if reason == "" {
325
-				client.Send(nil, hsNickMask, "NOTICE", client.Nick(), client.t("Your vhost request was rejected by an administrator"))
326
-			} else {
327
-				client.Send(nil, hsNickMask, "NOTICE", client.Nick(), fmt.Sprintf(client.t("Your vhost request was rejected by an administrator. The reason given was: %s"), reason))
328
-			}
329
-		}
330
-	}
331
-}
332
-
333 190
 func hsSetCloakSecretHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
334 191
 	secret := params[0]
335 192
 	expectedCode := utils.ConfirmationCode(secret, server.ctime)

+ 2
- 2
irc/import.go View File

@@ -69,8 +69,8 @@ func doImportDBGeneric(config *Config, dbImport databaseImport, credsType Creden
69 69
 	// produce a hardcoded version of the database schema
70 70
 	// XXX instead of referencing, e.g., keyAccountExists, we should write in the string literal
71 71
 	// (to ensure that no matter what code changes happen elsewhere, we're still producing a
72
-	// version 14 db)
73
-	tx.Set(keySchemaVersion, "14", nil)
72
+	// db of the hardcoded version)
73
+	tx.Set(keySchemaVersion, "17", nil)
74 74
 	tx.Set(keyCloakSecret, utils.GenerateSecretKey(), nil)
75 75
 
76 76
 	for username, userInfo := range dbImport.Users {

+ 0
- 3
irc/server.go View File

@@ -570,9 +570,6 @@ func (server *Server) applyConfig(config *Config) (err error) {
570 570
 		if !oldConfig.Accounts.NickReservation.Enabled {
571 571
 			server.accounts.buildNickToAccountIndex(config)
572 572
 		}
573
-		if !oldConfig.Accounts.VHosts.Enabled {
574
-			server.accounts.initVHostRequestQueue(config)
575
-		}
576 573
 		if !oldConfig.Channels.Registration.Enabled {
577 574
 			server.channels.loadRegisteredChannels(config)
578 575
 		}

Loading…
Cancel
Save