This repository has been archived by the owner on Jul 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
close #22: Auto update ressources as needed
- Loading branch information
Showing
7 changed files
with
52 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,4 @@ | ||
lists/x* | ||
lists/ipout-hosts | ||
lists/ipout-protected | ||
tmp/ | ||
|
||
*.pyc | ||
*.txt | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import urllib.request | ||
import zipfile | ||
import os | ||
import sys | ||
import time | ||
|
||
class Updater: | ||
def run(): | ||
if Updater.uptodate(): | ||
return | ||
|
||
downloads = [ | ||
['https://www.cloudflare.com/ips-v4', 'lists/cloudflare_ipv4'], | ||
['https://www.cloudflare.com/ips-v6', 'lists/cloudflare_ipv6'], | ||
] | ||
|
||
for d in downloads: | ||
Updater.download(d[0], d[1]) | ||
|
||
Updater.last_updated(Updater.today()) | ||
print('') | ||
|
||
|
||
def uptodate(): | ||
last_updated = open('lists/last_updated', 'r').read() | ||
if last_updated == Updater.today(): | ||
return True | ||
return False | ||
|
||
def last_updated(date): | ||
file = open('lists/last_updated', 'w') | ||
file.write(date) | ||
file.close | ||
|
||
def today(): | ||
return time.strftime("%Y-%m-%d") | ||
|
||
def download(url, file): | ||
print('[download] %s' % url) | ||
try: | ||
urllib.request.urlretrieve(url, file) | ||
except (OSError, HTTPError, http.client.BadStatusLine): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
last_updated | ||
cloudflare_ip* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2018-03-29 |
This file was deleted.
Oops, something went wrong.