mirror of
https://github.com/hanzoai/s3.git
synced 2026-10-30 14:59:09 +00:00
hanzoai/s3 was an AGPL-3.0 MinIO fork whose network-copyleft blocks embedding
and reselling as a managed service. Replace it wholesale with a fork of
SeaweedFS (github.com/seaweedfs/seaweedfs, Apache-2.0, Go) which ships a
built-in S3 gateway + Filer.
- License: AGPL-3.0 -> Apache-2.0 (upstream LICENSE kept verbatim, incl.
"Copyright 2025 Chris Lu"); NOTICE added crediting SeaweedFS. No AGPL/BUSL/
SSPL/GPL or enterprise ("ee") files remain.
- Module: go.mod path set to github.com/hanzoai/s3 with a self-replace
(replace github.com/seaweedfs/seaweedfs => ./) so the ~1800 internal Go files
keep their upstream import paths with zero churn. Internal identifiers and
import paths are intentionally NOT renamed.
- CLI rebrand: the binary is built as `s3` (was `weed`); root usage, per-command
help/usage/flag strings, shell autocomplete program name, and the product name
in CLI output now read "Hanzo S3" / `s3`. Users never see `weed`.
(e.g. `s3 server`, `s3 filer`, `s3 master`, `s3 volume`, `s3 s3`, `s3 mount`.)
- Build: `make` (or `go build -o s3 ./weed`) builds the `s3` binary green;
`cmd/weed-db` and `cmd/weed-sql` also build; `go vet ./weed/command/` clean.
- README/LLM.md rewritten for Hanzo S3; AGENTS.md/CLAUDE.md symlinks preserved.
- Dropped a 33MB prebuilt Mach-O `stress` binary upstream had committed; `.gitignore`
updated to ignore the `s3` build output.
111 lines
3.5 KiB
Go
111 lines
3.5 KiB
Go
package dash
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/cluster"
|
|
"github.com/seaweedfs/seaweedfs/weed/glog"
|
|
"github.com/seaweedfs/seaweedfs/weed/operation"
|
|
"github.com/seaweedfs/seaweedfs/weed/pb"
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb"
|
|
"github.com/seaweedfs/seaweedfs/weed/wdclient"
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
// WithMasterClient executes a function with a master client connection
|
|
func (s *AdminServer) WithMasterClient(f func(client master_pb.SeaweedClient) error) error {
|
|
return s.masterClient.WithClient(false, f)
|
|
}
|
|
|
|
// WithFilerClient executes a function with a filer client connection
|
|
func (s *AdminServer) WithFilerClient(f func(client filer_pb.SeaweedFilerClient) error) error {
|
|
filerAddr := s.GetFilerAddress()
|
|
if filerAddr == "" {
|
|
return fmt.Errorf("no filer available")
|
|
}
|
|
|
|
return pb.WithGrpcFilerClient(false, 0, pb.ServerAddress(filerAddr), s.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
|
return f(client)
|
|
})
|
|
}
|
|
|
|
// WithVolumeServerClient executes a function with a volume server client connection
|
|
func (s *AdminServer) WithVolumeServerClient(address pb.ServerAddress, f func(client volume_server_pb.VolumeServerClient) error) error {
|
|
return operation.WithVolumeServerClient(false, address, s.grpcDialOption, func(client volume_server_pb.VolumeServerClient) error {
|
|
return f(client)
|
|
})
|
|
}
|
|
|
|
// GetMasterClient returns the admin server's wdclient.MasterClient. It is used
|
|
// by file browser download paths that stream chunks straight from the volume
|
|
// servers via filer.PrepareStreamContent so they keep working when the filer
|
|
// has -disableHttp=true.
|
|
func (s *AdminServer) GetMasterClient() *wdclient.MasterClient {
|
|
return s.masterClient
|
|
}
|
|
|
|
// GetGrpcDialOption returns the dial option used for all admin-originated
|
|
// gRPC connections (TLS or insecure). File browser uploads need this when
|
|
// they perform the assign + volume HTTP POST + create-entry flow.
|
|
func (s *AdminServer) GetGrpcDialOption() grpc.DialOption {
|
|
return s.grpcDialOption
|
|
}
|
|
|
|
// GetFilerAddress returns a filer address, discovering from masters if needed
|
|
func (s *AdminServer) GetFilerAddress() string {
|
|
// Discover filers from masters
|
|
filers := s.getDiscoveredFilers()
|
|
if len(filers) > 0 {
|
|
return filers[0] // Return the first available filer
|
|
}
|
|
|
|
return ""
|
|
}
|
|
|
|
// getDiscoveredFilers returns cached filers or discovers them from masters
|
|
func (s *AdminServer) getDiscoveredFilers() []string {
|
|
// Check if cache is still valid
|
|
if time.Since(s.lastFilerUpdate) < s.filerCacheExpiration && len(s.cachedFilers) > 0 {
|
|
return s.cachedFilers
|
|
}
|
|
|
|
// Discover filers from masters
|
|
var filers []string
|
|
err := s.WithMasterClient(func(client master_pb.SeaweedClient) error {
|
|
resp, err := client.ListClusterNodes(context.Background(), &master_pb.ListClusterNodesRequest{
|
|
ClientType: cluster.FilerType,
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, node := range resp.ClusterNodes {
|
|
filers = append(filers, node.Address)
|
|
}
|
|
|
|
return nil
|
|
})
|
|
|
|
if err != nil {
|
|
currentMaster := s.masterClient.GetMaster(context.Background())
|
|
glog.Warningf("Failed to discover filers from master %s: %v", currentMaster, err)
|
|
// Return cached filers even if expired, better than nothing
|
|
return s.cachedFilers
|
|
}
|
|
|
|
// Update cache
|
|
s.cachedFilers = filers
|
|
s.lastFilerUpdate = time.Now()
|
|
|
|
return filers
|
|
}
|
|
|
|
// GetAllFilers returns all discovered filers
|
|
func (s *AdminServer) GetAllFilers() []string {
|
|
return s.getDiscoveredFilers()
|
|
}
|