diff options
| author | Chris Lu <chris.lu@gmail.com> | 2021-08-12 21:40:33 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2021-08-12 21:40:33 -0700 |
| commit | 5a0f92423eb4f89d35b245b1913eb7ba60436742 (patch) | |
| tree | 433a3ce97451c9800089b8d87abc09480c0dcf78 /weed/server | |
| parent | 6238644c35fc5dafcc4eb1722b3d5c9b92c0b031 (diff) | |
| download | seaweedfs-5a0f92423eb4f89d35b245b1913eb7ba60436742.tar.xz seaweedfs-5a0f92423eb4f89d35b245b1913eb7ba60436742.zip | |
use grpc and jwt
Diffstat (limited to 'weed/server')
| -rw-r--r-- | weed/server/master_grpc_server_volume.go | 14 | ||||
| -rw-r--r-- | weed/server/master_server_handlers.go | 4 | ||||
| -rw-r--r-- | weed/server/volume_server_handlers_read.go | 2 |
3 files changed, 13 insertions, 7 deletions
diff --git a/weed/server/master_grpc_server_volume.go b/weed/server/master_grpc_server_volume.go index 314db363f..4b975a0c4 100644 --- a/weed/server/master_grpc_server_volume.go +++ b/weed/server/master_grpc_server_volume.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/chrislusf/raft" "reflect" + "strings" "sync" "time" @@ -69,7 +70,7 @@ func (ms *MasterServer) ProcessGrowRequest() { func (ms *MasterServer) LookupVolume(ctx context.Context, req *master_pb.LookupVolumeRequest) (*master_pb.LookupVolumeResponse, error) { resp := &master_pb.LookupVolumeResponse{} - volumeLocations := ms.lookupVolumeId(req.VolumeIds, req.Collection) + volumeLocations := ms.lookupVolumeId(req.VolumeOrFileIds, req.Collection) for _, result := range volumeLocations { var locations []*master_pb.Location @@ -79,10 +80,15 @@ func (ms *MasterServer) LookupVolume(ctx context.Context, req *master_pb.LookupV PublicUrl: loc.PublicUrl, }) } + var auth string + if strings.Contains(result.VolumeOrFileId, ",") { // this is a file id + auth = string(security.GenJwt(ms.guard.SigningKey, ms.guard.ExpiresAfterSec, result.VolumeOrFileId)) + } resp.VolumeIdLocations = append(resp.VolumeIdLocations, &master_pb.LookupVolumeResponse_VolumeIdLocation{ - VolumeId: result.VolumeId, - Locations: locations, - Error: result.Error, + VolumeOrFileId: result.VolumeOrFileId, + Locations: locations, + Error: result.Error, + Auth: auth, }) } diff --git a/weed/server/master_server_handlers.go b/weed/server/master_server_handlers.go index 32eb41114..2a1f6d523 100644 --- a/weed/server/master_server_handlers.go +++ b/weed/server/master_server_handlers.go @@ -86,8 +86,8 @@ func (ms *MasterServer) findVolumeLocation(collection, vid string) operation.Loo err = fmt.Errorf("volume id %s not found", vid) } ret := operation.LookupResult{ - VolumeId: vid, - Locations: locations, + VolumeOrFileId: vid, + Locations: locations, } if err != nil { ret.Error = err.Error() diff --git a/weed/server/volume_server_handlers_read.go b/weed/server/volume_server_handlers_read.go index 29428730e..5d12108d3 100644 --- a/weed/server/volume_server_handlers_read.go +++ b/weed/server/volume_server_handlers_read.go @@ -252,7 +252,7 @@ func (vs *VolumeServer) tryHandleChunkedFile(n *needle.Needle, fileName string, w.Header().Set("X-File-Store", "chunked") - chunkedFileReader := operation.NewChunkedFileReader(chunkManifest.Chunks, vs.GetMaster()) + chunkedFileReader := operation.NewChunkedFileReader(chunkManifest.Chunks, vs.GetMaster(), vs.grpcDialOption) defer chunkedFileReader.Close() rs := conditionallyResizeImages(chunkedFileReader, ext, r) |
