跳到主要内容

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

浏览文件

main.go

52 行 · 1.0 KB历史下载
1package main
2
3// small wrapper around sftp server that allows it to be used as a separate process subsystem call by the ssh server.
4// in practice this will statically link; however this allows unit testing from the sftp client.
5
6import (
7 "flag"
8 "fmt"
9 "io"
10 "io/ioutil"
11 "os"
12
13 "github.com/pkg/sftp"
14)
15
16func main() {
17 var (
18 readOnly bool
19 debugStderr bool
20 debugLevel string
21 options []sftp.ServerOption
22 )
23
24 flag.BoolVar(&readOnly, "R", false, "read-only server")
25 flag.BoolVar(&debugStderr, "e", false, "debug to stderr")
26 flag.StringVar(&debugLevel, "l", "none", "debug level (ignored)")
27 flag.Parse()
28
29 debugStream := ioutil.Discard
30 if debugStderr {
31 debugStream = os.Stderr
32 }
33 options = append(options, sftp.WithDebug(debugStream))
34
35 if readOnly {
36 options = append(options, sftp.ReadOnly())
37 }
38
39 svr, _ := sftp.NewServer(
40 struct {
41 io.Reader
42 io.WriteCloser
43 }{os.Stdin,
44 os.Stdout,
45 },
46 options...,
47 )
48 if err := svr.Serve(); err != nil {
49 fmt.Fprintf(debugStream, "sftp server completed with error: %v", err)
50 os.Exit(1)
51 }
52}