timecheck
This commit is contained in:
parent
8548d1d596
commit
09431f353d
@ -343,6 +343,7 @@ func getLocalPath(ctx context.Context, digest string) (string, error) {
|
||||
}
|
||||
|
||||
request.Header.Set("Authorization", authz)
|
||||
request.Header.Set("Timestamp", time.Now().Format(time.RFC3339))
|
||||
request.Header.Set("User-Agent", fmt.Sprintf("ollama/%s (%s %s) Go/%s", version.Version, runtime.GOARCH, runtime.GOOS, runtime.Version()))
|
||||
request.Header.Set("X-Redirect-Create", "1")
|
||||
|
||||
|
@ -997,6 +997,16 @@ func (s *Server) IsServerKeyPublicKey(c *gin.Context) bool {
|
||||
serverPublicKey, err := auth.GetPublicKey()
|
||||
if err != nil {
|
||||
slog.Error(fmt.Sprintf("failed to get server public key: %v", err))
|
||||
return false
|
||||
}
|
||||
|
||||
timestamp, err := time.Parse(time.RFC3339, c.GetHeader("Timestamp"))
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
if time.Since(timestamp) > time.Minute {
|
||||
return false
|
||||
}
|
||||
|
||||
if bytes.Equal(serverPublicKey.Marshal(), clientPublicKey.Marshal()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user