mirror of
https://github.com/danderson/netboot.git
synced 2025-08-07 07:07:17 +02:00
Clean up more lint errors.
Also remove the 'vetshadow' linter, it's overly noisy on normal code.
This commit is contained in:
parent
31095fd432
commit
99cc04c381
2
Makefile
2
Makefile
@ -31,7 +31,7 @@ ci-test:
|
|||||||
ci-lint:
|
ci-lint:
|
||||||
$(GOCMD) get -u github.com/alecthomas/gometalinter
|
$(GOCMD) get -u github.com/alecthomas/gometalinter
|
||||||
gometalinter --install golint
|
gometalinter --install golint
|
||||||
gometalinter --deadline=1m --disable-all --enable=gofmt --enable=golint --enable=vet --enable=vetshadow --enable=structcheck --enable=unconvert --vendor ./...
|
gometalinter --deadline=1m --disable-all --enable=gofmt --enable=golint --enable=vet --enable=structcheck --enable=unconvert --vendor ./...
|
||||||
|
|
||||||
.PHONY: update-ipxe
|
.PHONY: update-ipxe
|
||||||
update-ipxe:
|
update-ipxe:
|
||||||
|
@ -102,14 +102,14 @@ func (s *staticBooter) ReadBootFile(id ID) (io.ReadCloser, int64, error) {
|
|||||||
return s.serveFile(s.kernel)
|
return s.serveFile(s.kernel)
|
||||||
|
|
||||||
case strings.HasPrefix(path, "initrd-"):
|
case strings.HasPrefix(path, "initrd-"):
|
||||||
i, err := strconv.Atoi(string(path[7:]))
|
i, err := strconv.Atoi(path[7:])
|
||||||
if err != nil || i < 0 || i >= len(s.initrd) {
|
if err != nil || i < 0 || i >= len(s.initrd) {
|
||||||
return nil, -1, fmt.Errorf("no file with ID %q", id)
|
return nil, -1, fmt.Errorf("no file with ID %q", id)
|
||||||
}
|
}
|
||||||
return s.serveFile(s.initrd[i])
|
return s.serveFile(s.initrd[i])
|
||||||
|
|
||||||
case strings.HasPrefix(path, "other-"):
|
case strings.HasPrefix(path, "other-"):
|
||||||
i, err := strconv.Atoi(string(path[6:]))
|
i, err := strconv.Atoi(path[6:])
|
||||||
if err != nil || i < 0 || i >= len(s.otherIDs) {
|
if err != nil || i < 0 || i >= len(s.otherIDs) {
|
||||||
return nil, -1, fmt.Errorf("no file with ID %q", id)
|
return nil, -1, fmt.Errorf("no file with ID %q", id)
|
||||||
}
|
}
|
||||||
|
@ -18,15 +18,13 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"time"
|
|
||||||
|
|
||||||
"go.universe.tf/netboot/dhcp4"
|
"go.universe.tf/netboot/dhcp4"
|
||||||
"golang.org/x/net/icmp"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type dhcpServer struct {
|
type dhcpServer struct {
|
||||||
dhcpConn *dhcp4.Conn // Used for sending only
|
//dhcpConn *dhcp4.Conn // Used for sending only
|
||||||
icmpConn icmp.PacketConn
|
//icmpConn icmp.PacketConn
|
||||||
leases []lease
|
leases []lease
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,8 +36,8 @@ const (
|
|||||||
|
|
||||||
type lease struct {
|
type lease struct {
|
||||||
state int
|
state int
|
||||||
mac net.HardwareAddr
|
//mac net.HardwareAddr
|
||||||
expires time.Time
|
//expires time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDHCPServer(address string, dhcpConn *dhcp4.Conn) (*dhcpServer, error) {
|
func newDHCPServer(address string, dhcpConn *dhcp4.Conn) (*dhcpServer, error) {
|
||||||
|
@ -58,7 +58,7 @@ func getURL(id ID, key *[32]byte) (string, error) {
|
|||||||
|
|
||||||
var nonce [24]byte
|
var nonce [24]byte
|
||||||
copy(nonce[:], signed)
|
copy(nonce[:], signed)
|
||||||
out, ok := secretbox.Open(nil, []byte(signed[24:]), &nonce, key)
|
out, ok := secretbox.Open(nil, signed[24:], &nonce, key)
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", errors.New("signature verification failed")
|
return "", errors.New("signature verification failed")
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ func (s *Server) transfer(addr net.Addr, req *rrq) error {
|
|||||||
conn.Write(tftpError("internal server error"))
|
conn.Write(tftpError("internal server error"))
|
||||||
return fmt.Errorf("writing seqnum: %s", err)
|
return fmt.Errorf("writing seqnum: %s", err)
|
||||||
}
|
}
|
||||||
n, err := io.CopyN(&b, file, int64(req.BlockSize))
|
n, err := io.CopyN(&b, file, req.BlockSize)
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && err != io.EOF {
|
||||||
conn.Write(tftpError("internal server error"))
|
conn.Write(tftpError("internal server error"))
|
||||||
return fmt.Errorf("reading bytes for block %d: %s", seq, err)
|
return fmt.Errorf("reading bytes for block %d: %s", seq, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user