-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from mingcheng/master
增加在线获取最新数据库并直接运行
- Loading branch information
Showing
7 changed files
with
142 additions
and
24 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
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,57 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"compress/zlib" | ||
"encoding/binary" | ||
"io/ioutil" | ||
"net/http" | ||
) | ||
|
||
// @ref https://zhangzifan.com/update-qqwry-dat.html | ||
|
||
func getKey() (uint32, error) { | ||
resp, err := http.Get("http://update.cz88.net/ip/copywrite.rar") | ||
if err != nil { | ||
return 0, err | ||
} | ||
defer resp.Body.Close() | ||
|
||
if body, err := ioutil.ReadAll(resp.Body); err != nil { | ||
return 0, err | ||
} else { | ||
// @see https://stackoverflow.com/questions/34078427/how-to-read-packed-binary-data-in-go | ||
return binary.LittleEndian.Uint32(body[5*4:]), nil | ||
} | ||
} | ||
|
||
func GetOnline() ([]byte, error) { | ||
resp, err := http.Get("http://update.cz88.net/ip/qqwry.rar") | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
|
||
if body, err := ioutil.ReadAll(resp.Body); err != nil { | ||
return nil, err | ||
} else { | ||
if key, err := getKey(); err != nil { | ||
return nil, err | ||
} else { | ||
for i := 0; i < 0x200; i++ { | ||
key = key * 0x805 | ||
key++ | ||
key = key & 0xff | ||
|
||
body[i] = byte(uint32(body[i]) ^ key) | ||
} | ||
|
||
reader, err := zlib.NewReader(bytes.NewReader(body)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return ioutil.ReadAll(reader) | ||
} | ||
} | ||
} |
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,22 @@ | ||
<?php | ||
// PHP 纯真 IP 地址数据库自动更新功能 | ||
// @from https://zhangzifan.com/update-qqwry-dat.html | ||
$copywrite = file_get_contents("http://update.cz88.net/ip/copywrite.rar"); | ||
$qqwry = file_get_contents("http://update.cz88.net/ip/qqwry.rar"); | ||
|
||
$key = unpack("V6", $copywrite)[6]; | ||
|
||
for ($i = 0; $i < 0x200; $i++) { | ||
$key *= 0x805; | ||
$key++; | ||
$key = $key & 0xFF; | ||
$qqwry[$i] = chr(ord($qqwry[$i]) ^ $key); | ||
} | ||
|
||
$qqwry = gzuncompress($qqwry); | ||
$fp = fopen("qqwry.dat", "wb"); | ||
if ($fp) { | ||
fwrite($fp, $qqwry); | ||
fclose($fp); | ||
} | ||
|
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,8 @@ | ||
module github.com/freshcn/qqwry | ||
|
||
go 1.12 | ||
|
||
require ( | ||
github.com/pquerna/ffjson v0.0.0-20181028064349-e517b90714f7 | ||
golang.org/x/text v0.3.2 | ||
) |
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,5 @@ | ||
github.com/pquerna/ffjson v0.0.0-20181028064349-e517b90714f7 h1:gGBSHPOU7g8YjTbhwn+lvFm2VDEhhA+PwDIlstkgSxE= | ||
github.com/pquerna/ffjson v0.0.0-20181028064349-e517b90714f7/go.mod h1:YARuvh7BUWHNhzDq2OM5tzR2RiCcN2D7sapiKyCel/M= | ||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= | ||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= | ||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.