From 84864d5dc96e831851c1c6f17b5e82d0cf60dcf5 Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Tue, 1 May 2018 23:02:28 -0400 Subject: [PATCH 01/24] if block ends with a return statement drop this else and outdent its block trying out some lint drive refactoring with golint :D --- network/net_gateway.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/network/net_gateway.go b/network/net_gateway.go index 4a47698b..0db60274 100644 --- a/network/net_gateway.go +++ b/network/net_gateway.go @@ -20,14 +20,13 @@ func FindGateway(iface *Endpoint) (*Endpoint, error) { return IPv4RouteIsGateway(iface.Name(), m, func(gateway string) (*Endpoint, error) { if gateway == iface.IpAddress { return iface, nil - } else { - // we have the address, now we need its mac - mac, err := ArpLookup(iface.Name(), gateway, false) - if err != nil { - return nil, err - } - return NewEndpoint(gateway, mac), nil } + // we have the address, now we need its mac + mac, err := ArpLookup(iface.Name(), gateway, false) + if err != nil { + return nil, err + } + return NewEndpoint(gateway, mac), nil }) } } From 8193834f0f63c088f0d00a4d8f4c4538a3627ad9 Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Tue, 1 May 2018 23:05:26 -0400 Subject: [PATCH 02/24] if block ends with a return statement drop this else and outdent its block --- core/core.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/core.go b/core/core.go index dd7ee469..d013d270 100644 --- a/core/core.go +++ b/core/core.go @@ -92,10 +92,9 @@ func ExpandPath(path string) (string, error) { if strings.HasPrefix(path, "~") { if usr, err := user.Current(); err != nil { return "", err - } else { - // Replace only the first occurrence of ~ - path = strings.Replace(path, "~", usr.HomeDir, 1) } + // Replace only the first occurrence of ~ + path = strings.Replace(path, "~", usr.HomeDir, 1) } return filepath.Abs(path) } From ea4301814679c008abd6da3fe63824e627706e18 Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Tue, 1 May 2018 23:06:11 -0400 Subject: [PATCH 03/24] if block ends with a return statement drop this else and outdent its block --- core/core.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/core.go b/core/core.go index d013d270..072ae821 100644 --- a/core/core.go +++ b/core/core.go @@ -66,9 +66,8 @@ func ExecSilent(executable string, args []string) (string, error) { raw, err := exec.Command(path, args...).CombinedOutput() if err != nil { return "", err - } else { - return Trim(string(raw)), nil } + return Trim(string(raw)), nil } func Exec(executable string, args []string) (string, error) { From e02e13ab63b5fc37b96284e8bd55a30e855d2db3 Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Tue, 1 May 2018 23:06:58 -0400 Subject: [PATCH 04/24] if block ends with a return statement drop this else and outdent its block --- firewall/firewall_darwin.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/firewall/firewall_darwin.go b/firewall/firewall_darwin.go index d328a0fb..287779b2 100644 --- a/firewall/firewall_darwin.go +++ b/firewall/firewall_darwin.go @@ -85,9 +85,8 @@ func (f PfFirewall) enableParam(param string, enabled bool) error { if _, err := f.sysCtlWrite(param, value); err != nil { return err - } else { - return nil } + return nil } func (f PfFirewall) EnableForwarding(enabled bool) error { From 2522b890695c6bae167b71e3bfea347b44c5e396 Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Tue, 1 May 2018 23:08:11 -0400 Subject: [PATCH 05/24] if block ends with a return statement drop this else and outdent its block --- modules/wifi_show.go | 46 ++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/modules/wifi_show.go b/modules/wifi_show.go index d977d2f8..c84ecc16 100644 --- a/modules/wifi_show.go +++ b/modules/wifi_show.go @@ -83,30 +83,30 @@ func (w *WiFiModule) getRow(station *network.Station) ([]string, bool) { recvd, seen, }, include - } else { - // this is ugly, but necessary in order to have this - // method handle both access point and clients - // transparently - clients := "" - if ap, found := w.Session.WiFi.Get(station.HwAddress); found { - if ap.NumClients() > 0 { - clients = strconv.Itoa(ap.NumClients()) - } - } - - return []string{ - fmt.Sprintf("%d dBm", station.RSSI), - bssid, - ssid, - /* station.Vendor, */ - encryption, - strconv.Itoa(network.Dot11Freq2Chan(station.Frequency)), - clients, - sent, - recvd, - seen, - }, include } + + // this is ugly, but necessary in order to have this + // method handle both access point and clients + // transparently + clients := "" + if ap, found := w.Session.WiFi.Get(station.HwAddress); found { + if ap.NumClients() > 0 { + clients = strconv.Itoa(ap.NumClients()) + } + } + + return []string{ + fmt.Sprintf("%d dBm", station.RSSI), + bssid, + ssid, + /* station.Vendor, */ + encryption, + strconv.Itoa(network.Dot11Freq2Chan(station.Frequency)), + clients, + sent, + recvd, + seen, + }, include } func (w *WiFiModule) Show(by string) error { From f0408bc5142d1885369b058c40086fab08568338 Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Tue, 1 May 2018 23:09:09 -0400 Subject: [PATCH 06/24] if block ends with a return statement drop this else and outdent its block --- modules/wifi.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/wifi.go b/modules/wifi.go index ada4f99a..031352b9 100644 --- a/modules/wifi.go +++ b/modules/wifi.go @@ -101,9 +101,8 @@ func NewWiFiModule(s *session.Session) *WiFiModule { func(args []string) error { if err := w.parseApConfig(); err != nil { return err - } else { - return w.startAp() } + return w.startAp() })) w.AddParam(session.NewStringParameter("wifi.ap.ssid", From db18057fce80f1e07d1b573560e12654d67ee8b6 Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Tue, 1 May 2018 23:10:49 -0400 Subject: [PATCH 07/24] if block ends with a return statement drop this else and outdent its block --- modules/wifi.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/wifi.go b/modules/wifi.go index 031352b9..27f32eab 100644 --- a/modules/wifi.go +++ b/modules/wifi.go @@ -148,9 +148,8 @@ func NewWiFiModule(s *session.Session) *WiFiModule { // No channels setted, retrieve frequencies supported by the card if frequencies, err := network.GetSupportedFrequencies(w.Session.Interface.Name()); err != nil { return err - } else { - newfrequencies = frequencies } + newfrequencies = frequencies } w.frequencies = newfrequencies From 7996fc40ff1fede03eb07365a13a91e45f8fd1ed Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Tue, 1 May 2018 23:10:55 -0400 Subject: [PATCH 08/24] if block ends with a return statement drop this else and outdent its block --- modules/wol.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/wol.go b/modules/wol.go index 54be2419..881b576b 100644 --- a/modules/wol.go +++ b/modules/wol.go @@ -31,9 +31,8 @@ func NewWOL(s *session.Session) *WOL { func(args []string) error { if mac, err := parseMAC(args); err != nil { return err - } else { - return w.wolETH(mac) } + return w.wolETH(mac) })) w.AddHandler(session.NewModuleHandler("wol.udp MAC", "wol.udp(\\s.+)?", From 024f978c3a6615f5a4310e3f59aedbecf8d75501 Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Tue, 1 May 2018 23:13:16 -0400 Subject: [PATCH 09/24] golint says don't use underscores in Go names; var from_hw should be fromHw --- modules/utils.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/utils.go b/modules/utils.go index 06bb6eb8..341408ea 100644 --- a/modules/utils.go +++ b/modules/utils.go @@ -20,9 +20,9 @@ func findMAC(s *session.Session, ip net.IP, probe bool) (net.HardwareAddr, error mac, err = network.ArpLookup(s.Interface.Name(), ip.String(), false) if err != nil && probe { from := s.Interface.IP - from_hw := s.Interface.HW + fromHw := s.Interface.HW - if err, probe := packets.NewUDPProbe(from, from_hw, ip, 139); err != nil { + if err, probe := packets.NewUDPProbe(from, fromHw, ip, 139); err != nil { log.Error("Error while creating UDP probe packet for %s: %s", ip.String(), err) } else { s.Queue.Send(probe) From d65bee06ce92338327d4693e4ccd9baaf8127e9e Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Tue, 1 May 2018 23:13:33 -0400 Subject: [PATCH 10/24] if block ends with a return statement drop this else and outdent its block --- modules/wol.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/wol.go b/modules/wol.go index 881b576b..31719ae5 100644 --- a/modules/wol.go +++ b/modules/wol.go @@ -40,9 +40,8 @@ func NewWOL(s *session.Session) *WOL { func(args []string) error { if mac, err := parseMAC(args); err != nil { return err - } else { - return w.wolUDP(mac) } + return w.wolUDP(mac) })) return w @@ -55,9 +54,8 @@ func parseMAC(args []string) (string, error) { if tmp != "" { if !reMAC.MatchString(tmp) { return "", fmt.Errorf("%s is not a valid MAC address.", tmp) - } else { - mac = tmp } + mac = tmp } } From 9505a149ce1a052aaa5ba43c381d64474f922d98 Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Tue, 1 May 2018 23:15:05 -0400 Subject: [PATCH 11/24] if block ends with a return statement drop this else and outdent its block --- modules/dns_spoof.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/dns_spoof.go b/modules/dns_spoof.go index e75a31bc..0f1ea6b3 100644 --- a/modules/dns_spoof.go +++ b/modules/dns_spoof.go @@ -107,9 +107,8 @@ func (s *DNSSpoofer) Configure() error { for _, domain := range domains { if expr, err := glob.Compile(domain); err != nil { return fmt.Errorf("'%s' is not a valid domain glob expression: %s", domain, err) - } else { - s.Domains = append(s.Domains, expr) } + s.Domains = append(s.Domains, expr) } if err, addr = s.StringParam("dns.spoof.address"); err != nil { From 3f8226ff67abec9d53ea7131cc70c3693deee721 Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Tue, 1 May 2018 23:21:42 -0400 Subject: [PATCH 12/24] if block ends with a return statement drop this else and outdent its block --- modules/events_stream.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/events_stream.go b/modules/events_stream.go index 6c5597f8..a716e4cd 100644 --- a/modules/events_stream.go +++ b/modules/events_stream.go @@ -210,9 +210,8 @@ func (s *EventsStream) startWaitingFor(tag string, timeout int) error { if event == nil { return fmt.Errorf("'events.waitFor %s %d' timed out.", tag, timeout) - } else { - log.Debug("Got event: %v", event) } + log.Debug("Got event: %v", event) return nil } From aee47df0a696b21dba53efa6fcd824b9a6c3d57e Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Tue, 1 May 2018 23:21:46 -0400 Subject: [PATCH 13/24] if block ends with a return statement drop this else and outdent its block --- modules/gps.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/gps.go b/modules/gps.go index 50ee1ed0..7994f0e2 100644 --- a/modules/gps.go +++ b/modules/gps.go @@ -98,9 +98,8 @@ func (gps *GPS) readLine() (line string, err error) { } else if n == 1 { if b[0] == '\n' { return core.Trim(line), nil - } else { - line += string(b[0]) } + line += string(b[0]) } } } From 069ad23282f4e587a423af2ef05bdd635fc22b95 Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Tue, 1 May 2018 23:21:49 -0400 Subject: [PATCH 14/24] if block ends with a return statement drop this else and outdent its block --- modules/http_proxy_base_cookietracker.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/http_proxy_base_cookietracker.go b/modules/http_proxy_base_cookietracker.go index d60f7802..9804b718 100644 --- a/modules/http_proxy_base_cookietracker.go +++ b/modules/http_proxy_base_cookietracker.go @@ -27,9 +27,8 @@ func (t *CookieTracker) domainOf(req *http.Request) string { if parsed, err := tld.Parse(req.Host); err != nil { log.Warning("Could not parse host %s: %s", req.Host, err) return req.Host - } else { - return fmt.Sprintf("%s.%s", parsed.Domain, parsed.TLD) } + return fmt.Sprintf("%s.%s", parsed.Domain, parsed.TLD) } func (t *CookieTracker) keyOf(req *http.Request) string { From 343ad54b9ad40252e7ff6073714462d878945380 Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Tue, 1 May 2018 23:21:52 -0400 Subject: [PATCH 15/24] if block ends with a return statement drop this else and outdent its block --- modules/http_proxy_base_sslstriper.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/http_proxy_base_sslstriper.go b/modules/http_proxy_base_sslstriper.go index 5d2142ae..412d4694 100644 --- a/modules/http_proxy_base_sslstriper.go +++ b/modules/http_proxy_base_sslstriper.go @@ -304,10 +304,9 @@ func (s *SSLStripper) isMaxRedirs(hostname string) bool { // reset delete(s.redirs, hostname) return true - } else { - // increment - s.redirs[hostname]++ } + // increment + s.redirs[hostname]++ } else { // start tracking redirections s.redirs[hostname] = 1 From 55614a7f284df04d89bc27d0c46cc62c9b91eb76 Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Tue, 1 May 2018 23:21:54 -0400 Subject: [PATCH 16/24] if block ends with a return statement drop this else and outdent its block --- modules/http_proxy_base.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/http_proxy_base.go b/modules/http_proxy_base.go index 38ba658f..600f0ead 100644 --- a/modules/http_proxy_base.go +++ b/modules/http_proxy_base.go @@ -115,9 +115,8 @@ func (p *HTTPProxy) Configure(address string, proxyPort int, httpPort int, scrip if scriptPath != "" { if err, p.Script = LoadHttpProxyScript(scriptPath, p.sess); err != nil { return err - } else { - log.Debug("Proxy script %s loaded.", scriptPath) } + log.Debug("Proxy script %s loaded.", scriptPath) } p.Server = &http.Server{ @@ -336,9 +335,9 @@ func (p *HTTPProxy) Stop() error { p.isRunning = false p.sniListener.Close() return nil - } else { - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) - defer cancel() - return p.Server.Shutdown(ctx) } + + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + return p.Server.Shutdown(ctx) } From c2db4b0d676486a0757e9ddd3b2fbf1dd252622a Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Tue, 1 May 2018 23:22:06 -0400 Subject: [PATCH 17/24] if block ends with a return statement drop this else and outdent its block --- modules/net_probe.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/net_probe.go b/modules/net_probe.go index 334b26fc..64784810 100644 --- a/modules/net_probe.go +++ b/modules/net_probe.go @@ -71,9 +71,8 @@ func (p *Prober) Configure() error { var err error if err, p.throttle = p.IntParam("net.probe.throttle"); err != nil { return err - } else { - log.Debug("Throttling packets of %d ms.", p.throttle) } + log.Debug("Throttling packets of %d ms.", p.throttle) return nil } From 5619127f93594c6d4bffddae603935c5facb883b Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Tue, 1 May 2018 23:22:10 -0400 Subject: [PATCH 18/24] if block ends with a return statement drop this else and outdent its block --- modules/tcp_proxy.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/tcp_proxy.go b/modules/tcp_proxy.go index d3be611a..18f2b664 100644 --- a/modules/tcp_proxy.go +++ b/modules/tcp_proxy.go @@ -124,9 +124,8 @@ func (p *TcpProxy) Configure() error { if scriptPath != "" { if err, p.script = LoadTcpProxyScript(scriptPath, p.Session); err != nil { return err - } else { - log.Debug("TCP proxy script %s loaded.", scriptPath) } + log.Debug("TCP proxy script %s loaded.", scriptPath) } if !p.Session.Firewall.IsForwardingEnabled() { From c6bbbca93f6c553f96757cf61a37604bf9b42adf Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Tue, 1 May 2018 23:22:13 -0400 Subject: [PATCH 19/24] if block ends with a return statement drop this else and outdent its block --- packets/dhcp6.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packets/dhcp6.go b/packets/dhcp6.go index 01056597..39e4d3eb 100644 --- a/packets/dhcp6.go +++ b/packets/dhcp6.go @@ -40,9 +40,8 @@ func DHCP6For(what dhcp6.MessageType, to dhcp6.Packet, duid []byte) (err error, var rawCID []byte if raw, found := to.Options[dhcp6.OptionClientID]; !found || len(raw) < 1 { return ErrNoCID, p - } else { - rawCID = raw[0] } + rawCID = raw[0] p.Options.AddRaw(dhcp6.OptionClientID, rawCID) p.Options.AddRaw(dhcp6.OptionServerID, duid) From 6a69369491e3b8661595df479003a3d5839c7129 Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Tue, 1 May 2018 23:22:16 -0400 Subject: [PATCH 20/24] if block ends with a return statement drop this else and outdent its block --- packets/queue.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packets/queue.go b/packets/queue.go index d76ae69d..8b21fe0a 100644 --- a/packets/queue.go +++ b/packets/queue.go @@ -217,9 +217,8 @@ func (q *Queue) Send(raw []byte) error { if err := q.handle.WritePacketData(raw); err != nil { q.TrackError() return err - } else { - q.TrackSent(uint64(len(raw))) } + q.TrackSent(uint64(len(raw))) return nil } From f128d3a035953eaeaaa82893e30963433d7c2130 Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Tue, 1 May 2018 23:22:19 -0400 Subject: [PATCH 21/24] if block ends with a return statement drop this else and outdent its block --- session/command_handler.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/session/command_handler.go b/session/command_handler.go index e7efad17..677238d4 100644 --- a/session/command_handler.go +++ b/session/command_handler.go @@ -27,7 +27,6 @@ func (h *CommandHandler) Parse(line string) (bool, []string) { result := h.Parser.FindStringSubmatch(line) if len(result) == h.Parser.NumSubexp()+1 { return true, result[1:] - } else { - return false, nil } + return false, nil } From bfdd7db0184eb1e173b2dde2c9efdf473b713398 Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Tue, 1 May 2018 23:22:21 -0400 Subject: [PATCH 22/24] if block ends with a return statement drop this else and outdent its block --- session/environment.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/session/environment.go b/session/environment.go index a47496bd..e71cae7a 100644 --- a/session/environment.go +++ b/session/environment.go @@ -114,9 +114,8 @@ func (env *Environment) GetInt(name string) (error, int) { if found, value := env.Get(name); found { if i, err := strconv.Atoi(value); err == nil { return nil, i - } else { - return err, 0 } + return err, 0 } return fmt.Errorf("Not found."), 0 From f09125b1665dadc6ff5f962afaacf465c6d54ffd Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Tue, 1 May 2018 23:22:26 -0400 Subject: [PATCH 23/24] if block ends with a return statement drop this else and outdent its block --- session/module.go | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/session/module.go b/session/module.go index 3d17995c..210d49a0 100644 --- a/session/module.go +++ b/session/module.go @@ -62,13 +62,12 @@ func (m SessionModule) ListParam(name string) (err error, values []string) { list := "" if err, list = m.StringParam(name); err != nil { return - } else { - parts := strings.Split(list, ",") - for _, part := range parts { - part = core.Trim(part) - if part != "" { - values = append(values, part) - } + } + parts := strings.Split(list, ",") + for _, part := range parts { + part = core.Trim(part) + if part != "" { + values = append(values, part) } } return @@ -78,33 +77,27 @@ func (m SessionModule) StringParam(name string) (error, string) { if p, found := m.params[name]; found { if err, v := p.Get(m.Session); err != nil { return err, "" - } else { - return nil, v.(string) } - } else { - return fmt.Errorf("Parameter %s does not exist.", name), "" + return nil, v.(string) } + return fmt.Errorf("Parameter %s does not exist.", name), "" } func (m SessionModule) IntParam(name string) (error, int) { if p, found := m.params[name]; found { if err, v := p.Get(m.Session); err != nil { return err, 0 - } else { - return nil, v.(int) } - - } else { - return fmt.Errorf("Parameter %s does not exist.", name), 0 + return nil, v.(int) } + return fmt.Errorf("Parameter %s does not exist.", name), 0 } func (m SessionModule) BoolParam(name string) (error, bool) { if err, v := m.params[name].Get(m.Session); err != nil { return err, false - } else { - return nil, v.(bool) } + return nil, v.(bool) } func (m *SessionModule) AddHandler(h ModuleHandler) { @@ -127,9 +120,8 @@ func (m *SessionModule) SetRunning(running bool, cb func()) error { if running == m.Running() { if m.Started { return ErrAlreadyStarted - } else { - return ErrAlreadyStopped } + return ErrAlreadyStopped } m.StatusLock.Lock() From ca42274656feba4c384a502dd6fe622f104eb092 Mon Sep 17 00:00:00 2001 From: Kent Gruber Date: Tue, 1 May 2018 23:22:29 -0400 Subject: [PATCH 24/24] if block ends with a return statement drop this else and outdent its block --- session/session_core_handlers.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/session/session_core_handlers.go b/session/session_core_handlers.go index 05c281a8..d9f05279 100644 --- a/session/session_core_handlers.go +++ b/session/session_core_handlers.go @@ -148,9 +148,8 @@ func (s *Session) sleepHandler(args []string, sess *Session) error { if secs, err := strconv.Atoi(args[0]); err == nil { time.Sleep(time.Duration(secs) * time.Second) return nil - } else { - return err } + return err } func (s *Session) getHandler(args []string, sess *Session) error { @@ -257,9 +256,8 @@ func (s *Session) aliasHandler(args []string, sess *Session) error { if s.Lan.SetAliasFor(mac, alias) { return nil - } else { - return fmt.Errorf("Could not find endpoint %s", mac) } + return fmt.Errorf("Could not find endpoint %s", mac) } func (s *Session) addHandler(h CommandHandler, c *readline.PrefixCompleter) {