rsyncd

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2023 License: BSD-3-Clause Imports: 26 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CounterPair

func CounterPair(r io.Reader, w io.Writer) (*countingReader, *countingWriter)

Types

type Module

type Module struct {
	Name string   `toml:"name"`
	Path string   `toml:"path"`
	ACL  []string `toml:"acl"`
}

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option specifies the server options.

func WithLogger

func WithLogger(logger log.Logger) Option

WithLogger specifies the logger to use for the server. It also sets the global logger used by the rsync package.

type Opts

type Opts struct {
	Gokrazy struct {
		Config           string
		Listen           string
		MonitoringListen string
		AnonSSHListen    string
		ModuleMap        string
	}

	Daemon           bool
	Server           bool
	Sender           bool
	PreserveGid      bool
	PreserveUid      bool
	PreserveLinks    bool
	PreservePerms    bool
	PreserveDevices  bool
	PreserveSpecials bool
	PreserveTimes    bool
	Recurse          bool
	IgnoreTimes      bool
	DryRun           bool
	D                bool
}

func NewGetOpt

func NewGetOpt() (*Opts, *getoptions.GetOpt)

type Server

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

func NewServer

func NewServer(modules []Module, opts ...Option) (*Server, error)
Example
package main

import (
	"context"
	"log"
	"net"
	"time"

	"github.com/gokrazy/rsync/rsyncd"
)

func main() {
	// simulate user (or process supervisor) asking us to stop soon after starting
	ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
	defer cancel()

	listener, err := net.Listen("tcp", "localhost:873")
	if err != nil {
		log.Fatal(err)
	}

	rsyncServer, err := rsyncd.NewServer([]rsyncd.Module{
		{
			Name: "music",
			Path: "/home/bob/Music",
		},
	})
	if err != nil {
		log.Fatal(err)
	}

	if err := rsyncServer.Serve(ctx, listener); err != nil {
		log.Fatal(err)
	}

	log.Println("gracefully exiting")
}
Output:

func (*Server) HandleConn

func (s *Server) HandleConn(module Module, rd io.Reader, crd *countingReader, cwr *countingWriter, paths []string, opts *Opts, negotiate bool) (err error)

handleConn is equivalent to rsync/main.c:start_server

func (*Server) HandleDaemonConn

func (s *Server) HandleDaemonConn(ctx context.Context, conn io.ReadWriter, remoteAddr net.Addr) (err error)

FIXME: context cancellation not yet implemented

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, ln net.Listener) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL