Remove unused user.getChannel, move getUpstream to user
This commit is contained in:
parent
88cc4c41f1
commit
03c546e8bf
@ -321,7 +321,7 @@ func (dc *downstreamConn) register() error {
|
||||
}
|
||||
|
||||
if network != "" {
|
||||
dc.upstream = dc.srv.getUpstream(network)
|
||||
dc.upstream = dc.user.getUpstream(network)
|
||||
if dc.upstream == nil {
|
||||
dc.logger.Printf("failed registration: unknown upstream %q", network)
|
||||
dc.SendMessage(&irc.Message{
|
||||
|
37
server.go
37
server.go
@ -82,31 +82,13 @@ func (u *user) forEachDownstream(f func(dc *downstreamConn)) {
|
||||
u.lock.Unlock()
|
||||
}
|
||||
|
||||
func (u *user) getChannel(name string, upstream *Upstream) (*upstreamChannel, error) {
|
||||
var channel *upstreamChannel
|
||||
var err error
|
||||
u.forEachUpstream(func(uc *upstreamConn) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if upstream != nil && uc.upstream != upstream {
|
||||
return
|
||||
}
|
||||
if ch, ok := uc.channels[name]; ok {
|
||||
if channel != nil {
|
||||
err = fmt.Errorf("ambiguous channel name %q", name)
|
||||
} else {
|
||||
channel = ch
|
||||
func (u *user) getUpstream(name string) *Upstream {
|
||||
for i, upstream := range u.srv.Upstreams {
|
||||
if upstream.Addr == name {
|
||||
return &u.srv.Upstreams[i]
|
||||
}
|
||||
}
|
||||
})
|
||||
if channel == nil {
|
||||
return nil, ircError{&irc.Message{
|
||||
Command: irc.ERR_NOSUCHCHANNEL,
|
||||
Params: []string{name, "No such channel"},
|
||||
}}
|
||||
}
|
||||
return channel, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
type Upstream struct {
|
||||
@ -199,15 +181,6 @@ func (s *Server) getUser(name string) *user {
|
||||
return u
|
||||
}
|
||||
|
||||
func (s *Server) getUpstream(name string) *Upstream {
|
||||
for i, upstream := range s.Upstreams {
|
||||
if upstream.Addr == name {
|
||||
return &s.Upstreams[i]
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Server) Serve(ln net.Listener) error {
|
||||
for {
|
||||
netConn, err := ln.Accept()
|
||||
|
Loading…
Reference in New Issue
Block a user