{"record":{"id":"935669f7fd29e22a","repo":"jeessy2/ddns-go","slug":"error","errorCode":null,"errorMessage":"密码不安全！尝试使用更复杂的密码","messagePattern":"密码不安全！尝试使用更复杂的密码","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"config/config.go","lineNumber":223,"sourceCode":"\t\tutil.Log(err.Error())\n\t\treturn\n\t}\n\n\t// 保存配置\n\tconf.Password = hashedPwd\n\tconf.SaveConfig()\n\tutil.Log(\"用户名 %s 的密码已重置成功! 请重启ddns-go\", conf.Username)\n}\n\n// CheckPassword 检查密码\nfunc (conf *Config) CheckPassword(newPassword string) (hashedPwd string, err error) {\n\tvar minEntropyBits float64 = 30\n\tif conf.NotAllowWanAccess {\n\t\tminEntropyBits = 25\n\t}\n\terr = passwordvalidator.Validate(newPassword, minEntropyBits)\n\tif err != nil {\n\t\treturn \"\", errors.New(util.LogStr(\"密码不安全！尝试使用更复杂的密码\"))\n\t}\n\n\t// 加密密码\n\thashedPwd, err = util.HashPassword(newPassword)\n\tif err != nil {\n\t\treturn \"\", errors.New(util.LogStr(\"异常信息: %s\", err.Error()))\n\t}\n\treturn\n}\n\nfunc (conf *DnsConfig) getIpv4AddrFromInterface() string {\n\tipv4, _, err := GetNetInterface()\n\tif err != nil {\n\t\tutil.Log(\"从网卡获得IPv4失败\")\n\t\treturn \"\"\n\t}\n\n\tfor _, netInterface := range ipv4 {","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/jeessy2/ddns-go/blob/5874c2e6667c69357ab95079421131104bd3fcae/config/config.go#L205-L241","documentation":"CheckPassword validates the new password with passwordvalidator against a minimum entropy of 30 bits (25 if WAN access is allowed). If the password fails the entropy check, ResetPassword returns this error meaning the chosen password is too weak. The message is the user-facing fix hint: pick a more complex password.","triggerScenarios":"Calling ResetPassword (which invokes CheckPassword) with a newPassword whose estimated entropy is below minEntropyBits — e.g. short passwords, dictionary words, no digits/symbols/case mix.","commonSituations":"User picks a simple password like '123456' or 'password'; minEntropyBits is raised to 30 when NotAllowWanAccess is true, so a password acceptable in LAN mode is rejected; validator version change tightened scoring.","solutions":["Choose a longer, more complex password (add length, mixed case, digits, symbols) so entropy meets the threshold","Check whether NotAllowWanAccess is set — if true the stricter 30-bit threshold applies; either strengthen the password or adjust the setting consciously","If legitimate passwords are rejected, lower minEntropyBits in config.go or adjust validator configuration"],"exampleFix":"// before\nerr = passwordvalidator.Validate(newPassword, minEntropyBits)\nif err != nil {\n  return \"\", errors.New(util.LogStr(\"密码不安全！尝试使用更复杂的密码\"))\n}\n// after\n// no code change: pick a stronger password, e.g. >= 12 chars with mixed classes\n// newPassword = \"Tr0ub4dor&3LongerPhrase!\"","handlingStrategy":"validation","validationCode":"// client-side pre-check before calling ResetPassword\nfunction passwordLooksStrong(pw, minLen = 10) {\n  return typeof pw === 'string' &&\n    pw.length >= minLen &&\n    /[a-z]/.test(pw) && /[A-Z]/.test(pw) &&\n    /\\d/.test(pw) && /[^A-Za-z0-9]/.test(pw);\n}","typeGuard":"null","tryCatchPattern":"newPwd, err := conf.CheckPassword(input)\nif err != nil {\n  if strings.Contains(err.Error(), \"密码不安全\") {\n    // prompt user to choose a stronger password\n    return fmt.Errorf(\"密码强度不足: %w\", err)\n  }\n  return err\n}","preventionTips":["Enforce a client-side password strength meter before submission","Require a minimum length (>= 10-12) plus mixed character classes","Account for stricter thresholds when NotAllowWanAccess is enabled (30-bit minimum)","Standardize on passphrases rather than short complex strings"],"tags":["password","validation","security"],"backgroundTag":"weak-password-rejected","analyzedSha":"5874c2e6667c69357ab95079421131104bd3fcae","analyzedAt":"2026-09-03T15:41:16.799Z","contentChangedAt":"2026-09-03T15:41:16.799Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}