diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 85b6bad..ef9c6ec 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -17,7 +17,7 @@ jobs: with: go-version: 1.21 - name: Lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v6 with: version: latest build: diff --git a/.golangci.yaml b/.golangci.yaml index 0b27a7c..3569c62 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -18,7 +18,7 @@ linters: - dogsled - errname - errorlint - - exportloopref + - copyloopvar - forcetypeassert - gocognit - goconst diff --git a/deprecated/v1/sifi/sifi.go b/deprecated/v1/sifi/sifi.go index aa32b9b..821803d 100644 --- a/deprecated/v1/sifi/sifi.go +++ b/deprecated/v1/sifi/sifi.go @@ -17,8 +17,10 @@ import ( ) const ( - PortNumber = 7434 // PortNumber is the default port for `sifid` (sifi on a keypad). - ServiceName = "sifid" // ServiceName is the public name of the SIFI service. + // PortNumber is the default port for `sifid` (sifi on a keypad). + PortNumber = 7434 + // ServiceName is the public name of the SIFI service. + ServiceName = "sifid" ) // path returns a URL path with the correct prefix appended. diff --git a/manifold/manifold.go b/manifold/manifold.go index 9e069af..e9567c6 100644 --- a/manifold/manifold.go +++ b/manifold/manifold.go @@ -5,8 +5,12 @@ package manifold const ( - APIPrefix = "/manifold-api" // APIPrefix is the prefix for all API paths. - APIVersion = "v3-preview" // APIVersion is the prefix for all API paths (without the leading slash). - PortNumber = 7434 // PortNumber is the default port for `sifid` (sifi on a keypad). - ServiceName = "sifid" // ServiceName is the public name of the manifold-api service. + // APIPrefix is the prefix for all API paths. + APIPrefix = "/manifold-api" + // APIVersion is the prefix for all API paths (without the leading slash). + APIVersion = "v3-preview" + // PortNumber is the default port for `sifid` (sifi on a keypad). + PortNumber = 7434 + // ServiceName is the public name of the manifold-api service. + ServiceName = "sifid" ) diff --git a/metal/responses.go b/metal/responses.go index 4a222cc..d086a79 100644 --- a/metal/responses.go +++ b/metal/responses.go @@ -212,7 +212,12 @@ type NetInterfaceInfo struct { MAC string `json:"mac"` // The network's MAC address MTU uint16 `json:"mtu"` // The network's maximum transmission unit LinkSpeedMbs uint `json:"link_speed_Mbs"` - Link bool `json:"link"` + Link bool `json:"link"` // true when the link status is up + VendorID string `json:"vendor_id"` // the link device Vendor ID (from e.g PCI info) + DeviceID string `json:"device_id"` // the link device ID (from e.g PCI info) + Vendor string `json:"vendor"` // the link device vendor (name) + Device string `json:"device"` // the link device (name) + BusInfo string `json:"bus_info"` // the link bus info/address (from e.g PCI info) } // BcacheInfo is the information we can get for a single bcache device. diff --git a/upload/service.go b/upload/service.go index e6654fd..e3a7c94 100644 --- a/upload/service.go +++ b/upload/service.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "io" + "math" "net/http" "os" "path/filepath" @@ -106,7 +107,11 @@ func (s Service) Upload(ctx context.Context, path string) (*UploadResponse, erro } upload.Offset = status.Offset - upload.Completed = int64(status.Offset) == stat.Size() + size := stat.Size() + if size < 0 { + return nil, errors.New("invalid stat.Size()") + } + upload.Completed = (status.Offset == uint64(size)) return &upload, nil } @@ -130,15 +135,24 @@ func (s Service) Resume(ctx context.Context, id, path string) (*ResumeResponse, } defer fin.Close() + if status.Offset > math.MaxInt64 { + return nil, errors.New("offset too large") + } + status, err = s.upload(ctx, id, int64(status.Offset), fin) if err != nil { return nil, err } + size := stat.Size() + if size < 0 { + return nil, errors.New("invalid stat.Size()") + } + resume := ResumeResponse{ Version: status.Version, Offset: status.Offset, - Completed: int64(status.Offset) == stat.Size(), + Completed: status.Offset == uint64(size), } return &resume, nil