소스 검색

fix #1190

tags/v2.3.0-rc1
Shivaram Lingamneni 3 년 전
부모
커밋
32c58c1e1f
6개의 변경된 파일1개의 추가작업 그리고 174개의 파일을 삭제
  1. 0
    4
      conventional.yaml
  2. 0
    4
      default.yaml
  3. 1
    42
      irc/accounts.go
  4. 0
    7
      irc/config.go
  5. 0
    1
      irc/errors.go
  6. 0
    116
      irc/hostserv.go

+ 0
- 4
conventional.yaml 파일 보기

@@ -451,10 +451,6 @@ accounts:
451 451
             # before they can request a new one.
452 452
             cooldown: 168h
453 453
 
454
-        # vhosts that users can take without approval, using `/HS TAKE`
455
-        offer-list:
456
-            #- "oragono.test"
457
-
458 454
     # modes that are set by default when a user connects
459 455
     # if unset, no user modes will be set by default
460 456
     # +i is invisible (a user's channels are hidden from whois replies)

+ 0
- 4
default.yaml 파일 보기

@@ -477,10 +477,6 @@ accounts:
477 477
             # before they can request a new one.
478 478
             cooldown: 168h
479 479
 
480
-        # vhosts that users can take without approval, using `/HS TAKE`
481
-        offer-list:
482
-            #- "oragono.test"
483
-
484 480
     # modes that are set by default when a user connects
485 481
     # if unset, no user modes will be set by default
486 482
     # +i is invisible (a user's channels are hidden from whois replies)

+ 1
- 42
irc/accounts.go 파일 보기

