{"record":{"id":"27f63c0d9703188d","repo":"shadow1ng/fscan","slug":"rsync-connect-failed","errorCode":null,"errorMessage":"rsync_connect_failed","messagePattern":"rsync_connect_failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/services/rsync.go","lineNumber":113,"sourceCode":"\t}\n}\n\n// createAuthFunc 创建Rsync认证函数\nfunc (p *RsyncPlugin) createAuthFunc(info *common.HostInfo, session *common.ScanSession) AuthFunc {\n\treturn func(ctx context.Context, cred Credential) *AuthResult {\n\t\treturn p.doRsyncAuth(ctx, info, cred, session)\n\t}\n}\n\n// doRsyncAuth 执行Rsync认证\nfunc (p *RsyncPlugin) doRsyncAuth(ctx context.Context, info *common.HostInfo, cred Credential, session *common.ScanSession) *AuthResult {\n\t// 先获取可用模块列表\n\tconn := p.connectToRsync(ctx, info, session)\n\tif conn == nil {\n\t\treturn &AuthResult{\n\t\t\tSuccess:   false,\n\t\t\tErrorType: ErrorTypeNetwork,\n\t\t\tError:     fmt.Errorf(\"%s\", i18n.GetText(\"rsync_connect_failed\")),\n\t\t}\n\t}\n\tmodules := p.getModules(conn, session.Config)\n\t_ = conn.Close()\n\n\tif len(modules) == 0 {\n\t\treturn &AuthResult{\n\t\t\tSuccess:   false,\n\t\t\tErrorType: ErrorTypeUnknown,\n\t\t\tError:     fmt.Errorf(\"%s\", i18n.GetText(\"rsync_modules_failed\")),\n\t\t}\n\t}\n\n\t// 提取第一个模块名\n\tvar firstModule string\n\tfor _, moduleLine := range modules {\n\t\tif fields := strings.Fields(moduleLine); len(fields) > 0 {\n\t\t\tfirstModule = fields[0]","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/services/rsync.go#L95-L131","documentation":"doRsyncAuth first opens a TCP connection and requests the module list via connectToRsync. If connectToRsync returns nil (connection or LIST-phase handshake failed), the auth attempt is aborted with rsync_connect_failed and ErrorTypeNetwork, indicating a network-level or protocol-level failure to talk to the rsync daemon.","triggerScenarios":"connectToRsync cannot dial info.Target() within the timeout, the TCP connection is refused/reset, or the initial rsync protocol handshake (@RSYNCD greeting) does not complete, so the function returns nil and the error is raised at rsync.go:113.","commonSituations":"rsync daemon not running or bound to a different port; firewall dropping 873; module list restricted by hosts allow/deny; daemon configured with 'list = no' or proxy in between; network timeouts in cloud environments.","solutions":["Verify the rsync daemon is reachable: nc -vz <host> 873 or telnet and expect the @RSYNCD banner.","Confirm the daemon port matches the scan target (port option in rsyncd.conf / non-default ports).","Check rsyncd.conf 'hosts allow'/'hosts deny' so the scanner IP is permitted.","Increase the connection timeout in the scan config for slow links."],"exampleFix":"// before (wrong port)\ntarget := \"10.0.0.5:22\" // rsync_connect_failed\n// after\ntarget := \"10.0.0.5:873\" // @RSYNCD 31.0 banner received","handlingStrategy":"retry","validationCode":"conn, err := net.DialTimeout(\"tcp\", host+\":873\", 5*time.Second)\nif err != nil { /* skip host: rsync not reachable */ }\nelse { conn.SetReadDeadline(time.Now().Add(3*time.Second)); buf := make([]byte, 64); n, _ := conn.Read(buf); if !strings.HasPrefix(string(buf[:n]), \"@RSYNCD\") { /* not rsync */ } conn.Close() }","typeGuard":null,"tryCatchPattern":"res, err := plugin.Scan(ctx, target)\nif err != nil && strings.Contains(err.Error(), \"rsync_connect_failed\") {\n    // transient network? retry with backoff, else mark host unreachable\n}","preventionTips":["Preflight the @RSYNCD banner before auth attempts.","Keep connection timeouts generous (>=5s) for remote scans.","Maintain a reachability check (TCP dial) upstream of the rsync module."],"tags":["rsync","network","tcp","connection"],"backgroundTag":"connection-refused","analyzedSha":"95cc12e753bf43de7004e5aef42a9ffba3934303","analyzedAt":"2026-09-06T17:07:30.094Z","contentChangedAt":"2026-09-06T17:07:30.094Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}