mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
oper: Support custom vhosts, and chghost
This commit is contained in:
parent
8e2a8cb1b3
commit
29e811a531
@ -11,6 +11,7 @@ New release of Oragono!
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
* Operator classes, allowing for more finely-grained permissions for operators.
|
* Operator classes, allowing for more finely-grained permissions for operators.
|
||||||
|
* Added support for IRCv3 capability [`chghost`](http://ircv3.net/specs/extensions/chghost-3.2.html).
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
* In the config file, "operator" changed to "opers", and new oper class is required.
|
* In the config file, "operator" changed to "opers", and new oper class is required.
|
||||||
|
@ -18,6 +18,7 @@ const (
|
|||||||
AccountNotify Capability = "account-notify"
|
AccountNotify Capability = "account-notify"
|
||||||
AwayNotify Capability = "away-notify"
|
AwayNotify Capability = "away-notify"
|
||||||
CapNotify Capability = "cap-notify"
|
CapNotify Capability = "cap-notify"
|
||||||
|
ChgHost Capability = "chghost"
|
||||||
EchoMessage Capability = "echo-message"
|
EchoMessage Capability = "echo-message"
|
||||||
ExtendedJoin Capability = "extended-join"
|
ExtendedJoin Capability = "extended-join"
|
||||||
InviteNotify Capability = "invite-notify"
|
InviteNotify Capability = "invite-notify"
|
||||||
@ -34,6 +35,7 @@ var (
|
|||||||
AccountNotify: true,
|
AccountNotify: true,
|
||||||
AwayNotify: true,
|
AwayNotify: true,
|
||||||
CapNotify: true,
|
CapNotify: true,
|
||||||
|
ChgHost: true,
|
||||||
EchoMessage: true,
|
EchoMessage: true,
|
||||||
ExtendedJoin: true,
|
ExtendedJoin: true,
|
||||||
InviteNotify: true,
|
InviteNotify: true,
|
||||||
|
@ -45,6 +45,8 @@ type Client struct {
|
|||||||
hasQuit bool
|
hasQuit bool
|
||||||
hops int
|
hops int
|
||||||
hostname string
|
hostname string
|
||||||
|
rawHostname string
|
||||||
|
vhost string
|
||||||
idleTimer *time.Timer
|
idleTimer *time.Timer
|
||||||
monitoring map[string]bool
|
monitoring map[string]bool
|
||||||
nick string
|
nick string
|
||||||
@ -136,7 +138,7 @@ func (client *Client) run() {
|
|||||||
var msg ircmsg.IrcMessage
|
var msg ircmsg.IrcMessage
|
||||||
|
|
||||||
// Set the hostname for this client
|
// Set the hostname for this client
|
||||||
client.hostname = AddrLookupHostname(client.socket.conn.RemoteAddr())
|
client.rawHostname = AddrLookupHostname(client.socket.conn.RemoteAddr())
|
||||||
|
|
||||||
//TODO(dan): Make this a socketreactor from ircbnc
|
//TODO(dan): Make this a socketreactor from ircbnc
|
||||||
for {
|
for {
|
||||||
@ -313,6 +315,12 @@ func (client *Client) updateNick() {
|
|||||||
func (client *Client) updateNickMask() {
|
func (client *Client) updateNickMask() {
|
||||||
client.updateNick()
|
client.updateNick()
|
||||||
|
|
||||||
|
if len(client.vhost) > 0 {
|
||||||
|
client.hostname = client.vhost
|
||||||
|
} else {
|
||||||
|
client.hostname = client.rawHostname
|
||||||
|
}
|
||||||
|
|
||||||
client.nickMaskString = fmt.Sprintf("%s!%s@%s", client.nick, client.username, client.hostname)
|
client.nickMaskString = fmt.Sprintf("%s!%s@%s", client.nick, client.username, client.hostname)
|
||||||
|
|
||||||
nickMaskCasefolded, err := Casefold(client.nickMaskString)
|
nickMaskCasefolded, err := Casefold(client.nickMaskString)
|
||||||
|
@ -209,6 +209,7 @@ func (conf *Config) OperatorClasses() (*map[string]OperClass, error) {
|
|||||||
type Oper struct {
|
type Oper struct {
|
||||||
Class *OperClass
|
Class *OperClass
|
||||||
WhoisLine string
|
WhoisLine string
|
||||||
|
Vhost string
|
||||||
Pass []byte
|
Pass []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,6 +225,7 @@ func (conf *Config) Operators(oc *map[string]OperClass) (map[string]Oper, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
oper.Pass = opConf.PasswordBytes()
|
oper.Pass = opConf.PasswordBytes()
|
||||||
|
oper.Vhost = opConf.Vhost
|
||||||
class, exists := (*oc)[opConf.Class]
|
class, exists := (*oc)[opConf.Class]
|
||||||
if !exists {
|
if !exists {
|
||||||
return nil, fmt.Errorf("Could not load operator [%s] - they use operclass [%s] which does not exist", name, opConf.Class)
|
return nil, fmt.Errorf("Could not load operator [%s] - they use operclass [%s] which does not exist", name, opConf.Class)
|
||||||
|
@ -904,7 +904,15 @@ func operHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
|||||||
server.currentOpers[client] = true
|
server.currentOpers[client] = true
|
||||||
client.whoisLine = server.operators[name].WhoisLine
|
client.whoisLine = server.operators[name].WhoisLine
|
||||||
|
|
||||||
//TODO(dan): push out CHGHOST if vhost is applied
|
// push new vhost if one is set
|
||||||
|
if len(server.operators[name].Vhost) > 0 {
|
||||||
|
originalHost := client.nickMaskString
|
||||||
|
client.vhost = server.operators[name].Vhost
|
||||||
|
for fClient := range client.Friends(ChgHost) {
|
||||||
|
fClient.SendFromClient(client, nil, originalHost, "CHGHOST", client.username, client.vhost)
|
||||||
|
}
|
||||||
|
client.updateNickMask()
|
||||||
|
}
|
||||||
|
|
||||||
client.Send(nil, server.name, RPL_YOUREOPER, client.nick, "You are now an IRC operator")
|
client.Send(nil, server.name, RPL_YOUREOPER, client.nick, "You are now an IRC operator")
|
||||||
//TODO(dan): Should this be sent automagically as part of setting the flag/mode?
|
//TODO(dan): Should this be sent automagically as part of setting the flag/mode?
|
||||||
|
Loading…
Reference in New Issue
Block a user