|
@@ -381,39 +381,6 @@ func (c *Client) Version(ctx context.Context) (string, error) {
|
|
return version.Version, nil
|
|
return version.Version, nil
|
|
}
|
|
}
|
|
|
|
|
|
-func Authorization(ctx context.Context, request *http.Request) (string, error) {
|
|
|
|
- data := []byte(fmt.Sprintf("%s,%s,%d", request.Method, request.URL.RequestURI(), time.Now().Unix()))
|
|
|
|
-
|
|
|
|
- home, err := os.UserHomeDir()
|
|
|
|
- if err != nil {
|
|
|
|
- return "", err
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- knownHostsFile, err := os.OpenFile(filepath.Join(home, ".ollama", "known_hosts"), os.O_CREATE|os.O_RDWR|os.O_APPEND, 0600)
|
|
|
|
- if err != nil {
|
|
|
|
- return "", err
|
|
|
|
- }
|
|
|
|
- defer knownHostsFile.Close()
|
|
|
|
-
|
|
|
|
- token, err := auth.Sign(ctx, data)
|
|
|
|
- if err != nil {
|
|
|
|
- return "", err
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // interleave request data into the token
|
|
|
|
- key, sig, _ := strings.Cut(token, ":")
|
|
|
|
- return fmt.Sprintf("%s:%s:%s", key, base64.StdEncoding.EncodeToString(data), sig), nil
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// EnvConfig returns the environment configuration for the server.
|
|
|
|
-func (c *Client) ServerConfig(ctx context.Context) (*ServerConfig, error) {
|
|
|
|
- var config ServerConfig
|
|
|
|
- if err := c.do(ctx, http.MethodGet, "/api/config", nil, &config); err != nil {
|
|
|
|
- return nil, err
|
|
|
|
- }
|
|
|
|
- return &config, nil
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
func Authorization(ctx context.Context, request *http.Request) (string, error) {
|
|
func Authorization(ctx context.Context, request *http.Request) (string, error) {
|
|
|
|
|
|
data := []byte(fmt.Sprintf("%s,%s,%d", request.Method, request.URL.RequestURI(), time.Now().Unix()))
|
|
data := []byte(fmt.Sprintf("%s,%s,%d", request.Method, request.URL.RequestURI(), time.Now().Unix()))
|