@@ -1575,7 +1575,6 @@ func (am *AccountManager) ModifyAccountSettings(account string, munger settingsM
1575 1575
 type VHostInfo struct {
1576 1576
 	ApprovedVHost   string
1577 1577
 	Enabled         bool
1578
-	Forbidden       bool
1579 1578
 	RequestedVHost  string
1580 1579
 	RejectedVHost   string
1581 1580
 	RejectionReason string
@@ -1629,10 +1628,6 @@ func (am *AccountManager) VHostSet(account string, vhost string) (result VHostIn
1629 1628
 func (am *AccountManager) VHostRequest(account string, vhost string, cooldown time.Duration) (result VHostInfo, err error) {
1630 1629
 	munger := func(input VHostInfo) (output VHostInfo, err error) {
1631 1630
 		output = input
1632
-		if input.Forbidden {
1633
-			err = errVhostsForbidden
1634
-			return
1635
-		}
1636 1631
 		// you can update your existing request, but if you were approved or rejected,
1637 1632
 		// you can't spam a new request
1638 1633
 		if output.RequestedVHost == "" {
@@ -1651,32 +1646,6 @@ func (am *AccountManager) VHostRequest(account string, vhost string, cooldown ti
1651 1646
 	return am.performVHostChange(account, munger)
1652 1647
 }
1653 1648
 
1654
-func (am *AccountManager) VHostTake(account string, vhost string, cooldown time.Duration) (result VHostInfo, err error) {
1655
-	munger := func(input VHostInfo) (output VHostInfo, err error) {
1656
-		output = input
1657
-		if input.Forbidden {
1658
-			err = errVhostsForbidden
1659
-			return
1660
-		}
1661
-		// if you have a request pending, you can cancel it using take;
1662
-		// otherwise, you're subject to the same throttling as if you were making a request
1663
-		if output.RequestedVHost == "" {
1664
-			err = output.checkThrottle(cooldown)
1665
-		}
1666
-		if err != nil {
1667
-			return
1668
-		}
1669
-		output.ApprovedVHost = vhost
1670
-		output.RequestedVHost = ""
1671
-		output.RejectedVHost = ""
1672
-		output.RejectionReason = ""
1673
-		output.LastRequestTime = time.Now().UTC()
1674
-		return
1675
-	}
1676
-
1677
-	return am.performVHostChange(account, munger)
1678
-}
1679
-
1680 1649
 func (am *AccountManager) VHostApprove(account string) (result VHostInfo, err error) {
1681 1650
 	munger := func(input VHostInfo) (output VHostInfo, err error) {
1682 1651
 		output = input
@@ -1716,16 +1685,6 @@ func (am *AccountManager) VHostSetEnabled(client *Client, enabled bool) (result
1716 1685
 	return am.performVHostChange(client.Account(), munger)
1717 1686
 }
1718 1687
 
1719
-func (am *AccountManager) VHostForbid(account string, forbid bool) (result VHostInfo, err error) {
1720
-	munger := func(input VHostInfo) (output VHostInfo, err error) {
1721
-		output = input
1722
-		output.Forbidden = forbid
1723
-		return
1724
-	}
1725
-
1726
-	return am.performVHostChange(account, munger)
1727
-}
1728
-
1729 1688
 func (am *AccountManager) performVHostChange(account string, munger vhostMunger) (result VHostInfo, err error) {
1730 1689
 	account, err = CasefoldName(account)
1731 1690
 	if err != nil || account == "" {
@@ -1846,7 +1805,7 @@ func (am *AccountManager) applyVHostInfo(client *Client, info VHostInfo) {
1846 1805
 	}
1847 1806
 
1848 1807
 	vhost := ""
1849
-	if info.Enabled && !info.Forbidden {
1808
+	if info.Enabled {
1850 1809
 		vhost = info.ApprovedVHost
1851 1810
 	}
1852 1811
 	oldNickmask := client.NickMaskString()

+ 0
- 7
irc/config.go 파일 보기

@@ -315,7 +315,6 @@ type VHostConfig struct {
315 315
 		Channel  string
316 316
 		Cooldown custime.Duration
317 317
 	} `yaml:"user-requests"`
318
-	OfferList []string `yaml:"offer-list"`
319 318
 }
320 319
 
321 320
 type NickEnforcementMethod int
@@ -1086,12 +1085,6 @@ func LoadConfig(filename string) (config *Config, err error) {
1086 1085
 		config.Accounts.VHosts.ValidRegexp = defaultValidVhostRegex
1087 1086
 	}
1088 1087
 
1089
-	for _, vhost := range config.Accounts.VHosts.OfferList {
1090
-		if !config.Accounts.VHosts.ValidRegexp.MatchString(vhost) {
1091
-			return nil, fmt.Errorf("invalid offered vhost: %s", vhost)
1092
-		}
1093
-	}
1094
-
1095 1088
 	config.Server.capValues[caps.SASL] = "PLAIN,EXTERNAL"
1096 1089
 	if !config.Accounts.AuthenticationEnabled {
1097 1090
 		config.Server.supportedCaps.Disable(caps.SASL)

+ 0
- 1
irc/errors.go 파일 보기

@@ -58,7 +58,6 @@ var (
58 58
 	errBanned                         = errors.New("IP or nickmask banned")
59 59
 	errInvalidParams                  = utils.ErrInvalidParams
60 60
 	errNoVhost                        = errors.New(`You do not have an approved vhost`)
61
-	errVhostsForbidden                = errors.New(`An administrator has denied you the ability to use vhosts`)
62 61
 	errLimitExceeded                  = errors.New("Limit exceeded")
63 62
 	errNoop                           = errors.New("Action was a no-op")
64 63
 	errCASFailed                      = errors.New("Compare-and-swap update of database value failed")

+ 0
- 116
irc/hostserv.go 파일 보기

@@ -129,51 +129,6 @@ for the rejection.`,
129 129
 			maxParams:         2,
130 130
 			unsplitFinalParam: true,
131 131
 		},
132
-		"forbid": {
133
-			handler: hsForbidHandler,
134
-			help: `Syntax: $bFORBID <user>$b
135
-
136
-FORBID prevents a user from using any vhost, including ones on the offer list.`,
137
-			helpShort: `$bFORBID$b prevents a user from using vhosts.`,
138
-			capabs:    []string{"vhosts"},
139
-			enabled:   hostservEnabled,
140
-			minParams: 1,
141
-			maxParams: 1,
142
-		},
143
-		"permit": {
144
-			handler: hsForbidHandler,
145
-			help: `Syntax: $bPERMIT <user>$b
146
-
147
-PERMIT undoes FORBID, allowing the user to TAKE vhosts again.`,
148
-			helpShort: `$bPERMIT$b allows a user to use vhosts again.`,
149
-			capabs:    []string{"vhosts"},
150
-			enabled:   hostservEnabled,
151
-			minParams: 1,
152
-			maxParams: 1,
153
-		},
154
-		"offerlist": {
155
-			handler: hsOfferListHandler,
156
-			help: `Syntax: $bOFFERLIST$b
157
-
158
-OFFERLIST lists vhosts that can be chosen without requiring operator approval;
159
-to use one of the listed vhosts, take it with /HOSTSERV TAKE.`,
160
-			helpShort: `$bOFFERLIST$b lists vhosts that can be taken without operator approval.`,
161
-			enabled:   hostservEnabled,
162
-			minParams: 0,
163
-			maxParams: 0,
164
-		},
165
-		"take": {
166
-			handler: hsTakeHandler,
167
-			help: `Syntax: $bTAKE$b <vhost>
168
-
169
-TAKE sets your vhost to one of the vhosts in the server's offer list; to see
170
-the offered vhosts, use /HOSTSERV OFFERLIST.`,
171
-			helpShort:    `$bTAKE$b sets your vhost to one of the options from the offer list.`,
172
-			enabled:      hostservEnabled,
173
-			authRequired: true,
174
-			minParams:    1,
175
-			maxParams:    1,
176
-		},
177 132
 		"setcloaksecret": {
178 133
 			handler: hsSetCloakSecretHandler,
179 134
 			help: `Syntax: $bSETCLOAKSECRET$b <secret> [code]
@@ -238,8 +193,6 @@ func hsRequestHandler(server *Server, client *Client, command string, params []s
238 193
 	if err != nil {
239 194
 		if throttled, ok := err.(*vhostThrottleExceeded); ok {
240 195
 			hsNotice(rb, fmt.Sprintf(client.t("You must wait an additional %v before making another request"), throttled.timeRemaining))
241
-		} else if err == errVhostsForbidden {
242
-			hsNotice(rb, client.t("An administrator has denied you the ability to use vhosts"))
243 196
 		} else {
244 197
 			hsNotice(rb, client.t("An error occurred"))
245 198
 		}
@@ -276,11 +229,6 @@ func hsStatusHandler(server *Server, client *Client, command string, params []st
276 229
 		return
277 230
 	}
278 231
 
279
-	if account.VHost.Forbidden {
280
-		hsNotice(rb, client.t("An administrator has denied you the ability to use vhosts"))
281
-		return
282
-	}
283
-
284 232
 	if account.VHost.ApprovedVHost != "" {
285 233
 		hsNotice(rb, fmt.Sprintf(client.t("Account %[1]s has vhost: %[2]s"), accountName, account.VHost.ApprovedVHost))
286 234
 		if !account.VHost.Enabled {
@@ -382,70 +330,6 @@ func hsRejectHandler(server *Server, client *Client, command string, params []st
382 330
 	}
383 331
 }
384 332
 
385
-func hsForbidHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
386
-	user := params[0]
387
-	forbidden := command == "forbid"
388
-
389
-	_, err := server.accounts.VHostForbid(user, forbidden)
390
-	if err == errAccountDoesNotExist {
391
-		hsNotice(rb, client.t("No such account"))
392
-	} else if err != nil {
393
-		hsNotice(rb, client.t("An error occurred"))
394
-	} else {
395
-		if forbidden {
396
-			hsNotice(rb, fmt.Sprintf(client.t("User %s is no longer allowed to use vhosts"), user))
397
-		} else {
398
-			hsNotice(rb, fmt.Sprintf(client.t("User %s is now allowed to use vhosts"), user))
399
-		}
400
-	}
401
-}
402
-
403
-func hsOfferListHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
404
-	vhostConfig := server.Config().Accounts.VHosts
405
-	if len(vhostConfig.OfferList) == 0 {
406
-		if vhostConfig.UserRequests.Enabled {
407
-			hsNotice(rb, client.t("The server does not offer any vhosts, but you can request one with /HOSTSERV REQUEST"))
408
-		} else {
409
-			hsNotice(rb, client.t("The server does not offer any vhosts"))
410
-		}
411
-	} else {
412
-		hsNotice(rb, client.t("The following vhosts are available and can be chosen with /HOSTSERV TAKE:"))
413
-		for _, vhost := range vhostConfig.OfferList {
414
-			hsNotice(rb, vhost)
415
-		}
416
-	}
417
-}
418
-
419
-func hsTakeHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
420
-	config := server.Config()
421
-	vhost := params[0]
422
-	found := false
423
-	for _, offered := range config.Accounts.VHosts.OfferList {
424
-		if offered == vhost {
425
-			found = true
426
-		}
427
-	}
428
-	if !found {
429
-		hsNotice(rb, client.t("That vhost isn't being offered by the server"))
430
-		return
431
-	}
432
-
433
-	account := client.Account()
434
-	_, err := server.accounts.VHostTake(account, vhost, time.Duration(config.Accounts.VHosts.UserRequests.Cooldown))
435
-	if err != nil {
436
-		if throttled, ok := err.(*vhostThrottleExceeded); ok {
437
-			hsNotice(rb, fmt.Sprintf(client.t("You must wait an additional %v before taking a vhost"), throttled.timeRemaining))
438
-		} else if err == errVhostsForbidden {
439
-			hsNotice(rb, client.t("An administrator has denied you the ability to use vhosts"))
440
-		} else {
441
-			hsNotice(rb, client.t("An error occurred"))
442
-		}
443
-	} else {
444
-		hsNotice(rb, client.t("Successfully set vhost"))
445
-		server.snomasks.Send(sno.LocalVhosts, fmt.Sprintf("Client %s (account %s) took vhost %s", client.Nick(), account, vhost))
446
-	}
447
-}
448
-
449 333
 func hsSetCloakSecretHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
450 334
 	secret := params[0]
451 335
 	expectedCode := utils.ConfirmationCode(secret, server.ctime)

Loading…
취소
저장