├── .gitignore ├── LICENSE ├── Pipfile ├── Pipfile.lock ├── README.md └── main.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### JetBrains template 3 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 4 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 5 | 6 | # User-specific stuff 7 | .idea/**/workspace.xml 8 | .idea/**/tasks.xml 9 | .idea/**/dictionaries 10 | .idea/**/shelf 11 | 12 | # Sensitive or high-churn files 13 | .idea/**/dataSources/ 14 | .idea/**/dataSources.ids 15 | .idea/**/dataSources.local.xml 16 | .idea/**/sqlDataSources.xml 17 | .idea/**/dynamic.xml 18 | .idea/**/uiDesigner.xml 19 | .idea/**/dbnavigator.xml 20 | 21 | # Gradle 22 | .idea/**/gradle.xml 23 | .idea/**/libraries 24 | 25 | # CMake 26 | cmake-build-debug/ 27 | cmake-build-release/ 28 | 29 | # Mongo Explorer plugin 30 | .idea/**/mongoSettings.xml 31 | 32 | # File-based project format 33 | *.iws 34 | 35 | # IntelliJ 36 | out/ 37 | 38 | # mpeltonen/sbt-idea plugin 39 | .idea_modules/ 40 | 41 | # JIRA plugin 42 | atlassian-ide-plugin.xml 43 | 44 | # Cursive Clojure plugin 45 | .idea/replstate.xml 46 | 47 | # Crashlytics plugin (for Android Studio and IntelliJ) 48 | com_crashlytics_export_strings.xml 49 | crashlytics.properties 50 | crashlytics-build.properties 51 | fabric.properties 52 | 53 | # Editor-based Rest Client 54 | .idea/httpRequests 55 | ### Eclipse template 56 | 57 | .metadata 58 | bin/ 59 | tmp/ 60 | *.tmp 61 | *.bak 62 | *.swp 63 | *~.nib 64 | local.properties 65 | .settings/ 66 | .loadpath 67 | .recommenders 68 | 69 | # External tool builders 70 | .externalToolBuilders/ 71 | 72 | # Locally stored "Eclipse launch configurations" 73 | *.launch 74 | 75 | # PyDev specific (Python IDE for Eclipse) 76 | *.pydevproject 77 | 78 | # CDT-specific (C/C++ Development Tooling) 79 | .cproject 80 | 81 | # CDT- autotools 82 | .autotools 83 | 84 | # Java annotation processor (APT) 85 | .factorypath 86 | 87 | # PDT-specific (PHP Development Tools) 88 | .buildpath 89 | 90 | # sbteclipse plugin 91 | .target 92 | 93 | # Tern plugin 94 | .tern-project 95 | 96 | # TeXlipse plugin 97 | .texlipse 98 | 99 | # STS (Spring Tool Suite) 100 | .springBeans 101 | 102 | # Code Recommenders 103 | .recommenders/ 104 | 105 | # Scala IDE specific (Scala & Java development for Eclipse) 106 | .cache-main 107 | .scala_dependencies 108 | .worksheet 109 | ### Windows template 110 | # Windows thumbnail cache files 111 | Thumbs.db 112 | ehthumbs.db 113 | ehthumbs_vista.db 114 | 115 | # Dump file 116 | *.stackdump 117 | 118 | # Folder config file 119 | [Dd]esktop.ini 120 | 121 | # Recycle Bin used on file shares 122 | $RECYCLE.BIN/ 123 | 124 | # Windows Installer files 125 | *.cab 126 | *.msi 127 | *.msix 128 | *.msm 129 | *.msp 130 | 131 | # Windows shortcuts 132 | *.lnk 133 | ### Python template 134 | # Byte-compiled / optimized / DLL files 135 | __pycache__/ 136 | *.py[cod] 137 | *$py.class 138 | 139 | # C extensions 140 | *.so 141 | 142 | # Distribution / packaging 143 | .Python 144 | build/ 145 | develop-eggs/ 146 | dist/ 147 | downloads/ 148 | eggs/ 149 | .eggs/ 150 | lib/ 151 | lib64/ 152 | parts/ 153 | sdist/ 154 | var/ 155 | wheels/ 156 | *.egg-info/ 157 | .installed.cfg 158 | *.egg 159 | MANIFEST 160 | 161 | # PyInstaller 162 | # Usually these files are written by a python script from a template 163 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 164 | *.manifest 165 | *.spec 166 | 167 | # Installer logs 168 | pip-log.txt 169 | pip-delete-this-directory.txt 170 | 171 | # Unit test / coverage reports 172 | htmlcov/ 173 | .tox/ 174 | .coverage 175 | .coverage.* 176 | .cache 177 | nosetests.xml 178 | coverage.xml 179 | *.cover 180 | .hypothesis/ 181 | .pytest_cache/ 182 | 183 | # Translations 184 | *.mo 185 | *.pot 186 | 187 | # Django stuff: 188 | *.log 189 | local_settings.py 190 | db.sqlite3 191 | 192 | # Flask stuff: 193 | instance/ 194 | .webassets-cache 195 | 196 | # Scrapy stuff: 197 | .scrapy 198 | 199 | # Sphinx documentation 200 | docs/_build/ 201 | 202 | # PyBuilder 203 | target/ 204 | 205 | # Jupyter Notebook 206 | .ipynb_checkpoints 207 | 208 | # pyenv 209 | .python-version 210 | 211 | # celery beat schedule file 212 | celerybeat-schedule 213 | 214 | # SageMath parsed files 215 | *.sage.py 216 | 217 | # Environments 218 | .env 219 | .venv 220 | env/ 221 | venv/ 222 | ENV/ 223 | env.bak/ 224 | venv.bak/ 225 | 226 | # Spyder project settings 227 | .spyderproject 228 | .spyproject 229 | 230 | # Rope project settings 231 | .ropeproject 232 | 233 | # mkdocs documentation 234 | /site 235 | 236 | # mypy 237 | .mypy_cache/ 238 | 239 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 ercJuL 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Pipfile: -------------------------------------------------------------------------------- 1 | [[source]] 2 | name = "pypi" 3 | url = "https://pypi.org/simple" 4 | verify_ssl = true 5 | 6 | [dev-packages] 7 | 8 | [packages] 9 | 10 | [requires] 11 | python_version = "3.7" 12 | -------------------------------------------------------------------------------- /Pipfile.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_meta": { 3 | "hash": { 4 | "sha256": "7e7ef69da7248742e869378f8421880cf8f0017f96d94d086813baa518a65489" 5 | }, 6 | "pipfile-spec": 6, 7 | "requires": { 8 | "python_version": "3.7" 9 | }, 10 | "sources": [ 11 | { 12 | "name": "pypi", 13 | "url": "https://pypi.org/simple", 14 | "verify_ssl": true 15 | } 16 | ] 17 | }, 18 | "default": {}, 19 | "develop": {} 20 | } 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Iris_enable_py 2 | iris 本地激活 3 | 克隆后管理员或root权限运行,有问题提Issues 4 | 5 | - mac/Linux 6 | `sudo python3 main.py` 7 | 8 | - windows 9 | 管理员权限打开cmd 10 | ``` 11 | cd [main.py目录] 12 | python main.py 13 | ``` 14 | 15 | |系统|Iris 版本|测试结果| 16 | |:---:|:---:|:---:| 17 | |Ubuntu 16.04.5 LTS|Iris-0.9.9-Linux-64bit.zip|:heavy_check_mark:| 18 | |Win10 Pro 17763|Iris-1.1.2.3.exe|:heavy_check_mark:| 19 | |Mac 10.13.4|Iris-1.1.2-OSX.zip|:heavy_check_mark:| 20 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import os 2 | import platform 3 | import re 4 | import socket 5 | import sys 6 | import time 7 | from http import HTTPStatus 8 | from http.server import BaseHTTPRequestHandler, HTTPServer 9 | from threading import Thread 10 | 11 | setting = { 12 | 'hosts_path': { 13 | 'linux': '/etc/hosts', 14 | 'darwin': '/etc/hosts', 15 | 'windows': 'C:/Windows/System32/drivers/etc/hosts' 16 | }, 17 | 'flush_dns_cmd': { 18 | 'linux': ['/etc/init.d/nscd restart', ], 19 | 'darwin': ['killall -HUP mDNSResponder', ], 20 | 'windows': ['ipconfig /flushdns', ] 21 | } 22 | } 23 | 24 | 25 | class MyHttpServer(BaseHTTPRequestHandler): 26 | def do_GET(self): 27 | """Serve a GET request.""" 28 | self.send_response(HTTPStatus.OK) 29 | self.end_headers() 30 | self.wfile.write(b'SUCCESS') # 此处修改返回标识 31 | print('本地服务器启动') 32 | 33 | 34 | def change_hosts(sys_type): 35 | host_path = setting['hosts_path'][sys_type] 36 | with open(host_path, 'r') as f: 37 | txt = f.read() 38 | try: 39 | if 'iristech.co' in txt: 40 | txt = re.sub('.+?iristech.co.*?', '127.0.0.1 iristech.co', txt) 41 | with open(host_path, 'w') as f: 42 | f.write(txt) 43 | else: 44 | with open(host_path, 'a') as f: 45 | f.writelines('\n127.0.0.1 iristech.co\n') 46 | except PermissionError as err: 47 | print('权限不足,请以管理员或root权限运行') 48 | sys.exit(1) 49 | 50 | 51 | def get_ip(): 52 | addr_info = socket.getaddrinfo('iristech.co', 'http') 53 | return addr_info[0][4][0] 54 | 55 | 56 | def exe_cmd(sys_type): 57 | for index, cmd in enumerate(setting['flush_dns_cmd'][sys_type]): 58 | cmd_result = os.system(cmd) 59 | if cmd_result == 0: 60 | return 61 | print('执行命令 %s 出错' % cmd) 62 | print('尝试执行下一条命令') 63 | else: 64 | print('执行dns刷新命令出错') 65 | 66 | 67 | if __name__ == '__main__': 68 | print('''############################### 69 | Iris Pro 本地激活 70 | ###############################''') 71 | sys_type = platform.system() 72 | print('1 ==> 系统类型: ', sys_type) 73 | sys_type = sys_type.lower() 74 | iris_ip = get_ip() 75 | print('2 ==> iristech.co 指向 ', iris_ip) 76 | if iris_ip != '127.0.0.1': 77 | is_true = input('此 %s ip是否为激活服务器IP? (y/N)' % iris_ip) 78 | if is_true.lower() != 'y': 79 | change_hosts(sys_type) 80 | for try_count in range(5): 81 | exe_cmd(sys_type) 82 | iris_ip = get_ip() 83 | print('iristech.co ==> ', iris_ip) 84 | if iris_ip == '127.0.0.1': 85 | print('IP已指向本地服务器') 86 | break 87 | time.sleep(1) 88 | else: 89 | print('ERROR: IP指向仍然错误,程序终止,请手动设置 iristech.co 指向 127.0.0.1') 90 | print('提示: 百度 "[所用系统] 修改 hosts"') 91 | print('提示: 百度 "[所用系统] 刷新dns"') 92 | sys.exit(1) 93 | 94 | http_server = HTTPServer(('', int(80)), MyHttpServer) 95 | thread = Thread(target=http_server.serve_forever) 96 | thread.start() 97 | print('服务已启动') 98 | print('3 ==> 打开软件输入任意激活码激活') 99 | --------------------------------------------------------------------------------