(config, is_local)
| 121 | |
| 122 | |
| 123 | def check_config(config, is_local): |
| 124 | if config.get('daemon', None) == 'stop': |
| 125 | # no need to specify configuration for daemon stop |
| 126 | return |
| 127 | |
| 128 | if is_local: |
| 129 | if config.get('server', None) is None: |
| 130 | logging.error('server addr not specified') |
| 131 | print_local_help() |
| 132 | sys.exit(2) |
| 133 | else: |
| 134 | config['server'] = to_str(config['server']) |
| 135 | else: |
| 136 | config['server'] = to_str(config.get('server', '0.0.0.0')) |
| 137 | try: |
| 138 | config['forbidden_ip'] = \ |
| 139 | IPNetwork(config.get('forbidden_ip', '127.0.0.0/8,::1/128')) |
| 140 | except Exception as e: |
| 141 | logging.error(e) |
| 142 | sys.exit(2) |
| 143 | |
| 144 | if is_local and not config.get('password', None): |
| 145 | logging.error('password not specified') |
| 146 | print_help(is_local) |
| 147 | sys.exit(2) |
| 148 | |
| 149 | if not is_local and not config.get('password', None) \ |
| 150 | and not config.get('port_password', None) \ |
| 151 | and not config.get('manager_address'): |
| 152 | logging.error('password or port_password not specified') |
| 153 | print_help(is_local) |
| 154 | sys.exit(2) |
| 155 | |
| 156 | if 'local_port' in config: |
| 157 | config['local_port'] = int(config['local_port']) |
| 158 | |
| 159 | if 'server_port' in config and type(config['server_port']) != list: |
| 160 | config['server_port'] = int(config['server_port']) |
| 161 | |
| 162 | if config.get('local_address', '') in [b'0.0.0.0']: |
| 163 | logging.warn('warning: local set to listen on 0.0.0.0, it\'s not safe') |
| 164 | if config.get('server', '') in ['127.0.0.1', 'localhost']: |
| 165 | logging.warn('warning: server set to listen on %s:%s, are you sure?' % |
| 166 | (to_str(config['server']), config['server_port'])) |
| 167 | if (config.get('method', '') or '').lower() == 'table': |
| 168 | logging.warn('warning: table is not safe; please use a safer cipher, ' |
| 169 | 'like AES-256-CFB') |
| 170 | if (config.get('method', '') or '').lower() == 'rc4': |
| 171 | logging.warn('warning: RC4 is not safe; please use a safer cipher, ' |
| 172 | 'like AES-256-CFB') |
| 173 | if config.get('timeout', 300) < 100: |
| 174 | logging.warn('warning: your timeout %d seems too short' % |
| 175 | int(config.get('timeout'))) |
| 176 | if config.get('timeout', 300) > 600: |
| 177 | logging.warn('warning: your timeout %d seems too long' % |
| 178 | int(config.get('timeout'))) |
| 179 | if config.get('password') in [b'mypassword']: |
| 180 | logging.error('DON\'T USE DEFAULT PASSWORD! Please change it in your ' |
no test coverage detected