mirror of
				https://github.com/9001/copyparty.git
				synced 2025-10-31 04:32:20 -06:00 
			
		
		
		
	disable bans according to perms; closes #911
This commit is contained in:
		
							parent
							
								
									3364448858
								
							
						
					
					
						commit
						6f02812af1
					
				|  | @ -1547,6 +1547,7 @@ def add_safety(ap): | ||||||
|     ap2.add_argument("--force-js", action="store_true", help="don't send folder listings as HTML, force clients to use the embedded json instead -- slight protection against misbehaving search engines which ignore \033[33m--no-robots\033[0m") |     ap2.add_argument("--force-js", action="store_true", help="don't send folder listings as HTML, force clients to use the embedded json instead -- slight protection against misbehaving search engines which ignore \033[33m--no-robots\033[0m") | ||||||
|     ap2.add_argument("--no-robots", action="store_true", help="adds http and html headers asking search engines to not index anything (volflag=norobots)") |     ap2.add_argument("--no-robots", action="store_true", help="adds http and html headers asking search engines to not index anything (volflag=norobots)") | ||||||
|     ap2.add_argument("--logout", metavar="H", type=float, default=8086.0, help="logout clients after \033[33mH\033[0m hours of inactivity; [\033[32m0.0028\033[0m]=10sec, [\033[32m0.1\033[0m]=6min, [\033[32m24\033[0m]=day, [\033[32m168\033[0m]=week, [\033[32m720\033[0m]=month, [\033[32m8760\033[0m]=year)") |     ap2.add_argument("--logout", metavar="H", type=float, default=8086.0, help="logout clients after \033[33mH\033[0m hours of inactivity; [\033[32m0.0028\033[0m]=10sec, [\033[32m0.1\033[0m]=6min, [\033[32m24\033[0m]=day, [\033[32m168\033[0m]=week, [\033[32m720\033[0m]=month, [\033[32m8760\033[0m]=year)") | ||||||
|  |     ap2.add_argument("--dont-ban", metavar="TXT", type=u, default="no", help="anyone at this accesslevel or above will not get banned: [\033[32mav\033[0m]=admin-in-volume, [\033[32maa\033[0m]=has-admin-anywhere, [\033[32mrw\033[0m]=read-write, [\033[32mauth\033[0m]=authenticated, [\033[32many\033[0m]=disable-all-bans, [\033[32mno\033[0m]=anyone-can-get-banned") | ||||||
|     ap2.add_argument("--ban-pw", metavar="N,W,B", type=u, default="9,60,1440", help="more than \033[33mN\033[0m wrong passwords in \033[33mW\033[0m minutes = ban for \033[33mB\033[0m minutes; disable with [\033[32mno\033[0m]") |     ap2.add_argument("--ban-pw", metavar="N,W,B", type=u, default="9,60,1440", help="more than \033[33mN\033[0m wrong passwords in \033[33mW\033[0m minutes = ban for \033[33mB\033[0m minutes; disable with [\033[32mno\033[0m]") | ||||||
|     ap2.add_argument("--ban-pwc", metavar="N,W,B", type=u, default="5,60,1440", help="more than \033[33mN\033[0m password-changes in \033[33mW\033[0m minutes = ban for \033[33mB\033[0m minutes; disable with [\033[32mno\033[0m]") |     ap2.add_argument("--ban-pwc", metavar="N,W,B", type=u, default="5,60,1440", help="more than \033[33mN\033[0m password-changes in \033[33mW\033[0m minutes = ban for \033[33mB\033[0m minutes; disable with [\033[32mno\033[0m]") | ||||||
|     ap2.add_argument("--ban-404", metavar="N,W,B", type=u, default="50,60,1440", help="hitting more than \033[33mN\033[0m 404's in \033[33mW\033[0m minutes = ban for \033[33mB\033[0m minutes; only affects users who cannot see directory listings because their access is either g/G/h") |     ap2.add_argument("--ban-404", metavar="N,W,B", type=u, default="50,60,1440", help="hitting more than \033[33mN\033[0m 404's in \033[33mW\033[0m minutes = ban for \033[33mB\033[0m minutes; only affects users who cannot see directory listings because their access is either g/G/h") | ||||||
|  |  | ||||||
|  | @ -862,6 +862,16 @@ class HttpCli(object): | ||||||
|             return self.conn.iphash.s(self.ip) |             return self.conn.iphash.s(self.ip) | ||||||
| 
 | 
 | ||||||
|     def cbonk(self, g: Garda, v: str, reason: str, descr: str) -> bool: |     def cbonk(self, g: Garda, v: str, reason: str, descr: str) -> bool: | ||||||
|  |         cond = self.args.dont_ban | ||||||
|  |         if ( | ||||||
|  |             cond == "any" | ||||||
|  |             or (cond == "auth" and self.uname != "*") | ||||||
|  |             or (cond == "aa" and self.avol) | ||||||
|  |             or (cond == "av" and self.can_admin) | ||||||
|  |             or (cond == "rw" and self.can_read and self.can_write) | ||||||
|  |         ): | ||||||
|  |             return False | ||||||
|  | 
 | ||||||
|         self.conn.hsrv.nsus += 1 |         self.conn.hsrv.nsus += 1 | ||||||
|         if not g.lim: |         if not g.lim: | ||||||
|             return False |             return False | ||||||
|  |  | ||||||
|  | @ -167,7 +167,7 @@ class Cfg(Namespace): | ||||||
|         ex = "ah_alg bname chdir chmod_f chpw_db doctitle df exit favico ipa html_head html_head_d html_head_s idp_login idp_logout lg_sba lg_sbf log_fk md_sba md_sbf name og_desc og_site og_th og_title og_title_a og_title_v og_title_i opds_exts shr tcolor textfiles txt_eol ufavico ufavico_h unlist vname xff_src zipmaxt R RS SR" |         ex = "ah_alg bname chdir chmod_f chpw_db doctitle df exit favico ipa html_head html_head_d html_head_s idp_login idp_logout lg_sba lg_sbf log_fk md_sba md_sbf name og_desc og_site og_th og_title og_title_a og_title_v og_title_i opds_exts shr tcolor textfiles txt_eol ufavico ufavico_h unlist vname xff_src zipmaxt R RS SR" | ||||||
|         ka.update(**{k: "" for k in ex.split()}) |         ka.update(**{k: "" for k in ex.split()}) | ||||||
| 
 | 
 | ||||||
|         ex = "ban_403 ban_404 ban_422 ban_pw ban_pwc ban_url spinner" |         ex = "ban_403 ban_404 ban_422 ban_pw ban_pwc ban_url dont_ban spinner" | ||||||
|         ka.update(**{k: "no" for k in ex.split()}) |         ka.update(**{k: "no" for k in ex.split()}) | ||||||
| 
 | 
 | ||||||
|         ex = "ext_th grp idp_h_usr idp_hm_usr ipr on403 on404 qr_file xac xad xar xau xban xbc xbd xbr xbu xiu xm" |         ex = "ext_th grp idp_h_usr idp_hm_usr ipr on403 on404 qr_file xac xad xar xau xban xbc xbd xbr xbu xiu xm" | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue