跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

credentials.go

58 行 · 1.6 KB历史下载
1// SPDX-FileCopyrightText: Copyright The Lima Authors
2// SPDX-License-Identifier: Apache-2.0
3
4package client
5
6import (
7 "context"
8 "net"
9
10 "google.golang.org/grpc/credentials"
11)
12
13// NewCredentials returns a lima credential implementing credentials.TransportCredentials.
14func NewCredentials() credentials.TransportCredentials {
15 return &secureTC{
16 info: credentials.ProtocolInfo{
17 SecurityProtocol: "local",
18 },
19 }
20}
21
22// secureTC is the credentials required to establish a lima guest connection.
23type secureTC struct {
24 info credentials.ProtocolInfo
25}
26
27func (c *secureTC) Info() credentials.ProtocolInfo {
28 return c.info
29}
30
31func (*secureTC) ClientHandshake(_ context.Context, _ string, conn net.Conn) (net.Conn, credentials.AuthInfo, error) {
32 return conn, info{credentials.CommonAuthInfo{SecurityLevel: credentials.PrivacyAndIntegrity}}, nil
33}
34
35func (*secureTC) ServerHandshake(conn net.Conn) (net.Conn, credentials.AuthInfo, error) {
36 return conn, info{credentials.CommonAuthInfo{SecurityLevel: credentials.PrivacyAndIntegrity}}, nil
37}
38
39func (c *secureTC) Clone() credentials.TransportCredentials {
40 return &secureTC{info: c.info}
41}
42
43func (c *secureTC) OverrideServerName(serverNameOverride string) error {
44 // SA1019: c.info.ServerName is deprecated:
45 // Users should use grpc.WithAuthority to override the authority on a channel instead of configuring the credentials.
46
47 //nolint:staticcheck,nolintlint // c.info.ServerName is used for compatibility reason
48 c.info.ServerName = serverNameOverride
49 return nil
50}
51
52type info struct {
53 credentials.CommonAuthInfo
54}
55
56func (info) AuthType() string {
57 return "local"
58}