跳到主要内容

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

浏览文件

main_linux.go

75 行 · 2.3 KB历史下载
1// SPDX-FileCopyrightText: Copyright The Lima Authors
2// SPDX-License-Identifier: Apache-2.0
3
4package main
5
6import (
7 "os"
8 "strings"
9
10 "github.com/sirupsen/logrus"
11 "github.com/spf13/cobra"
12
13 "github.com/lima-vm/lima/v2/pkg/networks"
14 "github.com/lima-vm/lima/v2/pkg/osutil"
15 "github.com/lima-vm/lima/v2/pkg/version"
16)
17
18func main() {
19 os.Setenv("PATH", strings.Join(safeDirs, ":"))
20 if err := newApp().Execute(); err != nil {
21 osutil.HandleExitError(err)
22 logrus.Fatal(err)
23 }
24}
25
26func newApp() *cobra.Command {
27 rootCmd := &cobra.Command{
28 Use: "lima-privileged-net",
29 Short: "Do not launch manually",
30 Long: `Privileged helper that manages the Linux bridges and tap devices of the
31"shared", "host", and "bridged" networks. It is executed via sudo by limactl.`,
32 Version: strings.TrimPrefix(version.Version, "v"),
33 SilenceUsage: true,
34 SilenceErrors: true,
35 PersistentPreRunE: func(_ *cobra.Command, _ []string) error {
36 return verifySelf()
37 },
38 }
39 rootCmd.AddCommand(newStartCommand(), newTapCommand())
40 return rootCmd
41}
42
43func newStartCommand() *cobra.Command {
44 var c netConfig
45 cmd := &cobra.Command{
46 Use: "start",
47 Short: "Bring a network up and stay in the foreground until terminated",
48 Args: cobra.NoArgs,
49 RunE: func(cmd *cobra.Command, _ []string) error {
50 return c.run(cmd.Context())
51 },
52 }
53 f := cmd.Flags()
54 f.StringVar(&c.pidFile, "pidfile", "", "file to write the PID of this process to")
55 f.StringVar(&c.mode, "mode", "", "network mode: "+networks.ModeShared+", "+networks.ModeHost+", or "+networks.ModeBridged)
56 f.StringVar(&c.bridge, "bridge", "", "name of the bridge interface")
57 f.StringVar(&c.gateway, "gateway", "", "IPv4 address assigned to the bridge")
58 f.StringVar(&c.netmask, "netmask", "", "IPv4 netmask of the network")
59 f.StringVar(&c.dhcpEnd, "dhcp-end", "", "last IPv4 address handed out by DHCP")
60 return cmd
61}
62
63func newTapCommand() *cobra.Command {
64 var bridge string
65 cmd := &cobra.Command{
66 Use: "tap TAP",
67 Short: "Create a tap device owned by the calling user and attach it to a bridge",
68 Args: cobra.ExactArgs(1),
69 RunE: func(cmd *cobra.Command, args []string) error {
70 return tapUp(cmd.Context(), args[0], bridge)
71 },
72 }
73 cmd.Flags().StringVar(&bridge, "bridge", "", "name of the bridge to attach the tap device to")
74 return cmd
75}