Skip to content

Commit 4b8d960

Browse files
committed
rsyncd: add HandleConnArgs (rsyncopts is not exported)
We should refactor InternalHandleConn away eventually.
1 parent 559ca13 commit 4b8d960

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

internal/maincmd/maincmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func Main(ctx context.Context, args []string, stdin io.Reader, stdout io.Writer,
9696
log.Printf("paths: %q", remaining[1:])
9797
}
9898
conn := rsyncd.NewConnection(stdin, stdout, "<remote-shell>")
99-
return nil, srv.HandleConn(ctx, conn, nil, pc)
99+
return nil, srv.InternalHandleConn(ctx, conn, nil, pc)
100100
}
101101

102102
if !opts.Daemon() {

rsyncclient/rsyncclient_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func ExampleClient_Run_sendToGoroutine() {
7777
if err != nil {
7878
log.Fatalf("parsing server args: %v", err)
7979
}
80-
if err := rsync.HandleConn(ctx, conn, nil, pc); err != nil {
80+
if err := rsync.InternalHandleConn(ctx, conn, nil, pc); err != nil {
8181
log.Fatal(err)
8282
}
8383
}()
@@ -176,7 +176,7 @@ func TestClientServerModule(t *testing.T) {
176176
wg.Add(1)
177177
go func() {
178178
defer wg.Done()
179-
err := rsync.HandleConn(t.Context(), conn, &mod, pc)
179+
err := rsync.InternalHandleConn(t.Context(), conn, &mod, pc)
180180
if err != nil {
181181
t.Error(err)
182182
}
@@ -243,7 +243,7 @@ func TestClientServerCommand(t *testing.T) {
243243
wg.Add(1)
244244
go func() {
245245
defer wg.Done()
246-
err := rsync.HandleConn(t.Context(), conn, nil, pc)
246+
err := rsync.InternalHandleConn(t.Context(), conn, nil, pc)
247247
if err != nil {
248248
t.Error(err)
249249
}
@@ -309,7 +309,7 @@ func TestClientServerCommandSender(t *testing.T) {
309309
wg.Add(1)
310310
go func() {
311311
defer wg.Done()
312-
err := rsync.HandleConn(t.Context(), conn, nil, pc)
312+
err := rsync.InternalHandleConn(t.Context(), conn, nil, pc)
313313
if err != nil {
314314
t.Error(err)
315315
}

rsyncd/rsyncd.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,16 @@ func NewConnection(r io.Reader, w io.Writer, name string) *Conn {
300300
}
301301
}
302302

303-
func (s *Server) HandleConn(ctx context.Context, conn *Conn, module *Module, pc *rsyncopts.Context) error {
303+
// This method is only exported until we refactor; use HandleConnArgs() instead
304+
func (s *Server) InternalHandleConn(ctx context.Context, conn *Conn, module *Module, pc *rsyncopts.Context) error {
305+
return s.handleConn(ctx, conn, module, pc, true /* negotiate */)
306+
}
307+
308+
func (s *Server) HandleConnArgs(ctx context.Context, conn *Conn, module *Module, args []string) error {
309+
pc, err := rsyncopts.ParseArguments(args)
310+
if err != nil {
311+
return fmt.Errorf("parsing server args: %v", err)
312+
}
304313
return s.handleConn(ctx, conn, module, pc, true /* negotiate */)
305314
}
306315

0 commit comments

Comments
 (0)