| 29 | return True |
| 30 | |
| 31 | def checkIdletimeout(haproxyData, haCfgSections): |
| 32 | if "idletimeout" not in haproxyData: |
| 33 | return True |
| 34 | |
| 35 | # Normalize idletimeout value to string for comparison |
| 36 | idle_value = str(haproxyData["idletimeout"]).strip() |
| 37 | |
| 38 | # Safely get the defaults section and its timeout directives |
| 39 | defaults_section = haCfgSections.get("defaults", {}) |
| 40 | timeout_lines = defaults_section.get("timeout", []) |
| 41 | |
| 42 | # Extract client and server timeout values from the parsed "timeout" entries |
| 43 | timeout_values = {} |
| 44 | for tline in timeout_lines: |
| 45 | tline = tline.strip() |
| 46 | if not tline: |
| 47 | continue |
| 48 | parts = tline.split(None, 1) |
| 49 | if len(parts) < 2: |
| 50 | continue |
| 51 | kind, value = parts[0].strip(), parts[1].strip() |
| 52 | if kind in ("client", "server"): |
| 53 | timeout_values[kind] = value |
| 54 | |
| 55 | # Special handling for idletimeout == 0: there should be no client/server timeouts configured |
| 56 | if idle_value == "0": |
| 57 | if "client" in timeout_values or "server" in timeout_values: |
| 58 | print("defaults timeout client or timeout server should be absent when idletimeout is 0") |
| 59 | return False |
| 60 | return True |
| 61 | |
| 62 | # Non-zero idletimeout: both client and server timeouts must be present |
| 63 | if "client" not in timeout_values or "server" not in timeout_values: |
| 64 | print("defaults timeout client or timeout server missing") |
| 65 | return False |
| 66 | |
| 67 | if idle_value != timeout_values["client"] or idle_value != timeout_values["server"]: |
| 68 | print("defaults timeout client or timeout server mismatch occurred") |
| 69 | return False |
| 70 | return True |
| 71 | |
| 72 | def checkLoadBalance(haproxyData, haCfgSections): |
| 73 | correct = True |