mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-21 22:17:25 +08:00
use grpc and jwt
This commit is contained in:
@@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
|
@@ -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()
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user