OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 """Connect to a WiFi service and report the amount of time it took | 3 """Connect to a WiFi service and report the amount of time it took |
4 | 4 |
5 This script initiates a connection to a WiFi service and reports | 5 This script initiates a connection to a WiFi service and reports |
6 the time to major state changes (assoc, config). If the connection | 6 the time to major state changes (assoc, config). If the connection |
7 fails within the desired time, it outputs the contents of the log | 7 fails within the desired time, it outputs the contents of the log |
8 files during that intervening time. | 8 files during that intervening time. |
9 | 9 |
10 """ | 10 """ |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 150 |
151 connection_settings = { | 151 connection_settings = { |
152 'Type': 'wifi', | 152 'Type': 'wifi', |
153 'Mode': 'managed', | 153 'Mode': 'managed', |
154 'SSID': ssid, | 154 'SSID': ssid, |
155 'Security': security | 155 'Security': security |
156 } | 156 } |
157 | 157 |
158 if security == '802_1x': | 158 if security == '802_1x': |
159 cert_args = psk.split(':') | 159 cert_args = psk.split(':') |
160 (connection_settings['Identity'], | 160 if cert_args[0] == 'EAP-TLS': |
161 connection_settings['CertPath']) = cert_args[:2] | 161 (connection_settings['Identity'], |
162 if len(cert_args) > 2: | 162 connection_settings['CertPath']) = cert_args[1:3] |
163 connection_settings['AuthorityPath'] = cert_args[2] | 163 if len(cert_args) > 3: |
| 164 connection_settings['AuthorityPath'] = cert_args[3] |
| 165 elif (cert_args[0] == 'EAP-PEAP' or |
| 166 cert_args[0] == 'EAP-TTLS'): |
| 167 (connection_settings['Identity'], |
| 168 connection_settings['Passphrase']) = cert_args[1:3] |
| 169 if len(cert_args) > 3: |
| 170 connection_settings['AuthorityPath'] = cert_args[3] |
164 else: | 171 else: |
165 connection_settings['Passphrase'] = psk | 172 connection_settings['Passphrase'] = psk |
166 | 173 |
167 global logs | 174 global logs |
168 global handler | 175 global handler |
169 logs = OpenLogs('/var/log/messages') | 176 logs = OpenLogs('/var/log/messages') |
170 | 177 |
171 assoc_start = time.time() | 178 assoc_start = time.time() |
172 handler = ConnectStateHandler(bus, connection_settings, options.hidden, | 179 handler = ConnectStateHandler(bus, connection_settings, options.hidden, |
173 assoc_timeout, assoc_start, options.debug) | 180 assoc_timeout, assoc_start, options.debug) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 215 |
209 print ('OK %3.1f %3.1f %s (assoc and config times in sec, quirks)' % | 216 print ('OK %3.1f %3.1f %s (assoc and config times in sec, quirks)' % |
210 (assoc_time, config_time, str(connect_quirks.keys()))) | 217 (assoc_time, config_time, str(connect_quirks.keys()))) |
211 | 218 |
212 if connect_quirks: | 219 if connect_quirks: |
213 DumpLogs(logs) | 220 DumpLogs(logs) |
214 sys.exit(0) | 221 sys.exit(0) |
215 | 222 |
216 if __name__ == '__main__': | 223 if __name__ == '__main__': |
217 main(sys.argv) | 224 main(sys.argv) |
OLD | NEW |