rclone: github.com/ncw/rclone/cmd/serve/restic Index | Files

package restic

import "github.com/ncw/rclone/cmd/serve/restic"

Package restic serves a remote suitable for use with restic

Index

Package Files

restic.go stdio_conn.go

Variables

var Command = &cobra.Command{
    Use:   "restic remote:path",
    Short: `Serve the remote for restic's REST API.`,
    Long: "" /* 2586 byte string literal not displayed */+
        "`/<username>/`" + `.
` + httplib.Help,
    Run: func(command *cobra.Command, args []string) {
        cmd.CheckArgs(1, 1, command, args)
        f := cmd.NewFsSrc(args)
        cmd.Run(false, true, command, func() error {
            s := NewServer(f, &httpflags.Opt)
            if stdio {
                if terminal.IsTerminal(int(os.Stdout.Fd())) {
                    return errors.New("Refusing to run HTTP2 server directly on a terminal, please let restic start rclone")
                }

                conn := &StdioConn{
                    stdin:  os.Stdin,
                    stdout: os.Stdout,
                }

                httpSrv := &http2.Server{}
                opts := &http2.ServeConnOpts{
                    Handler: s,
                }
                httpSrv.ServeConn(conn, opts)
                return nil
            }
            err := s.Serve()
            if err != nil {
                return err
            }
            s.Wait()
            return nil
        })
    },
}

Command definition for cobra

type Addr Uses

type Addr struct{}

Addr implements net.Addr for stdin/stdout.

func (Addr) Network Uses

func (a Addr) Network() string

Network returns the network type as a string.

func (Addr) String Uses

func (a Addr) String() string

type Server Uses

type Server struct {
    *httplib.Server
    // contains filtered or unexported fields
}

Server contains everything to run the Server

func NewServer Uses

func NewServer(f fs.Fs, opt *httplib.Options) *Server

NewServer returns an HTTP server that speaks the rest protocol

func (*Server) Serve Uses

func (s *Server) Serve() error

Serve runs the http server in the background.

Use s.Close() and s.Wait() to shutdown server

func (*Server) ServeHTTP Uses

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP reads incoming requests and dispatches them

type StdioConn Uses

type StdioConn struct {
    // contains filtered or unexported fields
}

StdioConn implements a net.Conn via stdin/stdout.

func (*StdioConn) Close Uses

func (s *StdioConn) Close() error

Close closes both streams.

func (*StdioConn) LocalAddr Uses

func (s *StdioConn) LocalAddr() net.Addr

LocalAddr returns nil.

func (*StdioConn) Read Uses

func (s *StdioConn) Read(p []byte) (int, error)

func (*StdioConn) RemoteAddr Uses

func (s *StdioConn) RemoteAddr() net.Addr

RemoteAddr returns nil.

func (*StdioConn) SetDeadline Uses

func (s *StdioConn) SetDeadline(t time.Time) error

SetDeadline sets the read/write deadline.

func (*StdioConn) SetReadDeadline Uses

func (s *StdioConn) SetReadDeadline(t time.Time) error

SetReadDeadline sets the read/write deadline.

func (*StdioConn) SetWriteDeadline Uses

func (s *StdioConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the read/write deadline.

func (*StdioConn) Write Uses

func (s *StdioConn) Write(p []byte) (int, error)

Package restic imports 22 packages (graph) and is imported by 4 packages. Updated 2020-08-03. Refresh now. Tools for package owners.