MCPcopy Create free account
hub / github.com/coder/wush / newTSNet

Function newTSNet

cmd/wush/serve.go:229–254  ·  view source on GitHub ↗
(direction string, verbose bool)

Source from the content-addressed store, hash-verified

227}
228
229func newTSNet(direction string, verbose bool) (*tsnet.Server, error) {
230 var err error
231 tmp := os.TempDir()
232 srv := new(tsnet.Server)
233 srv.Dir = tmp
234 srv.Hostname = "wush-" + direction
235 srv.Ephemeral = true
236 srv.AuthKey = direction
237 srv.ControlURL = "http://127.0.0.1:8080"
238 srv.Logf = func(format string, args ...any) {}
239 srv.UserLogf = func(format string, args ...any) {}
240 if verbose {
241 logf := func(format string, args ...any) {
242 fmt.Fprintf(os.Stderr, format+"\n", args...)
243 }
244 srv.Logf = logf
245 srv.UserLogf = logf
246 }
247
248 srv.Store, err = store.New(func(format string, args ...any) {}, "mem:wush")
249 if err != nil {
250 return nil, xerrors.Errorf("create state store: %w", err)
251 }
252
253 return srv, nil
254}
255
256func bicopy(ctx context.Context, c1, c2 io.ReadWriteCloser) {
257 ctx, cancel := context.WithCancel(ctx)

Callers 4

cpCmdFunction · 0.70
portForwardCmdFunction · 0.70
sshCmdFunction · 0.70
serveCmdFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected