├── Mirroring website
├── .gitignore
├── .htaccess
├── Licence.txt
├── admin
│ ├── getjob.php
│ ├── include
│ │ ├── contentfileter.class.php
│ │ ├── cookie.class.php
│ │ ├── functions.php
│ │ ├── httpparser.class.php
│ │ ├── jobs.class.php
│ │ └── spider.class.php
│ └── jobs.txt
├── config.php
├── daemon
│ └── systemd.php
├── data
│ ├── article.db
│ ├── config.db
│ ├── job.db
│ ├── job
│ │ └── pageurl.sql
│ ├── jobs.db
│ ├── readme.txt
│ └── struct
│ │ ├── article.sql
│ │ ├── config.sql
│ │ ├── cookie.sql
│ │ ├── job_d.sql
│ │ └── jobs.sql
├── include
│ ├── common.class.php
│ ├── db.class.php
│ ├── filesystem.class.php
│ ├── functions.php
│ └── router.class.php
├── index.php
├── init.php
├── model
│ └── index.php
├── robots.txt
├── save.php
├── sitemap.php
├── template
│ ├── about.php
│ ├── category.html
│ ├── error.php
│ ├── images
│ │ ├── banner1.jpg
│ │ ├── banner2.jpg
│ │ └── banner3.jpg
│ ├── index.html
│ ├── single.html
│ └── style.css
└── uploads
│ └── default-thumbnail.jpg
├── auto website
├── .htaccess
├── config.php
├── cookie.txt
├── data
│ └── key.txt
├── favicon.ico
├── index.php
├── init.php
├── lib
│ ├── content.class.php
│ ├── content.php
│ ├── list.class.php
│ └── router.class.php
└── templates
│ ├── functions.php
│ ├── index.php
│ ├── media
│ ├── 70years.jpg
│ ├── 70years.png
│ ├── banner1.jpg
│ ├── banner10.jpg
│ ├── banner11.jpg
│ ├── banner12.jpg
│ ├── banner13.jpg
│ ├── banner14.jpg
│ ├── banner15.jpg
│ ├── banner16.jpg
│ ├── banner17.jpg
│ ├── banner18.jpg
│ ├── banner2.jpg
│ ├── banner3.jpg
│ ├── banner4.jpg
│ ├── banner5.jpg
│ ├── banner6.jpg
│ ├── banner7.jpg
│ ├── banner8.jpg
│ ├── banner9.jpg
│ ├── form1.js
│ ├── main-products.jpg
│ └── style.css
│ ├── robots.php
│ ├── single.php
│ └── sitemap.php
├── baidu-collect-check
└── urlcheck.py
├── baidusubmit
└── main.py
├── bdtranlate.py
├── delete-short-posts
└── delete-short-posts.php
├── directindustry.com
├── a.json
├── collection.py
├── collection.pyc
├── company.py
├── endb
└── xx.html
├── domai-cron-submit
├── dm_submit.py
└── replace.txt
├── domai-time-modifie
└── modifie.php
├── email-recorder
├── .htaccess
├── openlog.php
└── unsubscribe.php
├── get-google-image
├── collection.py
├── downimg.py
└── google.py
├── get-related-company
└── getcom.py
├── invalid-email-filter
├── dns
│ ├── __init__.py
│ ├── dnssec.py
│ ├── e164.py
│ ├── edns.py
│ ├── entropy.py
│ ├── exception.py
│ ├── flags.py
│ ├── grange.py
│ ├── hash.py
│ ├── inet.py
│ ├── ipv4.py
│ ├── ipv6.py
│ ├── message.py
│ ├── name.py
│ ├── namedict.py
│ ├── node.py
│ ├── opcode.py
│ ├── query.py
│ ├── rcode.py
│ ├── rdata.py
│ ├── rdataclass.py
│ ├── rdataset.py
│ ├── rdatatype.py
│ ├── rdtypes
│ │ ├── ANY
│ │ │ ├── AFSDB.py
│ │ │ ├── CERT.py
│ │ │ ├── CNAME.py
│ │ │ ├── DLV.py
│ │ │ ├── DNAME.py
│ │ │ ├── DNSKEY.py
│ │ │ ├── DS.py
│ │ │ ├── GPOS.py
│ │ │ ├── HINFO.py
│ │ │ ├── HIP.py
│ │ │ ├── ISDN.py
│ │ │ ├── LOC.py
│ │ │ ├── MX.py
│ │ │ ├── NS.py
│ │ │ ├── NSEC.py
│ │ │ ├── NSEC3.py
│ │ │ ├── NSEC3PARAM.py
│ │ │ ├── PTR.py
│ │ │ ├── RP.py
│ │ │ ├── RRSIG.py
│ │ │ ├── RT.py
│ │ │ ├── SOA.py
│ │ │ ├── SPF.py
│ │ │ ├── SSHFP.py
│ │ │ ├── TLSA.py
│ │ │ ├── TXT.py
│ │ │ ├── X25.py
│ │ │ └── __init__.py
│ │ ├── IN
│ │ │ ├── A.py
│ │ │ ├── AAAA.py
│ │ │ ├── APL.py
│ │ │ ├── DHCID.py
│ │ │ ├── IPSECKEY.py
│ │ │ ├── KX.py
│ │ │ ├── NAPTR.py
│ │ │ ├── NSAP.py
│ │ │ ├── NSAP_PTR.py
│ │ │ ├── PX.py
│ │ │ ├── SRV.py
│ │ │ ├── WKS.py
│ │ │ └── __init__.py
│ │ ├── __init__.py
│ │ ├── dsbase.py
│ │ ├── mxbase.py
│ │ ├── nsbase.py
│ │ └── txtbase.py
│ ├── renderer.py
│ ├── resolver.py
│ ├── reversename.py
│ ├── rrset.py
│ ├── set.py
│ ├── tokenizer.py
│ ├── tsig.py
│ ├── tsigkeyring.py
│ ├── ttl.py
│ ├── update.py
│ ├── version.py
│ ├── wiredata.py
│ └── zone.py
└── emailfilter.py
├── ixquick.php
├── offline sms
└── sms_market.html
├── renamedirbyorder.py
├── semtools
├── get_url.py
├── getadpage.exe
└── getadpage.py
├── txtcuter.py
├── upload.php
└── zip.php
/Mirroring website/.gitignore:
--------------------------------------------------------------------------------
1 | w/
2 | caches/
3 | filesystem/
4 |
--------------------------------------------------------------------------------
/Mirroring website/.htaccess:
--------------------------------------------------------------------------------
1 |
2 | RewriteEngine On
3 | RewriteBase /
4 | RewriteCond %{REQUEST_FILENAME} !-f
5 | RewriteCond %{REQUEST_FILENAME} !-d
6 | RewriteRule . /index.php [L]
7 |
8 |
--------------------------------------------------------------------------------
/Mirroring website/Licence.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hitoy/seotools/950dc87fcb82306c5f8d4f936289f1d21ed41329/Mirroring website/Licence.txt
--------------------------------------------------------------------------------
/Mirroring website/admin/getjob.php:
--------------------------------------------------------------------------------
1 | content=$content;
11 | }
12 |
13 | /*字符串替换*/
14 | public function strreplace($find,$replace,$ignore=true){
15 | if()
16 | if($ignore==true){
17 | $this->content=str_ireplace($find,$replace,$this->content);
18 | }else{
19 | $this->content=str_replace($find,$replace,$this->content);
20 | }
21 | }else if(is_array($find) && is_array($replace)){
22 |
23 | }
24 | }
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/Mirroring website/admin/include/cookie.class.php:
--------------------------------------------------------------------------------
1 | urire,$url,$match);
14 | if(empty($match)) throw new Exception("$url is Not a legal URL");
15 | $this->protocols=$match[1];
16 | $this->domain=$match[2];
17 | }
18 |
19 | public function take(SQLite3 $db){
20 | $db->getone("select from cookie where domain = $this->domain and time() < time");
21 |
22 |
23 | }
24 |
25 | public function storage($jsondata){
26 | $obj = json_decode($jsondata);
27 | foreach($obj as $data){
28 |
29 | }
30 | }
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | }
40 |
41 | /*
42 | require_once("spider.class.php");
43 | require_once("httpparser.class.php");
44 | //1,初始化蜘蛛
45 | $spider = new Spider("https://www.baidu.com/");
46 | //2,看是否有cookie
47 | //3,爬行,获取内容和cookie,并保存
48 |
49 |
50 | $rawhttp = $spider->crawl();
51 |
52 | $http = new HTTPParser($rawhttp);
53 |
54 | echo $http->get_cookie();
55 | */
56 | $a = new COOKIE("https://www.hitoy.org/super/sfasaf.html");
57 | print_r($a);
58 |
--------------------------------------------------------------------------------
/Mirroring website/admin/include/httpparser.class.php:
--------------------------------------------------------------------------------
1 | httpreg,$rawdata,$match);
33 | if(empty($match)) throw new Exception("Not a HTTP Response!");
34 | $this->$rawdata=$rawdata;
35 | $this->version=$match[1];
36 | $this->status=$match[2];
37 | $this->rawheader=$match[3];
38 | $this->rawhtml=$match[5];
39 | $this->__init__();
40 | }
41 |
42 | //初始化
43 | protected function __init__(){
44 | $tmp=explode("\r\n",$this->rawheader);
45 | foreach($tmp as $list){
46 | //jump if empty
47 | if(empty($list)) continue;
48 | //split
49 | $key = trim(substr($list,0,strpos($list,":")));
50 | $value = trim(substr($list,strpos($list,":")+1));
51 | //cookie process
52 | //cookie format:array("data"=>array("key1"=>"value1","key2"=>"value2"...),"expires"=>'','max-age'=>'','path'=>"",'domain'=>'')
53 | $headercookie=array("data"=>array(),"expires"=>gmdate('D, d M Y H:i:s T'),"max-age"=>0,"path"=>NULL,"domain"=>NULL);
54 | if(strtolower($key)=='set-cookie'){
55 | preg_match_all($this->cookiereg,$value.";",$match);
56 | $i = 0;
57 | for($i=0;$i$cookvalue));
64 | }
65 | }
66 | array_push($this->cookie,$headercookie);
67 | }else{
68 | $this->header[$key]=$value;
69 | }
70 | }
71 | $this->encoding = isset($this->header['Content-Encoding'])?$this->header['Content-Encoding']:"";
72 | $this->charset = isset($this->header['Content-Type'])?substr($this->header['Content-Type'],strpos($this->header['Content-Type'],'=')+1):"";
73 | }
74 |
75 | public function get_html(){
76 | if($this->encoding=='gzip' && function_exists("gzdecode")){
77 | $this->html=gzdecode($this->rawhtml);
78 | return $this->html;
79 | }else if($this->encoding=='gzip' && !function_exists("gzdecode")){
80 | throw new Exception("System does not have a GZIP Libary, Please Install!");
81 | }else if($this->encoding=='' && function_exists("")){
82 | $this->html = gzuncompress($this->rawhtml);
83 | return $this->html;
84 | }else if($this->encoding=='' && !function_exists("")){
85 | throw new Exception("System does not have a GZIP Libary, Please Install!");
86 | }else if($this->encoding==""){
87 | $this->html = $this->rawhtml;
88 | return $this->html;
89 | }
90 | throw new Exception("Unkown Content-Encoding, system exists!");
91 | }
92 |
93 | public function get_cookie(){
94 | return json_encode($this->cookie);
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/Mirroring website/admin/include/jobs.class.php:
--------------------------------------------------------------------------------
1 | urlsre=func_get_arg(0);
27 | return true;
28 | }else if($argnum==2 && is_array(func_get_arg[0])){
29 | $this->mustcontain=func_get_arg[0];
30 | $this->notcontain=func_get_arg[1];
31 | return true;
32 | }else if($argnum==2 && is_string(func_get_arg[0])){
33 | $this->htmlstart=func_get_arg[0];
34 | $this->htmlend=func_get_arg[1];
35 | return true
36 | }
37 | return false;
38 | }
39 |
40 | //填入所有URL
41 | //包含两种:正常URL和range
42 | //range格式如下: http://www.example.com/page/(range(start,stop,step)).html
43 | //传入的参数为数组
44 | public function add_urls($urls){
45 | foreach($urls as $url){
46 |
47 |
48 | }
49 | }
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/Mirroring website/admin/include/spider.class.php:
--------------------------------------------------------------------------------
1 | "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8","Accept-Encoding"=>"gzip,deflate","Accept-Language"=>"zh-CN,zh;q=0.8","Cache-Control"=>"max-age:0","Connection"=>"keep-alive");
22 | #HTTP代理
23 | protected $_proxy=array();
24 | #POST DATA
25 | private $_post;
26 |
27 | public function __construct($useragent="Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",$timeout=5){
28 | $this->_useragent=$useragent;
29 | self::$timeout=$timeout;
30 | }
31 |
32 | public function add_header($key,$value){
33 | $this->_httpheader[$key] = $value;
34 | }
35 | public function rm_header($key){
36 | if(array_key_exists($key)){
37 | $this->_httpheader=delete_array($this->_httpheader,$key);
38 | return true;
39 | }
40 | return false;
41 | }
42 |
43 | public function set_useragent($useragent){
44 | $this->_useragent=$useragent;
45 | }
46 |
47 | public function setmethod($method){
48 | $this->_method=$method;
49 | }
50 |
51 | public function add_post(array $data){
52 | $this->_post=$data;
53 | $this->_method="POST";
54 | }
55 |
56 | public function add_proxy($proxy){
57 | $this->_proxy=$proxy;
58 | }
59 |
60 |
61 | protected function curlhandler($showheader=true){
62 | if(!function_exists("curl_init")) throw new Exception("Error,Curl libray does not exist!");
63 | $ch = curl_init();
64 | curl_setopt($ch,CURLOPT_URL,$this->_uri);
65 | //curl_setopt($ch,CURLOPT_CONNECTIONTIMEOUT,5);
66 | //curl_setopt($ch,CURLOPT_DNS_CACHE_TIMEOUT,self::DNS_CACHE_TIME);
67 | curl_setopt($ch,CURLOPT_COOKIE,$this->_cookie);
68 | curl_setopt($ch,CURLOPT_USERAGENT,$this->_useragent);
69 | curl_setopt($ch,CURLOPT_REFERER,$this->_referer);
70 | curl_setopt($ch,CURLOPT_HTTPHEADER,header_change($this->_httpheader));
71 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
72 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
73 | curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
74 | if($showheader==true){
75 | curl_setopt($ch,CURLOPT_HEADER,1);
76 | }
77 | if(!empty($this->_post)){
78 | curl_setopt($ch,CURL_POST,1);
79 | curl_setopt($ch,CURLOPT_POSTFILEDS,$this->_post);
80 | }
81 | return $ch;
82 | }
83 |
84 | public function set_cookie(array $data){
85 | $str='';
86 | foreach($data as $k=>$v){
87 | $str.=urlencode($k)."=".urlencode($v)."&";
88 | }
89 | $this->_cookie = trim($str,"&");
90 | }
91 |
92 | public function crawl($url,$showheader=true){
93 | $this->_uri=$url;
94 | $curlhandler = $this->curlhandler($showheader);
95 | $http = curl_exec($curlhandler);
96 | curl_close($curlhandler);
97 | return $http;
98 | }
99 | }
100 |
101 | #HTTP中二维数组请求头变为1维数组
102 | function header_change($array){
103 | $newarray=array();
104 | foreach($array as $k=>$v){
105 | array_push($newarray,"$k:$v");
106 | }
107 | return $newarray;
108 | }
109 | #删除二维数组中的某个元素
110 | function delete_array($array,$key){
111 | $newarray=array();
112 | foreach($array as $k=>$v){
113 | if($k==$key) continue;
114 | $newarray[$k]=$v;
115 | }
116 | return $newarray;
117 | }
118 |
--------------------------------------------------------------------------------
/Mirroring website/admin/jobs.txt:
--------------------------------------------------------------------------------
1 | /*
2 | urlstart:stop:step
3 | urlmustcontain:urlmustnotcontain:urlhtmlstart:urlhtmlend
4 | titlestart:titleend:callback
5 | contentstart:contentend:callback
6 | */
7 | ==========
8 | https\://www.hitoy.org/page/(*)1:10:1
9 | www.hitoy.org:/about:::
10 | ::
11 | :
Concrete Plant
11 |12 |- Home
13 | ".$cate['name']."";
16 | }
17 | ?>
18 |
19 |28 |
29 | HZS Fully Environmental-friendly Commercial Concrete Mixing Plant
30 |
31 |
32 |39 | 42 |-
43 |
44 |
45 |
46 |
47 |
48 |
49 |50 | 53 |
54 |$r
"; 59 | } 60 | return $r; 61 | } 62 | 63 | 64 | public function showall(){ 65 | $urls=array(); 66 | foreach($this->list as $s){ 67 | $fd=fopen($s,"r"); 68 | while(!feof($fd)){ 69 | $title=trim(fgets($fd)); 70 | if(strlen($title) > 0){ 71 | $url=urlencode(preg_replace("/[\s]+/i","-",$title)); 72 | array_push($urls,$url); 73 | } 74 | } 75 | fclose($fd); 76 | } 77 | return $urls; 78 | } 79 | 80 | 81 | public function __destruct(){ 82 | if(!empty($this->keyfd)){ 83 | fclose($this->keyfd); 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /auto website/lib/router.class.php: -------------------------------------------------------------------------------- 1 | name=trim($name); 5 | if($this->name=="/" || $this->name == "/index.php"){ 6 | $this->type="home"; 7 | }else if(substr($this->name,0,6) == "/page/"){ 8 | $this->type="page"; 9 | }else if(substr($this->name,0,10)=='/category/'){ 10 | $this->type="category"; 11 | }else if(substr($this->name,0,11) == '/robots.txt'){ 12 | $this->type="robots"; 13 | }else if(substr($this->name,0,12) == '/sitemap.xml'){ 14 | $this->type="sitemap"; 15 | }else{ 16 | $this->type="single"; 17 | } 18 | } 19 | 20 | public function route(){ 21 | global $list; 22 | if(file_exists("templates/functions.php")){ 23 | require("templates/functions.php"); 24 | } 25 | if($this->type=="home"){ 26 | $page = 1; 27 | require("templates/index.php"); 28 | }else if($this->type=="page"){ 29 | preg_match("/^\/page\/(\d*)/i",$this->name,$pagear); 30 | if($pagear){ 31 | $page = $pagear[1]; 32 | }else{ 33 | $page = 1; 34 | } 35 | require("templates/index.php"); 36 | }else if($this->type=="category"){ 37 | require("templates/category.php"); 38 | }else if($this->type=="sitemap"){ 39 | require("templates/sitemap.php"); 40 | }else if($this->type=="robots"){ 41 | require("templates/robots.php"); 42 | }else if($this->type=="single"){ 43 | preg_match("/^\/(.*)/",$this->name,$tarr); 44 | if($tarr){ 45 | $title = $tarr[1]; 46 | }else{ 47 | $title = ""; 48 | } 49 | require("templates/single.php"); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /auto website/templates/functions.php: -------------------------------------------------------------------------------- 1 | ') return $content; 19 | preg_match_all("/([\s\S\n]*?)<\/p>/i",$content,$match); 20 | if(!$match[0]) return $content; 21 | $content=""; 22 | foreach($match[0] as $t){ 23 | preg_match("/^([\s\S\n]*?)<\/h2>([\s\S\n]+)$/",$t,$cc); 24 | preg_match("/(.*?)<\/h\d>/i",$t,$m);
25 | $alt=strtolower($m[1]);
26 | $li="".$cc[1]."".show_rand_img($alt,1,"/images/").$cc[2]." \r\n";
27 | $content = $content.$li;
28 | }
29 | return $content;
30 | }
31 |
32 | function show_rand_img($alt="",$num=1,$dir="/uploads/"){
33 | $document_root=$_SERVER["DOCUMENT_ROOT"];
34 | $imgdir=$document_root.$dir;
35 | if(!file_exists($imgdir)) exit("图片目录不存在");
36 | $imgarr=scandir($imgdir);
37 | if($num>count($imgarr)) $num=count($imgarr);
38 | $re="";
39 | for($i=0;$i<$num;$i++){
40 | $s=rand(0,count($imgarr));
41 | if(!is_file($imgdir.$imgarr[$s])){$i--;continue;}
42 | $src="//".$_SERVER["HTTP_HOST"].$dir.$imgarr[$s];
43 | $re .= "
";
44 | }
45 | return $re;
46 | }
47 |
48 | //show totle artice
49 | function showarctile($alt,$content,$imgoffset=4,$imgdir="/uploads/"){
50 | $content=trim($content);
51 | if(substr($content,0,4) != '
10 |
11 | http:///
12 |
13 | http://".$_SERVER["HTTP_HOST"]."/".$file." \r\n";
18 | $i++;
19 | }
20 | closedir($dir);
21 | ?>
22 |
23 |
36 |
--------------------------------------------------------------------------------
/baidu-collect-check/urlcheck.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*-coding:utf-8 -*-
3 | # Baidu Url Check Tool
4 | # Author Hito Yang
5 | print u"百度收录检查工具 By Hito\r\n"
6 | import httplib,urllib,sys,gzip,StringIO,re,time
7 | jumpre = re.compile(r"http:\/\/www.baidu.com\/link\?url\=[^\"]*")
8 | urlre = re.compile(r"URL\=\'([^\'\"]*)")
9 | urire = re.compile(r"\.com(.*)$")
10 | def debug(txt):
11 | log = open("log.txt","w+")
12 | log.write(txt)
13 | log.close()
14 | def GetResponse(url,referer="https://www.baidu.com/",ua="Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"):
15 | uri = urire.findall(url)
16 | header = {"Host":"www.baidu.com","Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","Accept-Encoding":"gzip, identity","Accept-Language":"zh-CN,zh;q=0.8","Cache-Control":"max-age=0","Connection":"keep-alive","User-Agent":ua}
17 | try:
18 | client = httplib.HTTPConnection("www.baidu.com",80,timeout=10)
19 | client.request("GET",uri[0],headers=header)
20 | res = client.getresponse()
21 | except:
22 | res = None
23 | if res:
24 | headers = dict(res.getheaders())
25 | if 'content-encoding' in headers:
26 | body = gz_decoding(res.read())
27 | else:
28 | body = res.read()
29 | return headers,body
30 | else:
31 | return ()
32 |
33 | def gz_decoding(data):
34 | compressedstream = StringIO.StringIO(data)
35 | gziper = gzip.GzipFile(fileobj=compressedstream)
36 | data2 = gziper.read()
37 | return data2
38 |
39 |
40 | def get_jump(httpdata):
41 | tmp=list()
42 | match = jumpre.findall(httpdata)
43 | for i in match:
44 | if not i in tmp:
45 | tmp.append(i)
46 | return tmp
47 |
48 | def is_collected(targeturl,urllist):
49 | for url in urllist:
50 | header,body = GetResponse(url)
51 | jump = None
52 | if(header['location']):
53 | jump = header['location'].lstrip("http://").rstrip("/")
54 | else:
55 | jump = urlre.findall(body).lstrip("http://").rstrip("/")
56 | if targeturl.lstrip("http://").rstrip("/") == jump:
57 | return True
58 | return False
59 |
60 |
61 | arg = sys.argv
62 | if len(arg) == 1:
63 | sys.stdout.write(u"请输入需要查询的URL或者存放URL的文件!\n")
64 | exit()
65 | else:
66 | key = arg[1].strip()
67 |
68 | if re.match(r"^http",key):
69 | urls = [key]
70 | else:
71 | try:
72 | f = open(key,"rb")
73 | urls = f.readlines()
74 | f.close()
75 | except Exception,e:
76 | sys.stdout.write("%s\n"%e)
77 |
78 | for url in urls:
79 | try:
80 | time.sleep(5)
81 | except KeyboardInterrupt:
82 | sys.stdout.write(u"Ctrl+C结束\n")
83 | break
84 | url=url.strip()
85 | if len(url)==0:continue
86 | url = urllib.quote(url)
87 | baidu = GetResponse("http://www.baidu.com/s?wd=%s"%url)
88 | jumplist = get_jump(baidu[1])
89 | url = urllib.unquote(url)
90 | if "很抱歉,没有找到与" in baidu[1]:
91 | sys.stdout.write(u"网址:%s 未收录!\n"%url)
92 | continue
93 | if len(jumplist) == 0:
94 | sys.stdout.write(u"网址:%s 未知 百度阻止了此次查询,请稍后再试\n"%url)
95 | if "debug" in arg:
96 | txt = str(baidu[0])+baidu[1]
97 | debug(txt)
98 | continue
99 | if(is_collected(url,jumplist)):
100 | sys.stdout.write(u"网址:%s 被收录!\n"%url)
101 | continue
102 | else:
103 | sys.stdout.write(u"网址:%s 未收录!\n"%url)
104 | continue
105 |
--------------------------------------------------------------------------------
/baidusubmit/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import urllib.request,re,sys,time
3 | URLLIST = list()
4 |
5 | pushurl = "http://data.zz.baidu.com/urls?site=zh.camelway.com&token=Xem54Yt3FsXzAEJ4"
6 | xiongzhangpushurl = "http://data.zz.baidu.com/urls?appid=1630841799366655&token=Gmlp2vwKtKZBtBjQ&type=realtime"
7 | xiongzhangweekurl = "http://data.zz.baidu.com/urls?appid=1630841799366655&token=Gmlp2vwKtKZBtBjQ&type=batch"
8 |
9 | try:
10 | sitemap = sys.argv[1]
11 | except BaseException as e:
12 | print('Must Input Your Sitemap!')
13 | sys.exit(-1)
14 | try:
15 | interval = int(sys.argv[2])
16 | except BaseException:
17 | interval = 10
18 |
19 | while True:
20 | try:
21 | nocachesitemap = "%s?page=%s"%(sitemap, time.time())
22 | urls = urllib.request.urlopen(nocachesitemap).read().decode('utf-8')
23 | urls = re.sub("<[^>]*>", "\r\n", urls)
24 | urls = re.findall(r'(http.*?)[\r\n]', urls)
25 | newurls = list(set(urls).difference(set(URLLIST)))
26 | URLLIST.extend(newurls)
27 |
28 | print('%s, Success to Get Sitemap %s'%(time.ctime(), nocachesitemap))
29 | print('Total %d url(s) Founded, %d new url(s)'%(len(urls), len(newurls)))
30 |
31 | if(len(newurls) > 0):
32 | xurls = "\r\n".join(newurls)
33 | #百度站长URL提交,无限制
34 | res = urllib.request.Request(pushurl, headers = {'Content-Type': 'text/plain', 'Content-Length': len(xurls)}, data = bytes(xurls, 'utf8'))
35 | result = urllib.request.urlopen(res).read().decode('utf-8')
36 | print("Ping Baidu ZhanZhang: %s"%result)
37 | #熊掌号提交
38 | res = urllib.request.Request(xiongzhangpushurl, headers = {'Content-Type': 'text/plain', 'Content-Length': len(xurls)}, data = bytes(xurls, 'utf8'))
39 | result = urllib.request.urlopen(res).read().decode('utf-8')
40 | print("Ping Baidu XiongZhang: %s"%result)
41 | #熊掌周级收录
42 | res = urllib.request.Request(xiongzhangweekurl, headers = {'Content-Type': 'text/plain', 'Content-Length': len(xurls)}, data = bytes(xurls, 'utf8'))
43 | result = urllib.request.urlopen(res).read().decode('utf-8')
44 | print("Ping Baidu XiongZhang Week: %s"%result)
45 |
46 | print("\n");
47 | except KeyboardInterrupt as e:
48 | break
49 |
50 | except BaseException as e:
51 | print(e)
52 |
53 | time.sleep(interval)
54 |
--------------------------------------------------------------------------------
/bdtranlate.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding=utf-8 -*-
3 | import sys,urllib2,urllib,json,time
4 |
5 | class TrsltError(Exception):
6 | def __init__(self,*args):
7 | self.message=args[0]
8 | def __str__(self):
9 | return repr(self.message)
10 |
11 | class Translator():
12 | def __init__(self,string,key="T93TH0Y1x5262LZSkHr5tLZx",api="http://openapi.baidu.com/public/2.0/bmt/translate",slang="auto",tlang="auto"):
13 | self.string=string
14 | self.key=key
15 | self.api=api
16 | self.slang=slang
17 | self.tlang=tlang
18 | def setlang(self,slang,tlang):
19 | self.slang=slang
20 | self.tlang=tlang
21 |
22 | def translate(self):
23 | apis={'client_id':self.key,'q':self.string,'from':self.slang,'to':self.tlang}
24 | baiduapi=self.api+"?"+urllib.urlencode(apis)
25 | try:
26 | f=urllib2.urlopen(baiduapi,timeout=20).read()
27 | except Exception, e:
28 | raise TrsltError(e.message)
29 |
30 | result=json.loads(f)
31 | if result.has_key('error_code'):
32 | error_msg='Translate Error: '+result['error_msg']
33 | raise TrsltError(error_msg)
34 | else:
35 | #print (result['trans_result'][0]['src'],result['trans_result'][0]['dst'])
36 | return (result['trans_result'][0]['src'].encode('utf-8'),result['trans_result'][0]['dst'].encode('utf-8'))
37 |
38 |
39 |
40 | def getargu(arg):
41 | index=sys.argv.index(arg)
42 | return sys.argv[index+1]
43 |
44 | if __name__ == '__main__':
45 | keyfile=getargu('-k')
46 | resultfile=getargu('-r')
47 | slang=getargu('-slang')
48 | tlang=getargu('-tlang')
49 | try:
50 | ttl=int(getargu('-t'))
51 | except:
52 | ttl=10
53 |
54 | try:
55 | kfile=open(keyfile,'r')
56 | rfile=open(resultfile,'a')
57 | except Exception,e:
58 | print e
59 | sys.exit()
60 |
61 | while True:
62 | try:
63 | key=kfile.readline().strip()
64 | if not key:break
65 | trs=Translator(key,slang=slang,tlang=tlang)
66 | resu=trs.translate()
67 | print "%s -->> %s"%resu
68 | rfile.write(resu[1]+'\n')
69 | rfile.flush()
70 | time.sleep(ttl)
71 | except TrsltError,e:
72 | print e
73 | continue
74 | except KeyboardInterrupt,e:
75 | break
76 | except Exception,e:
77 | print e
78 | break
79 | kfile.close()
80 | rfile.close()
81 |
--------------------------------------------------------------------------------
/delete-short-posts/delete-short-posts.php:
--------------------------------------------------------------------------------
1 |
19 |
20 | Unsuscribe - Sorry to Disturb You
25 |
26 |
30 |
31 |
32 |
33 | Unsubscribe success!
40 |
41 |
42 |
--------------------------------------------------------------------------------
/get-google-image/collection.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding:utf-8 -*-
3 | import urllib2,urllib,sys,gzip,StringIO
4 |
5 | class Collection:
6 | __referer = "http://www.google.com/"
7 | __useragent = "Mozilla/5.0 (Windows NT 6.3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.149 Safari/537.36"
8 |
9 | def __init__(self,url,referer=__referer,ua=__useragent):
10 | self.__ua = ua
11 | self.__referer = referer
12 | self.__get_content(url)
13 |
14 | def __get_content(self,url):
15 | header = {"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","Accept-Encoding":"gzip, identity","Accept-Language":"en-US,en;q=0.8","Connection":"keep-alive","User-Agent":self.__ua,"Referer":self.__referer}
16 | try:
17 | req = urllib2.Request(url,headers=header)
18 | page = urllib2.urlopen(req,timeout=10)
19 | rpheader = page.info()
20 | body = page.read()
21 | except Exception,e:
22 | print e
23 | self.content=''
24 | return
25 |
26 | encoding = rpheader.get("Content-Encoding")
27 | if encoding == 'gzip':
28 | self.content=gz_decoding(body).strip()
29 | else:
30 | self.content=body.strip()
31 |
32 |
33 |
34 | def gz_decoding(data):
35 | compressedstream = StringIO.StringIO(data)
36 | gziper = gzip.GzipFile(fileobj=compressedstream)
37 | data2 = gziper.read()
38 | return data2
39 |
40 |
41 |
42 | if __name__ == "__main__":
43 | sys.exit()
44 |
--------------------------------------------------------------------------------
/get-google-image/downimg.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #! -*- coding:utf-8 -*-
3 | import re,collection
4 | filenamereg=re.compile(r"[^/]*$")
5 |
6 | def downimg(url,path="./"):
7 | filename=filenamereg.search(url).group(0)
8 | try:
9 | imgcontent=collection.Collection(url).content
10 | imgpath=open(path+filename,"wb")
11 | imgpath.write(imgcontent)
12 | imgpath.close()
13 | except BaseException,e:
14 | print e
15 |
16 |
--------------------------------------------------------------------------------
/get-google-image/google.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding:utf-8 -*-
3 | from collection import *
4 | import re
5 | import sys
6 | import urllib
7 |
8 | key=urllib.quote(sys.argv[1])
9 | path=sys.argv[2] if len(sys.argv)==3 else "./"
10 |
11 | imgreg = re.compile(r"imgres\?imgurl=([^&]+)&")
12 | filenamereg=re.compile(r"[^/]*$")
13 |
14 | def downimg(url,path="./"):
15 | filename=filenamereg.search(url).group(0)
16 | imgcontent=Collection(url).content
17 | if len(imgcontent)>0:
18 | imgpath=open(path+filename,"wb")
19 | imgpath.write(imgcontent)
20 | imgpath.close()
21 |
22 |
23 | class GoogleImg(Collection):
24 | def get_img_list(self):
25 | try:
26 | return imgreg.findall(self.content)
27 | except:
28 | return []
29 |
30 | a = GoogleImg('https://www.google.com/search?q=%s&tbm=isch'%key)
31 |
32 | imglist = a.get_img_list()
33 |
34 | for img in imglist:
35 | print "get img %s"%img
36 | downimg(img,path)
37 |
--------------------------------------------------------------------------------
/get-related-company/getcom.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding:utf-8 -*-
3 | import urllib2,urllib,re,sys,StringIO
4 |
5 | if len(sys.argv)<2:
6 | sys.stdout.write("Please Input Your KeyWord!\n")
7 | sys.exit()
8 |
9 | url = "http://win.mofcom.gov.cn/cbgnew/search.asp"
10 | referrer = "http://win.mofcom.gov.cn/"
11 |
12 | key = sys.argv[1]
13 |
14 | def getPOSTHTML(url,data):
15 | formdata = urllib.urlencode(data)
16 | req = urllib2.Request(url,headers={"User-Agent":"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36","Referer":referrer})
17 | f = urllib2.urlopen(req,formdata,timeout=15)
18 | content = f.read()
19 | return content
20 |
21 | page = 1
22 | companyre = re.compile(r"(.*?)<\/b>",re.S)
23 | textre = re.compile(r"<[^>]*>")
24 | while True:
25 | content = getPOSTHTML(url,{"Ptype":"01","PageNo":page,"keyword":key,"p_area":"0","p_coun":"ALL","website":"all","email":"all","ekind":"all","eright":"all","HavePic":"ALL","pname":"LastUpdate","imageField32.x":"12","mageField32.y":"8"})
26 | list = companyre.findall(content)
27 | if not list:
28 | break
29 | comfile = open("company.txt","ab")
30 | for com in list:
31 | com = textre.sub("",com)
32 | com = com.replace("-->","").strip()
33 | print com
34 | comfile.write(com+"\r\n")
35 | comfile.close()
36 | page += 1
37 |
38 | """
39 |
40 |
41 |
42 | 11.
43 | ARPA
44 |
45 |
46 |
47 |
48 | print companyre.search(test).group(1)
49 | """
50 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009, 2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | """dnspython DNS toolkit"""
17 |
18 | __all__ = [
19 | 'dnssec',
20 | 'e164',
21 | 'edns',
22 | 'entropy',
23 | 'exception',
24 | 'flags',
25 | 'hash',
26 | 'inet',
27 | 'ipv4',
28 | 'ipv6',
29 | 'message',
30 | 'name',
31 | 'namedict',
32 | 'node',
33 | 'opcode',
34 | 'query',
35 | 'rcode',
36 | 'rdata',
37 | 'rdataclass',
38 | 'rdataset',
39 | 'rdatatype',
40 | 'renderer',
41 | 'resolver',
42 | 'reversename',
43 | 'rrset',
44 | 'set',
45 | 'tokenizer',
46 | 'tsig',
47 | 'tsigkeyring',
48 | 'ttl',
49 | 'rdtypes',
50 | 'update',
51 | 'version',
52 | 'wiredata',
53 | 'zone',
54 | ]
55 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/e164.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2006, 2007, 2009, 2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | """DNS E.164 helpers
17 |
18 | @var public_enum_domain: The DNS public ENUM domain, e164.arpa.
19 | @type public_enum_domain: dns.name.Name object
20 | """
21 |
22 | import dns.exception
23 | import dns.name
24 | import dns.resolver
25 |
26 | public_enum_domain = dns.name.from_text('e164.arpa.')
27 |
28 | def from_e164(text, origin=public_enum_domain):
29 | """Convert an E.164 number in textual form into a Name object whose
30 | value is the ENUM domain name for that number.
31 | @param text: an E.164 number in textual form.
32 | @type text: str
33 | @param origin: The domain in which the number should be constructed.
34 | The default is e164.arpa.
35 | @type origin: dns.name.Name object or None
36 | @rtype: dns.name.Name object
37 | """
38 | parts = [d for d in text if d.isdigit()]
39 | parts.reverse()
40 | return dns.name.from_text('.'.join(parts), origin=origin)
41 |
42 | def to_e164(name, origin=public_enum_domain, want_plus_prefix=True):
43 | """Convert an ENUM domain name into an E.164 number.
44 | @param name: the ENUM domain name.
45 | @type name: dns.name.Name object.
46 | @param origin: A domain containing the ENUM domain name. The
47 | name is relativized to this domain before being converted to text.
48 | @type origin: dns.name.Name object or None
49 | @param want_plus_prefix: if True, add a '+' to the beginning of the
50 | returned number.
51 | @rtype: str
52 | """
53 | if not origin is None:
54 | name = name.relativize(origin)
55 | dlabels = [d for d in name.labels if (d.isdigit() and len(d) == 1)]
56 | if len(dlabels) != len(name.labels):
57 | raise dns.exception.SyntaxError('non-digit labels in ENUM domain name')
58 | dlabels.reverse()
59 | text = ''.join(dlabels)
60 | if want_plus_prefix:
61 | text = '+' + text
62 | return text
63 |
64 | def query(number, domains, resolver=None):
65 | """Look for NAPTR RRs for the specified number in the specified domains.
66 |
67 | e.g. lookup('16505551212', ['e164.dnspython.org.', 'e164.arpa.'])
68 | """
69 | if resolver is None:
70 | resolver = dns.resolver.get_default_resolver()
71 | for domain in domains:
72 | if isinstance(domain, (str, unicode)):
73 | domain = dns.name.from_text(domain)
74 | qname = dns.e164.from_e164(number, domain)
75 | try:
76 | return resolver.query(qname, 'NAPTR')
77 | except dns.resolver.NXDOMAIN:
78 | pass
79 | raise dns.resolver.NXDOMAIN
80 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/exception.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | """Common DNS Exceptions."""
17 |
18 | class DNSException(Exception):
19 | """Abstract base class shared by all dnspython exceptions."""
20 | pass
21 |
22 | class FormError(DNSException):
23 | """DNS message is malformed."""
24 | pass
25 |
26 | class SyntaxError(DNSException):
27 | """Text input is malformed."""
28 | pass
29 |
30 | class UnexpectedEnd(SyntaxError):
31 | """Raised if text input ends unexpectedly."""
32 | pass
33 |
34 | class TooBig(DNSException):
35 | """The message is too big."""
36 | pass
37 |
38 | class Timeout(DNSException):
39 | """The operation timed out."""
40 | pass
41 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/flags.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2001-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | """DNS Message Flags."""
17 |
18 | # Standard DNS flags
19 |
20 | QR = 0x8000
21 | AA = 0x0400
22 | TC = 0x0200
23 | RD = 0x0100
24 | RA = 0x0080
25 | AD = 0x0020
26 | CD = 0x0010
27 |
28 | # EDNS flags
29 |
30 | DO = 0x8000
31 |
32 | _by_text = {
33 | 'QR' : QR,
34 | 'AA' : AA,
35 | 'TC' : TC,
36 | 'RD' : RD,
37 | 'RA' : RA,
38 | 'AD' : AD,
39 | 'CD' : CD
40 | }
41 |
42 | _edns_by_text = {
43 | 'DO' : DO
44 | }
45 |
46 |
47 | # We construct the inverse mappings programmatically to ensure that we
48 | # cannot make any mistakes (e.g. omissions, cut-and-paste errors) that
49 | # would cause the mappings not to be true inverses.
50 |
51 | _by_value = dict([(y, x) for x, y in _by_text.iteritems()])
52 |
53 | _edns_by_value = dict([(y, x) for x, y in _edns_by_text.iteritems()])
54 |
55 | def _order_flags(table):
56 | order = list(table.iteritems())
57 | order.sort()
58 | order.reverse()
59 | return order
60 |
61 | _flags_order = _order_flags(_by_value)
62 |
63 | _edns_flags_order = _order_flags(_edns_by_value)
64 |
65 | def _from_text(text, table):
66 | flags = 0
67 | tokens = text.split()
68 | for t in tokens:
69 | flags = flags | table[t.upper()]
70 | return flags
71 |
72 | def _to_text(flags, table, order):
73 | text_flags = []
74 | for k, v in order:
75 | if flags & k != 0:
76 | text_flags.append(v)
77 | return ' '.join(text_flags)
78 |
79 | def from_text(text):
80 | """Convert a space-separated list of flag text values into a flags
81 | value.
82 | @rtype: int"""
83 |
84 | return _from_text(text, _by_text)
85 |
86 | def to_text(flags):
87 | """Convert a flags value into a space-separated list of flag text
88 | values.
89 | @rtype: string"""
90 |
91 | return _to_text(flags, _by_value, _flags_order)
92 |
93 |
94 | def edns_from_text(text):
95 | """Convert a space-separated list of EDNS flag text values into a EDNS
96 | flags value.
97 | @rtype: int"""
98 |
99 | return _from_text(text, _edns_by_text)
100 |
101 | def edns_to_text(flags):
102 | """Convert an EDNS flags value into a space-separated list of EDNS flag
103 | text values.
104 | @rtype: string"""
105 |
106 | return _to_text(flags, _edns_by_value, _edns_flags_order)
107 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/grange.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | """DNS GENERATE range conversion."""
17 |
18 | import dns
19 |
20 | def from_text(text):
21 | """Convert the text form of a range in a GENERATE statement to an
22 | integer.
23 |
24 | @param text: the textual range
25 | @type text: string
26 | @return: The start, stop and step values.
27 | @rtype: tuple
28 | """
29 | # TODO, figure out the bounds on start, stop and step.
30 |
31 | import pdb
32 | step = 1
33 | cur = ''
34 | state = 0
35 | # state 0 1 2 3 4
36 | # x - y / z
37 | for c in text:
38 | if c == '-' and state == 0:
39 | start = int(cur)
40 | cur = ''
41 | state = 2
42 | elif c == '/':
43 | stop = int(cur)
44 | cur = ''
45 | state = 4
46 | elif c.isdigit():
47 | cur += c
48 | else:
49 | raise dns.exception.SyntaxError("Could not parse %s" % (c))
50 |
51 | if state in (1, 3):
52 | raise dns.exception.SyntaxError
53 |
54 | if state == 2:
55 | stop = int(cur)
56 |
57 | if state == 4:
58 | step = int(cur)
59 |
60 | assert step >= 1
61 | assert start >= 0
62 | assert start <= stop
63 | # TODO, can start == stop?
64 |
65 | return (start, stop, step)
66 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/hash.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | """Hashing backwards compatibility wrapper"""
17 |
18 | import sys
19 |
20 | _hashes = None
21 |
22 | def _need_later_python(alg):
23 | def func(*args, **kwargs):
24 | raise NotImplementedError("TSIG algorithm " + alg +
25 | " requires Python 2.5.2 or later")
26 | return func
27 |
28 | def _setup():
29 | global _hashes
30 | _hashes = {}
31 | try:
32 | import hashlib
33 | _hashes['MD5'] = hashlib.md5
34 | _hashes['SHA1'] = hashlib.sha1
35 | _hashes['SHA224'] = hashlib.sha224
36 | _hashes['SHA256'] = hashlib.sha256
37 | if sys.hexversion >= 0x02050200:
38 | _hashes['SHA384'] = hashlib.sha384
39 | _hashes['SHA512'] = hashlib.sha512
40 | else:
41 | _hashes['SHA384'] = _need_later_python('SHA384')
42 | _hashes['SHA512'] = _need_later_python('SHA512')
43 |
44 | if sys.hexversion < 0x02050000:
45 | # hashlib doesn't conform to PEP 247: API for
46 | # Cryptographic Hash Functions, which hmac before python
47 | # 2.5 requires, so add the necessary items.
48 | class HashlibWrapper:
49 | def __init__(self, basehash):
50 | self.basehash = basehash
51 | self.digest_size = self.basehash().digest_size
52 |
53 | def new(self, *args, **kwargs):
54 | return self.basehash(*args, **kwargs)
55 |
56 | for name in _hashes:
57 | _hashes[name] = HashlibWrapper(_hashes[name])
58 |
59 | except ImportError:
60 | import md5, sha
61 | _hashes['MD5'] = md5
62 | _hashes['SHA1'] = sha
63 |
64 | def get(algorithm):
65 | if _hashes is None:
66 | _setup()
67 | return _hashes[algorithm.upper()]
68 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/inet.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | """Generic Internet address helper functions."""
17 |
18 | import socket
19 |
20 | import dns.ipv4
21 | import dns.ipv6
22 |
23 |
24 | # We assume that AF_INET is always defined.
25 |
26 | AF_INET = socket.AF_INET
27 |
28 | # AF_INET6 might not be defined in the socket module, but we need it.
29 | # We'll try to use the socket module's value, and if it doesn't work,
30 | # we'll use our own value.
31 |
32 | try:
33 | AF_INET6 = socket.AF_INET6
34 | except AttributeError:
35 | AF_INET6 = 9999
36 |
37 | def inet_pton(family, text):
38 | """Convert the textual form of a network address into its binary form.
39 |
40 | @param family: the address family
41 | @type family: int
42 | @param text: the textual address
43 | @type text: string
44 | @raises NotImplementedError: the address family specified is not
45 | implemented.
46 | @rtype: string
47 | """
48 |
49 | if family == AF_INET:
50 | return dns.ipv4.inet_aton(text)
51 | elif family == AF_INET6:
52 | return dns.ipv6.inet_aton(text)
53 | else:
54 | raise NotImplementedError
55 |
56 | def inet_ntop(family, address):
57 | """Convert the binary form of a network address into its textual form.
58 |
59 | @param family: the address family
60 | @type family: int
61 | @param address: the binary address
62 | @type address: string
63 | @raises NotImplementedError: the address family specified is not
64 | implemented.
65 | @rtype: string
66 | """
67 | if family == AF_INET:
68 | return dns.ipv4.inet_ntoa(address)
69 | elif family == AF_INET6:
70 | return dns.ipv6.inet_ntoa(address)
71 | else:
72 | raise NotImplementedError
73 |
74 | def af_for_address(text):
75 | """Determine the address family of a textual-form network address.
76 |
77 | @param text: the textual address
78 | @type text: string
79 | @raises ValueError: the address family cannot be determined from the input.
80 | @rtype: int
81 | """
82 | try:
83 | junk = dns.ipv4.inet_aton(text)
84 | return AF_INET
85 | except:
86 | try:
87 | junk = dns.ipv6.inet_aton(text)
88 | return AF_INET6
89 | except:
90 | raise ValueError
91 |
92 | def is_multicast(text):
93 | """Is the textual-form network address a multicast address?
94 |
95 | @param text: the textual address
96 | @raises ValueError: the address family cannot be determined from the input.
97 | @rtype: bool
98 | """
99 | try:
100 | first = ord(dns.ipv4.inet_aton(text)[0])
101 | return (first >= 224 and first <= 239)
102 | except:
103 | try:
104 | first = ord(dns.ipv6.inet_aton(text)[0])
105 | return (first == 255)
106 | except:
107 | raise ValueError
108 |
109 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/ipv4.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | """IPv4 helper functions."""
17 |
18 | import struct
19 |
20 | import dns.exception
21 |
22 | def inet_ntoa(address):
23 | """Convert an IPv4 address in network form to text form.
24 |
25 | @param address: The IPv4 address
26 | @type address: string
27 | @returns: string
28 | """
29 | if len(address) != 4:
30 | raise dns.exception.SyntaxError
31 | return '%u.%u.%u.%u' % (ord(address[0]), ord(address[1]),
32 | ord(address[2]), ord(address[3]))
33 |
34 | def inet_aton(text):
35 | """Convert an IPv4 address in text form to network form.
36 |
37 | @param text: The IPv4 address
38 | @type text: string
39 | @returns: string
40 | """
41 | parts = text.split('.')
42 | if len(parts) != 4:
43 | raise dns.exception.SyntaxError
44 | for part in parts:
45 | if not part.isdigit():
46 | raise dns.exception.SyntaxError
47 | if len(part) > 1 and part[0] == '0':
48 | # No leading zeros
49 | raise dns.exception.SyntaxError
50 | try:
51 | bytes = [int(part) for part in parts]
52 | return struct.pack('BBBB', *bytes)
53 | except:
54 | raise dns.exception.SyntaxError
55 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/namedict.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | """DNS name dictionary"""
17 |
18 | import dns.name
19 |
20 | class NameDict(dict):
21 |
22 | """A dictionary whose keys are dns.name.Name objects.
23 | @ivar max_depth: the maximum depth of the keys that have ever been
24 | added to the dictionary.
25 | @type max_depth: int
26 | """
27 |
28 | def __init__(self, *args, **kwargs):
29 | super(NameDict, self).__init__(*args, **kwargs)
30 | self.max_depth = 0
31 |
32 | def __setitem__(self, key, value):
33 | if not isinstance(key, dns.name.Name):
34 | raise ValueError('NameDict key must be a name')
35 | depth = len(key)
36 | if depth > self.max_depth:
37 | self.max_depth = depth
38 | super(NameDict, self).__setitem__(key, value)
39 |
40 | def get_deepest_match(self, name):
41 | """Find the deepest match to I{name} in the dictionary.
42 |
43 | The deepest match is the longest name in the dictionary which is
44 | a superdomain of I{name}.
45 |
46 | @param name: the name
47 | @type name: dns.name.Name object
48 | @rtype: (key, value) tuple
49 | """
50 |
51 | depth = len(name)
52 | if depth > self.max_depth:
53 | depth = self.max_depth
54 | for i in xrange(-depth, 0):
55 | n = dns.name.Name(name[i:])
56 | if self.has_key(n):
57 | return (n, self[n])
58 | v = self[dns.name.empty]
59 | return (dns.name.empty, v)
60 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/opcode.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2001-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | """DNS Opcodes."""
17 |
18 | import dns.exception
19 |
20 | QUERY = 0
21 | IQUERY = 1
22 | STATUS = 2
23 | NOTIFY = 4
24 | UPDATE = 5
25 |
26 | _by_text = {
27 | 'QUERY' : QUERY,
28 | 'IQUERY' : IQUERY,
29 | 'STATUS' : STATUS,
30 | 'NOTIFY' : NOTIFY,
31 | 'UPDATE' : UPDATE
32 | }
33 |
34 | # We construct the inverse mapping programmatically to ensure that we
35 | # cannot make any mistakes (e.g. omissions, cut-and-paste errors) that
36 | # would cause the mapping not to be true inverse.
37 |
38 | _by_value = dict([(y, x) for x, y in _by_text.iteritems()])
39 |
40 |
41 | class UnknownOpcode(dns.exception.DNSException):
42 | """Raised if an opcode is unknown."""
43 | pass
44 |
45 | def from_text(text):
46 | """Convert text into an opcode.
47 |
48 | @param text: the textual opcode
49 | @type text: string
50 | @raises UnknownOpcode: the opcode is unknown
51 | @rtype: int
52 | """
53 |
54 | if text.isdigit():
55 | value = int(text)
56 | if value >= 0 and value <= 15:
57 | return value
58 | value = _by_text.get(text.upper())
59 | if value is None:
60 | raise UnknownOpcode
61 | return value
62 |
63 | def from_flags(flags):
64 | """Extract an opcode from DNS message flags.
65 |
66 | @param flags: int
67 | @rtype: int
68 | """
69 |
70 | return (flags & 0x7800) >> 11
71 |
72 | def to_flags(value):
73 | """Convert an opcode to a value suitable for ORing into DNS message
74 | flags.
75 | @rtype: int
76 | """
77 |
78 | return (value << 11) & 0x7800
79 |
80 | def to_text(value):
81 | """Convert an opcode to text.
82 |
83 | @param value: the opcdoe
84 | @type value: int
85 | @raises UnknownOpcode: the opcode is unknown
86 | @rtype: string
87 | """
88 |
89 | text = _by_value.get(value)
90 | if text is None:
91 | text = str(value)
92 | return text
93 |
94 | def is_update(flags):
95 | """True if the opcode in flags is UPDATE.
96 |
97 | @param flags: DNS flags
98 | @type flags: int
99 | @rtype: bool
100 | """
101 |
102 | if (from_flags(flags) == UPDATE):
103 | return True
104 | return False
105 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rcode.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2001-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | """DNS Result Codes."""
17 |
18 | import dns.exception
19 |
20 | NOERROR = 0
21 | FORMERR = 1
22 | SERVFAIL = 2
23 | NXDOMAIN = 3
24 | NOTIMP = 4
25 | REFUSED = 5
26 | YXDOMAIN = 6
27 | YXRRSET = 7
28 | NXRRSET = 8
29 | NOTAUTH = 9
30 | NOTZONE = 10
31 | BADVERS = 16
32 |
33 | _by_text = {
34 | 'NOERROR' : NOERROR,
35 | 'FORMERR' : FORMERR,
36 | 'SERVFAIL' : SERVFAIL,
37 | 'NXDOMAIN' : NXDOMAIN,
38 | 'NOTIMP' : NOTIMP,
39 | 'REFUSED' : REFUSED,
40 | 'YXDOMAIN' : YXDOMAIN,
41 | 'YXRRSET' : YXRRSET,
42 | 'NXRRSET' : NXRRSET,
43 | 'NOTAUTH' : NOTAUTH,
44 | 'NOTZONE' : NOTZONE,
45 | 'BADVERS' : BADVERS
46 | }
47 |
48 | # We construct the inverse mapping programmatically to ensure that we
49 | # cannot make any mistakes (e.g. omissions, cut-and-paste errors) that
50 | # would cause the mapping not to be a true inverse.
51 |
52 | _by_value = dict([(y, x) for x, y in _by_text.iteritems()])
53 |
54 |
55 | class UnknownRcode(dns.exception.DNSException):
56 | """Raised if an rcode is unknown."""
57 | pass
58 |
59 | def from_text(text):
60 | """Convert text into an rcode.
61 |
62 | @param text: the texual rcode
63 | @type text: string
64 | @raises UnknownRcode: the rcode is unknown
65 | @rtype: int
66 | """
67 |
68 | if text.isdigit():
69 | v = int(text)
70 | if v >= 0 and v <= 4095:
71 | return v
72 | v = _by_text.get(text.upper())
73 | if v is None:
74 | raise UnknownRcode
75 | return v
76 |
77 | def from_flags(flags, ednsflags):
78 | """Return the rcode value encoded by flags and ednsflags.
79 |
80 | @param flags: the DNS flags
81 | @type flags: int
82 | @param ednsflags: the EDNS flags
83 | @type ednsflags: int
84 | @raises ValueError: rcode is < 0 or > 4095
85 | @rtype: int
86 | """
87 |
88 | value = (flags & 0x000f) | ((ednsflags >> 20) & 0xff0)
89 | if value < 0 or value > 4095:
90 | raise ValueError('rcode must be >= 0 and <= 4095')
91 | return value
92 |
93 | def to_flags(value):
94 | """Return a (flags, ednsflags) tuple which encodes the rcode.
95 |
96 | @param value: the rcode
97 | @type value: int
98 | @raises ValueError: rcode is < 0 or > 4095
99 | @rtype: (int, int) tuple
100 | """
101 |
102 | if value < 0 or value > 4095:
103 | raise ValueError('rcode must be >= 0 and <= 4095')
104 | v = value & 0xf
105 | ev = long(value & 0xff0) << 20
106 | return (v, ev)
107 |
108 | def to_text(value):
109 | """Convert rcode into text.
110 |
111 | @param value: the rcode
112 | @type value: int
113 | @rtype: string
114 | """
115 |
116 | text = _by_value.get(value)
117 | if text is None:
118 | text = str(value)
119 | return text
120 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdataclass.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2001-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | """DNS Rdata Classes.
17 |
18 | @var _by_text: The rdata class textual name to value mapping
19 | @type _by_text: dict
20 | @var _by_value: The rdata class value to textual name mapping
21 | @type _by_value: dict
22 | @var _metaclasses: If an rdataclass is a metaclass, there will be a mapping
23 | whose key is the rdatatype value and whose value is True in this dictionary.
24 | @type _metaclasses: dict"""
25 |
26 | import re
27 |
28 | import dns.exception
29 |
30 | RESERVED0 = 0
31 | IN = 1
32 | CH = 3
33 | HS = 4
34 | NONE = 254
35 | ANY = 255
36 |
37 | _by_text = {
38 | 'RESERVED0' : RESERVED0,
39 | 'IN' : IN,
40 | 'CH' : CH,
41 | 'HS' : HS,
42 | 'NONE' : NONE,
43 | 'ANY' : ANY
44 | }
45 |
46 | # We construct the inverse mapping programmatically to ensure that we
47 | # cannot make any mistakes (e.g. omissions, cut-and-paste errors) that
48 | # would cause the mapping not to be true inverse.
49 |
50 | _by_value = dict([(y, x) for x, y in _by_text.iteritems()])
51 |
52 | # Now that we've built the inverse map, we can add class aliases to
53 | # the _by_text mapping.
54 |
55 | _by_text.update({
56 | 'INTERNET' : IN,
57 | 'CHAOS' : CH,
58 | 'HESIOD' : HS
59 | })
60 |
61 | _metaclasses = {
62 | NONE : True,
63 | ANY : True
64 | }
65 |
66 | _unknown_class_pattern = re.compile('CLASS([0-9]+)$', re.I);
67 |
68 | class UnknownRdataclass(dns.exception.DNSException):
69 | """Raised when a class is unknown."""
70 | pass
71 |
72 | def from_text(text):
73 | """Convert text into a DNS rdata class value.
74 | @param text: the text
75 | @type text: string
76 | @rtype: int
77 | @raises dns.rdataclass.UnknownRdataclass: the class is unknown
78 | @raises ValueError: the rdata class value is not >= 0 and <= 65535
79 | """
80 |
81 | value = _by_text.get(text.upper())
82 | if value is None:
83 | match = _unknown_class_pattern.match(text)
84 | if match == None:
85 | raise UnknownRdataclass
86 | value = int(match.group(1))
87 | if value < 0 or value > 65535:
88 | raise ValueError("class must be between >= 0 and <= 65535")
89 | return value
90 |
91 | def to_text(value):
92 | """Convert a DNS rdata class to text.
93 | @param value: the rdata class value
94 | @type value: int
95 | @rtype: string
96 | @raises ValueError: the rdata class value is not >= 0 and <= 65535
97 | """
98 |
99 | if value < 0 or value > 65535:
100 | raise ValueError("class must be between >= 0 and <= 65535")
101 | text = _by_value.get(value)
102 | if text is None:
103 | text = 'CLASS' + `value`
104 | return text
105 |
106 | def is_metaclass(rdclass):
107 | """True if the class is a metaclass.
108 | @param rdclass: the rdata class
109 | @type rdclass: int
110 | @rtype: bool"""
111 |
112 | if _metaclasses.has_key(rdclass):
113 | return True
114 | return False
115 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/ANY/AFSDB.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import dns.rdtypes.mxbase
17 |
18 | class AFSDB(dns.rdtypes.mxbase.UncompressedDowncasingMX):
19 | """AFSDB record
20 |
21 | @ivar subtype: the subtype value
22 | @type subtype: int
23 | @ivar hostname: the hostname name
24 | @type hostname: dns.name.Name object"""
25 |
26 | # Use the property mechanism to make "subtype" an alias for the
27 | # "preference" attribute, and "hostname" an alias for the "exchange"
28 | # attribute.
29 | #
30 | # This lets us inherit the UncompressedMX implementation but lets
31 | # the caller use appropriate attribute names for the rdata type.
32 | #
33 | # We probably lose some performance vs. a cut-and-paste
34 | # implementation, but this way we don't copy code, and that's
35 | # good.
36 |
37 | def get_subtype(self):
38 | return self.preference
39 |
40 | def set_subtype(self, subtype):
41 | self.preference = subtype
42 |
43 | subtype = property(get_subtype, set_subtype)
44 |
45 | def get_hostname(self):
46 | return self.exchange
47 |
48 | def set_hostname(self, hostname):
49 | self.exchange = hostname
50 |
51 | hostname = property(get_hostname, set_hostname)
52 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/ANY/CNAME.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import dns.rdtypes.nsbase
17 |
18 | class CNAME(dns.rdtypes.nsbase.NSBase):
19 | """CNAME record
20 |
21 | Note: although CNAME is officially a singleton type, dnspython allows
22 | non-singleton CNAME rdatasets because such sets have been commonly
23 | used by BIND and other nameservers for load balancing."""
24 | pass
25 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/ANY/DLV.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import dns.rdtypes.dsbase
17 |
18 | class DLV(dns.rdtypes.dsbase.DSBase):
19 | """DLV record"""
20 | pass
21 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/ANY/DNAME.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import dns.rdtypes.nsbase
17 |
18 | class DNAME(dns.rdtypes.nsbase.UncompressedNS):
19 | """DNAME record"""
20 | def to_digestable(self, origin = None):
21 | return self.target.to_digestable(origin)
22 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/ANY/DS.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import dns.rdtypes.dsbase
17 |
18 | class DS(dns.rdtypes.dsbase.DSBase):
19 | """DS record"""
20 | pass
21 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/ANY/HINFO.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import dns.exception
17 | import dns.rdata
18 | import dns.tokenizer
19 |
20 | class HINFO(dns.rdata.Rdata):
21 | """HINFO record
22 |
23 | @ivar cpu: the CPU type
24 | @type cpu: string
25 | @ivar os: the OS type
26 | @type os: string
27 | @see: RFC 1035"""
28 |
29 | __slots__ = ['cpu', 'os']
30 |
31 | def __init__(self, rdclass, rdtype, cpu, os):
32 | super(HINFO, self).__init__(rdclass, rdtype)
33 | self.cpu = cpu
34 | self.os = os
35 |
36 | def to_text(self, origin=None, relativize=True, **kw):
37 | return '"%s" "%s"' % (dns.rdata._escapify(self.cpu),
38 | dns.rdata._escapify(self.os))
39 |
40 | def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
41 | cpu = tok.get_string()
42 | os = tok.get_string()
43 | tok.get_eol()
44 | return cls(rdclass, rdtype, cpu, os)
45 |
46 | from_text = classmethod(from_text)
47 |
48 | def to_wire(self, file, compress = None, origin = None):
49 | l = len(self.cpu)
50 | assert l < 256
51 | byte = chr(l)
52 | file.write(byte)
53 | file.write(self.cpu)
54 | l = len(self.os)
55 | assert l < 256
56 | byte = chr(l)
57 | file.write(byte)
58 | file.write(self.os)
59 |
60 | def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
61 | l = ord(wire[current])
62 | current += 1
63 | rdlen -= 1
64 | if l > rdlen:
65 | raise dns.exception.FormError
66 | cpu = wire[current : current + l].unwrap()
67 | current += l
68 | rdlen -= l
69 | l = ord(wire[current])
70 | current += 1
71 | rdlen -= 1
72 | if l != rdlen:
73 | raise dns.exception.FormError
74 | os = wire[current : current + l].unwrap()
75 | return cls(rdclass, rdtype, cpu, os)
76 |
77 | from_wire = classmethod(from_wire)
78 |
79 | def _cmp(self, other):
80 | v = cmp(self.cpu, other.cpu)
81 | if v == 0:
82 | v = cmp(self.os, other.os)
83 | return v
84 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/ANY/ISDN.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import dns.exception
17 | import dns.rdata
18 | import dns.tokenizer
19 |
20 | class ISDN(dns.rdata.Rdata):
21 | """ISDN record
22 |
23 | @ivar address: the ISDN address
24 | @type address: string
25 | @ivar subaddress: the ISDN subaddress (or '' if not present)
26 | @type subaddress: string
27 | @see: RFC 1183"""
28 |
29 | __slots__ = ['address', 'subaddress']
30 |
31 | def __init__(self, rdclass, rdtype, address, subaddress):
32 | super(ISDN, self).__init__(rdclass, rdtype)
33 | self.address = address
34 | self.subaddress = subaddress
35 |
36 | def to_text(self, origin=None, relativize=True, **kw):
37 | if self.subaddress:
38 | return '"%s" "%s"' % (dns.rdata._escapify(self.address),
39 | dns.rdata._escapify(self.subaddress))
40 | else:
41 | return '"%s"' % dns.rdata._escapify(self.address)
42 |
43 | def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
44 | address = tok.get_string()
45 | t = tok.get()
46 | if not t.is_eol_or_eof():
47 | tok.unget(t)
48 | subaddress = tok.get_string()
49 | else:
50 | tok.unget(t)
51 | subaddress = ''
52 | tok.get_eol()
53 | return cls(rdclass, rdtype, address, subaddress)
54 |
55 | from_text = classmethod(from_text)
56 |
57 | def to_wire(self, file, compress = None, origin = None):
58 | l = len(self.address)
59 | assert l < 256
60 | byte = chr(l)
61 | file.write(byte)
62 | file.write(self.address)
63 | l = len(self.subaddress)
64 | if l > 0:
65 | assert l < 256
66 | byte = chr(l)
67 | file.write(byte)
68 | file.write(self.subaddress)
69 |
70 | def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
71 | l = ord(wire[current])
72 | current += 1
73 | rdlen -= 1
74 | if l > rdlen:
75 | raise dns.exception.FormError
76 | address = wire[current : current + l].unwrap()
77 | current += l
78 | rdlen -= l
79 | if rdlen > 0:
80 | l = ord(wire[current])
81 | current += 1
82 | rdlen -= 1
83 | if l != rdlen:
84 | raise dns.exception.FormError
85 | subaddress = wire[current : current + l].unwrap()
86 | else:
87 | subaddress = ''
88 | return cls(rdclass, rdtype, address, subaddress)
89 |
90 | from_wire = classmethod(from_wire)
91 |
92 | def _cmp(self, other):
93 | v = cmp(self.address, other.address)
94 | if v == 0:
95 | v = cmp(self.subaddress, other.subaddress)
96 | return v
97 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/ANY/MX.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import dns.rdtypes.mxbase
17 |
18 | class MX(dns.rdtypes.mxbase.MXBase):
19 | """MX record"""
20 | pass
21 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/ANY/NS.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import dns.rdtypes.nsbase
17 |
18 | class NS(dns.rdtypes.nsbase.NSBase):
19 | """NS record"""
20 | pass
21 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/ANY/NSEC3PARAM.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2004-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import cStringIO
17 | import struct
18 |
19 | import dns.exception
20 | import dns.rdata
21 |
22 | class NSEC3PARAM(dns.rdata.Rdata):
23 | """NSEC3PARAM record
24 |
25 | @ivar algorithm: the hash algorithm number
26 | @type algorithm: int
27 | @ivar flags: the flags
28 | @type flags: int
29 | @ivar iterations: the number of iterations
30 | @type iterations: int
31 | @ivar salt: the salt
32 | @type salt: string"""
33 |
34 | __slots__ = ['algorithm', 'flags', 'iterations', 'salt']
35 |
36 | def __init__(self, rdclass, rdtype, algorithm, flags, iterations, salt):
37 | super(NSEC3PARAM, self).__init__(rdclass, rdtype)
38 | self.algorithm = algorithm
39 | self.flags = flags
40 | self.iterations = iterations
41 | self.salt = salt
42 |
43 | def to_text(self, origin=None, relativize=True, **kw):
44 | if self.salt == '':
45 | salt = '-'
46 | else:
47 | salt = self.salt.encode('hex-codec')
48 | return '%u %u %u %s' % (self.algorithm, self.flags, self.iterations, salt)
49 |
50 | def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
51 | algorithm = tok.get_uint8()
52 | flags = tok.get_uint8()
53 | iterations = tok.get_uint16()
54 | salt = tok.get_string()
55 | if salt == '-':
56 | salt = ''
57 | else:
58 | salt = salt.decode('hex-codec')
59 | tok.get_eol()
60 | return cls(rdclass, rdtype, algorithm, flags, iterations, salt)
61 |
62 | from_text = classmethod(from_text)
63 |
64 | def to_wire(self, file, compress = None, origin = None):
65 | l = len(self.salt)
66 | file.write(struct.pack("!BBHB", self.algorithm, self.flags,
67 | self.iterations, l))
68 | file.write(self.salt)
69 |
70 | def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
71 | (algorithm, flags, iterations, slen) = struct.unpack('!BBHB',
72 | wire[current : current + 5])
73 | current += 5
74 | rdlen -= 5
75 | salt = wire[current : current + slen].unwrap()
76 | current += slen
77 | rdlen -= slen
78 | if rdlen != 0:
79 | raise dns.exception.FormError
80 | return cls(rdclass, rdtype, algorithm, flags, iterations, salt)
81 |
82 | from_wire = classmethod(from_wire)
83 |
84 | def _cmp(self, other):
85 | b1 = cStringIO.StringIO()
86 | self.to_wire(b1)
87 | b2 = cStringIO.StringIO()
88 | other.to_wire(b2)
89 | return cmp(b1.getvalue(), b2.getvalue())
90 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/ANY/PTR.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import dns.rdtypes.nsbase
17 |
18 | class PTR(dns.rdtypes.nsbase.NSBase):
19 | """PTR record"""
20 | pass
21 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/ANY/RP.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import dns.exception
17 | import dns.rdata
18 | import dns.name
19 |
20 | class RP(dns.rdata.Rdata):
21 | """RP record
22 |
23 | @ivar mbox: The responsible person's mailbox
24 | @type mbox: dns.name.Name object
25 | @ivar txt: The owner name of a node with TXT records, or the root name
26 | if no TXT records are associated with this RP.
27 | @type txt: dns.name.Name object
28 | @see: RFC 1183"""
29 |
30 | __slots__ = ['mbox', 'txt']
31 |
32 | def __init__(self, rdclass, rdtype, mbox, txt):
33 | super(RP, self).__init__(rdclass, rdtype)
34 | self.mbox = mbox
35 | self.txt = txt
36 |
37 | def to_text(self, origin=None, relativize=True, **kw):
38 | mbox = self.mbox.choose_relativity(origin, relativize)
39 | txt = self.txt.choose_relativity(origin, relativize)
40 | return "%s %s" % (str(mbox), str(txt))
41 |
42 | def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
43 | mbox = tok.get_name()
44 | txt = tok.get_name()
45 | mbox = mbox.choose_relativity(origin, relativize)
46 | txt = txt.choose_relativity(origin, relativize)
47 | tok.get_eol()
48 | return cls(rdclass, rdtype, mbox, txt)
49 |
50 | from_text = classmethod(from_text)
51 |
52 | def to_wire(self, file, compress = None, origin = None):
53 | self.mbox.to_wire(file, None, origin)
54 | self.txt.to_wire(file, None, origin)
55 |
56 | def to_digestable(self, origin = None):
57 | return self.mbox.to_digestable(origin) + \
58 | self.txt.to_digestable(origin)
59 |
60 | def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
61 | (mbox, cused) = dns.name.from_wire(wire[: current + rdlen],
62 | current)
63 | current += cused
64 | rdlen -= cused
65 | if rdlen <= 0:
66 | raise dns.exception.FormError
67 | (txt, cused) = dns.name.from_wire(wire[: current + rdlen],
68 | current)
69 | if cused != rdlen:
70 | raise dns.exception.FormError
71 | if not origin is None:
72 | mbox = mbox.relativize(origin)
73 | txt = txt.relativize(origin)
74 | return cls(rdclass, rdtype, mbox, txt)
75 |
76 | from_wire = classmethod(from_wire)
77 |
78 | def choose_relativity(self, origin = None, relativize = True):
79 | self.mbox = self.mbox.choose_relativity(origin, relativize)
80 | self.txt = self.txt.choose_relativity(origin, relativize)
81 |
82 | def _cmp(self, other):
83 | v = cmp(self.mbox, other.mbox)
84 | if v == 0:
85 | v = cmp(self.txt, other.txt)
86 | return v
87 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/ANY/RT.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import dns.rdtypes.mxbase
17 |
18 | class RT(dns.rdtypes.mxbase.UncompressedDowncasingMX):
19 | """RT record"""
20 | pass
21 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/ANY/SPF.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2006, 2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import dns.rdtypes.txtbase
17 |
18 | class SPF(dns.rdtypes.txtbase.TXTBase):
19 | """SPF record
20 |
21 | @see: RFC 4408"""
22 | pass
23 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/ANY/SSHFP.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2005-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import struct
17 |
18 | import dns.rdata
19 | import dns.rdatatype
20 |
21 | class SSHFP(dns.rdata.Rdata):
22 | """SSHFP record
23 |
24 | @ivar algorithm: the algorithm
25 | @type algorithm: int
26 | @ivar fp_type: the digest type
27 | @type fp_type: int
28 | @ivar fingerprint: the fingerprint
29 | @type fingerprint: string
30 | @see: draft-ietf-secsh-dns-05.txt"""
31 |
32 | __slots__ = ['algorithm', 'fp_type', 'fingerprint']
33 |
34 | def __init__(self, rdclass, rdtype, algorithm, fp_type,
35 | fingerprint):
36 | super(SSHFP, self).__init__(rdclass, rdtype)
37 | self.algorithm = algorithm
38 | self.fp_type = fp_type
39 | self.fingerprint = fingerprint
40 |
41 | def to_text(self, origin=None, relativize=True, **kw):
42 | return '%d %d %s' % (self.algorithm,
43 | self.fp_type,
44 | dns.rdata._hexify(self.fingerprint,
45 | chunksize=128))
46 |
47 | def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
48 | algorithm = tok.get_uint8()
49 | fp_type = tok.get_uint8()
50 | chunks = []
51 | while 1:
52 | t = tok.get().unescape()
53 | if t.is_eol_or_eof():
54 | break
55 | if not t.is_identifier():
56 | raise dns.exception.SyntaxError
57 | chunks.append(t.value)
58 | fingerprint = ''.join(chunks)
59 | fingerprint = fingerprint.decode('hex_codec')
60 | return cls(rdclass, rdtype, algorithm, fp_type, fingerprint)
61 |
62 | from_text = classmethod(from_text)
63 |
64 | def to_wire(self, file, compress = None, origin = None):
65 | header = struct.pack("!BB", self.algorithm, self.fp_type)
66 | file.write(header)
67 | file.write(self.fingerprint)
68 |
69 | def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
70 | header = struct.unpack("!BB", wire[current : current + 2])
71 | current += 2
72 | rdlen -= 2
73 | fingerprint = wire[current : current + rdlen].unwrap()
74 | return cls(rdclass, rdtype, header[0], header[1], fingerprint)
75 |
76 | from_wire = classmethod(from_wire)
77 |
78 | def _cmp(self, other):
79 | hs = struct.pack("!BB", self.algorithm, self.fp_type)
80 | ho = struct.pack("!BB", other.algorithm, other.fp_type)
81 | v = cmp(hs, ho)
82 | if v == 0:
83 | v = cmp(self.fingerprint, other.fingerprint)
84 | return v
85 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/ANY/TLSA.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2005-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import struct
17 |
18 | import dns.rdata
19 | import dns.rdatatype
20 |
21 | class TLSA(dns.rdata.Rdata):
22 | """TLSA record
23 |
24 | @ivar usage: The certificate usage
25 | @type usage: int
26 | @ivar selector: The selector field
27 | @type selector: int
28 | @ivar mtype: The 'matching type' field
29 | @type mtype: int
30 | @ivar cert: The 'Certificate Association Data' field
31 | @type cert: string
32 | @see: RFC 6698"""
33 |
34 | __slots__ = ['usage', 'selector', 'mtype', 'cert']
35 |
36 | def __init__(self, rdclass, rdtype, usage, selector,
37 | mtype, cert):
38 | super(TLSA, self).__init__(rdclass, rdtype)
39 | self.usage = usage
40 | self.selector = selector
41 | self.mtype = mtype
42 | self.cert = cert
43 |
44 | def to_text(self, origin=None, relativize=True, **kw):
45 | return '%d %d %d %s' % (self.usage,
46 | self.selector,
47 | self.mtype,
48 | dns.rdata._hexify(self.cert,
49 | chunksize=128))
50 |
51 | def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
52 | usage = tok.get_uint8()
53 | selector = tok.get_uint8()
54 | mtype = tok.get_uint8()
55 | cert_chunks = []
56 | while 1:
57 | t = tok.get().unescape()
58 | if t.is_eol_or_eof():
59 | break
60 | if not t.is_identifier():
61 | raise dns.exception.SyntaxError
62 | cert_chunks.append(t.value)
63 | cert = ''.join(cert_chunks)
64 | cert = cert.decode('hex_codec')
65 | return cls(rdclass, rdtype, usage, selector, mtype, cert)
66 |
67 | from_text = classmethod(from_text)
68 |
69 | def to_wire(self, file, compress = None, origin = None):
70 | header = struct.pack("!BBB", self.usage, self.selector, self.mtype)
71 | file.write(header)
72 | file.write(self.cert)
73 |
74 | def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
75 | header = struct.unpack("!BBB", wire[current : current + 3])
76 | current += 3
77 | rdlen -= 3
78 | cert = wire[current : current + rdlen].unwrap()
79 | return cls(rdclass, rdtype, header[0], header[1], header[2], cert)
80 |
81 | from_wire = classmethod(from_wire)
82 |
83 | def _cmp(self, other):
84 | hs = struct.pack("!BBB", self.usage, self.selector, self.mtype)
85 | ho = struct.pack("!BBB", other.usage, other.selector, other.mtype)
86 | v = cmp(hs, ho)
87 | if v == 0:
88 | v = cmp(self.cert, other.cert)
89 | return v
90 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/ANY/TXT.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import dns.rdtypes.txtbase
17 |
18 | class TXT(dns.rdtypes.txtbase.TXTBase):
19 | """TXT record"""
20 | pass
21 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/ANY/X25.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import dns.exception
17 | import dns.rdata
18 | import dns.tokenizer
19 |
20 | class X25(dns.rdata.Rdata):
21 | """X25 record
22 |
23 | @ivar address: the PSDN address
24 | @type address: string
25 | @see: RFC 1183"""
26 |
27 | __slots__ = ['address']
28 |
29 | def __init__(self, rdclass, rdtype, address):
30 | super(X25, self).__init__(rdclass, rdtype)
31 | self.address = address
32 |
33 | def to_text(self, origin=None, relativize=True, **kw):
34 | return '"%s"' % dns.rdata._escapify(self.address)
35 |
36 | def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
37 | address = tok.get_string()
38 | tok.get_eol()
39 | return cls(rdclass, rdtype, address)
40 |
41 | from_text = classmethod(from_text)
42 |
43 | def to_wire(self, file, compress = None, origin = None):
44 | l = len(self.address)
45 | assert l < 256
46 | byte = chr(l)
47 | file.write(byte)
48 | file.write(self.address)
49 |
50 | def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
51 | l = ord(wire[current])
52 | current += 1
53 | rdlen -= 1
54 | if l != rdlen:
55 | raise dns.exception.FormError
56 | address = wire[current : current + l].unwrap()
57 | return cls(rdclass, rdtype, address)
58 |
59 | from_wire = classmethod(from_wire)
60 |
61 | def _cmp(self, other):
62 | return cmp(self.address, other.address)
63 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/ANY/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | """Class ANY (generic) rdata type classes."""
17 |
18 | __all__ = [
19 | 'AFSDB',
20 | 'CERT',
21 | 'CNAME',
22 | 'DLV',
23 | 'DNAME',
24 | 'DNSKEY',
25 | 'DS',
26 | 'GPOS',
27 | 'HINFO',
28 | 'HIP',
29 | 'ISDN',
30 | 'LOC',
31 | 'MX',
32 | 'NS',
33 | 'NSEC',
34 | 'NSEC3',
35 | 'NSEC3PARAM',
36 | 'TLSA',
37 | 'PTR',
38 | 'RP',
39 | 'RRSIG',
40 | 'RT',
41 | 'SOA',
42 | 'SPF',
43 | 'SSHFP',
44 | 'TXT',
45 | 'X25',
46 | ]
47 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/IN/A.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import dns.exception
17 | import dns.ipv4
18 | import dns.rdata
19 | import dns.tokenizer
20 |
21 | class A(dns.rdata.Rdata):
22 | """A record.
23 |
24 | @ivar address: an IPv4 address
25 | @type address: string (in the standard "dotted quad" format)"""
26 |
27 | __slots__ = ['address']
28 |
29 | def __init__(self, rdclass, rdtype, address):
30 | super(A, self).__init__(rdclass, rdtype)
31 | # check that it's OK
32 | junk = dns.ipv4.inet_aton(address)
33 | self.address = address
34 |
35 | def to_text(self, origin=None, relativize=True, **kw):
36 | return self.address
37 |
38 | def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
39 | address = tok.get_identifier()
40 | tok.get_eol()
41 | return cls(rdclass, rdtype, address)
42 |
43 | from_text = classmethod(from_text)
44 |
45 | def to_wire(self, file, compress = None, origin = None):
46 | file.write(dns.ipv4.inet_aton(self.address))
47 |
48 | def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
49 | address = dns.ipv4.inet_ntoa(wire[current : current + rdlen])
50 | return cls(rdclass, rdtype, address)
51 |
52 | from_wire = classmethod(from_wire)
53 |
54 | def _cmp(self, other):
55 | sa = dns.ipv4.inet_aton(self.address)
56 | oa = dns.ipv4.inet_aton(other.address)
57 | return cmp(sa, oa)
58 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/IN/AAAA.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import dns.exception
17 | import dns.inet
18 | import dns.rdata
19 | import dns.tokenizer
20 |
21 | class AAAA(dns.rdata.Rdata):
22 | """AAAA record.
23 |
24 | @ivar address: an IPv6 address
25 | @type address: string (in the standard IPv6 format)"""
26 |
27 | __slots__ = ['address']
28 |
29 | def __init__(self, rdclass, rdtype, address):
30 | super(AAAA, self).__init__(rdclass, rdtype)
31 | # check that it's OK
32 | junk = dns.inet.inet_pton(dns.inet.AF_INET6, address)
33 | self.address = address
34 |
35 | def to_text(self, origin=None, relativize=True, **kw):
36 | return self.address
37 |
38 | def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
39 | address = tok.get_identifier()
40 | tok.get_eol()
41 | return cls(rdclass, rdtype, address)
42 |
43 | from_text = classmethod(from_text)
44 |
45 | def to_wire(self, file, compress = None, origin = None):
46 | file.write(dns.inet.inet_pton(dns.inet.AF_INET6, self.address))
47 |
48 | def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
49 | address = dns.inet.inet_ntop(dns.inet.AF_INET6,
50 | wire[current : current + rdlen])
51 | return cls(rdclass, rdtype, address)
52 |
53 | from_wire = classmethod(from_wire)
54 |
55 | def _cmp(self, other):
56 | sa = dns.inet.inet_pton(dns.inet.AF_INET6, self.address)
57 | oa = dns.inet.inet_pton(dns.inet.AF_INET6, other.address)
58 | return cmp(sa, oa)
59 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/IN/DHCID.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2006, 2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import dns.exception
17 |
18 | class DHCID(dns.rdata.Rdata):
19 | """DHCID record
20 |
21 | @ivar data: the data (the content of the RR is opaque as far as the
22 | DNS is concerned)
23 | @type data: string
24 | @see: RFC 4701"""
25 |
26 | __slots__ = ['data']
27 |
28 | def __init__(self, rdclass, rdtype, data):
29 | super(DHCID, self).__init__(rdclass, rdtype)
30 | self.data = data
31 |
32 | def to_text(self, origin=None, relativize=True, **kw):
33 | return dns.rdata._base64ify(self.data)
34 |
35 | def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
36 | chunks = []
37 | while 1:
38 | t = tok.get().unescape()
39 | if t.is_eol_or_eof():
40 | break
41 | if not t.is_identifier():
42 | raise dns.exception.SyntaxError
43 | chunks.append(t.value)
44 | b64 = ''.join(chunks)
45 | data = b64.decode('base64_codec')
46 | return cls(rdclass, rdtype, data)
47 |
48 | from_text = classmethod(from_text)
49 |
50 | def to_wire(self, file, compress = None, origin = None):
51 | file.write(self.data)
52 |
53 | def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
54 | data = wire[current : current + rdlen].unwrap()
55 | return cls(rdclass, rdtype, data)
56 |
57 | from_wire = classmethod(from_wire)
58 |
59 | def _cmp(self, other):
60 | return cmp(self.data, other.data)
61 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/IN/KX.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import dns.rdtypes.mxbase
17 |
18 | class KX(dns.rdtypes.mxbase.UncompressedMX):
19 | """KX record"""
20 | pass
21 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/IN/NSAP.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import dns.exception
17 | import dns.rdata
18 | import dns.tokenizer
19 |
20 | class NSAP(dns.rdata.Rdata):
21 | """NSAP record.
22 |
23 | @ivar address: a NASP
24 | @type address: string
25 | @see: RFC 1706"""
26 |
27 | __slots__ = ['address']
28 |
29 | def __init__(self, rdclass, rdtype, address):
30 | super(NSAP, self).__init__(rdclass, rdtype)
31 | self.address = address
32 |
33 | def to_text(self, origin=None, relativize=True, **kw):
34 | return "0x%s" % self.address.encode('hex_codec')
35 |
36 | def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
37 | address = tok.get_string()
38 | t = tok.get_eol()
39 | if address[0:2] != '0x':
40 | raise dns.exception.SyntaxError('string does not start with 0x')
41 | address = address[2:].replace('.', '')
42 | if len(address) % 2 != 0:
43 | raise dns.exception.SyntaxError('hexstring has odd length')
44 | address = address.decode('hex_codec')
45 | return cls(rdclass, rdtype, address)
46 |
47 | from_text = classmethod(from_text)
48 |
49 | def to_wire(self, file, compress = None, origin = None):
50 | file.write(self.address)
51 |
52 | def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
53 | address = wire[current : current + rdlen].unwrap()
54 | return cls(rdclass, rdtype, address)
55 |
56 | from_wire = classmethod(from_wire)
57 |
58 | def _cmp(self, other):
59 | return cmp(self.address, other.address)
60 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/IN/NSAP_PTR.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import dns.rdtypes.nsbase
17 |
18 | class NSAP_PTR(dns.rdtypes.nsbase.UncompressedNS):
19 | """NSAP-PTR record"""
20 | pass
21 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/IN/PX.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import struct
17 |
18 | import dns.exception
19 | import dns.rdata
20 | import dns.name
21 |
22 | class PX(dns.rdata.Rdata):
23 | """PX record.
24 |
25 | @ivar preference: the preference value
26 | @type preference: int
27 | @ivar map822: the map822 name
28 | @type map822: dns.name.Name object
29 | @ivar mapx400: the mapx400 name
30 | @type mapx400: dns.name.Name object
31 | @see: RFC 2163"""
32 |
33 | __slots__ = ['preference', 'map822', 'mapx400']
34 |
35 | def __init__(self, rdclass, rdtype, preference, map822, mapx400):
36 | super(PX, self).__init__(rdclass, rdtype)
37 | self.preference = preference
38 | self.map822 = map822
39 | self.mapx400 = mapx400
40 |
41 | def to_text(self, origin=None, relativize=True, **kw):
42 | map822 = self.map822.choose_relativity(origin, relativize)
43 | mapx400 = self.mapx400.choose_relativity(origin, relativize)
44 | return '%d %s %s' % (self.preference, map822, mapx400)
45 |
46 | def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
47 | preference = tok.get_uint16()
48 | map822 = tok.get_name()
49 | map822 = map822.choose_relativity(origin, relativize)
50 | mapx400 = tok.get_name(None)
51 | mapx400 = mapx400.choose_relativity(origin, relativize)
52 | tok.get_eol()
53 | return cls(rdclass, rdtype, preference, map822, mapx400)
54 |
55 | from_text = classmethod(from_text)
56 |
57 | def to_wire(self, file, compress = None, origin = None):
58 | pref = struct.pack("!H", self.preference)
59 | file.write(pref)
60 | self.map822.to_wire(file, None, origin)
61 | self.mapx400.to_wire(file, None, origin)
62 |
63 | def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
64 | (preference, ) = struct.unpack('!H', wire[current : current + 2])
65 | current += 2
66 | rdlen -= 2
67 | (map822, cused) = dns.name.from_wire(wire[: current + rdlen],
68 | current)
69 | if cused > rdlen:
70 | raise dns.exception.FormError
71 | current += cused
72 | rdlen -= cused
73 | if not origin is None:
74 | map822 = map822.relativize(origin)
75 | (mapx400, cused) = dns.name.from_wire(wire[: current + rdlen],
76 | current)
77 | if cused != rdlen:
78 | raise dns.exception.FormError
79 | if not origin is None:
80 | mapx400 = mapx400.relativize(origin)
81 | return cls(rdclass, rdtype, preference, map822, mapx400)
82 |
83 | from_wire = classmethod(from_wire)
84 |
85 | def choose_relativity(self, origin = None, relativize = True):
86 | self.map822 = self.map822.choose_relativity(origin, relativize)
87 | self.mapx400 = self.mapx400.choose_relativity(origin, relativize)
88 |
89 | def _cmp(self, other):
90 | sp = struct.pack("!H", self.preference)
91 | op = struct.pack("!H", other.preference)
92 | v = cmp(sp, op)
93 | if v == 0:
94 | v = cmp(self.map822, other.map822)
95 | if v == 0:
96 | v = cmp(self.mapx400, other.mapx400)
97 | return v
98 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/IN/SRV.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import struct
17 |
18 | import dns.exception
19 | import dns.rdata
20 | import dns.name
21 |
22 | class SRV(dns.rdata.Rdata):
23 | """SRV record
24 |
25 | @ivar priority: the priority
26 | @type priority: int
27 | @ivar weight: the weight
28 | @type weight: int
29 | @ivar port: the port of the service
30 | @type port: int
31 | @ivar target: the target host
32 | @type target: dns.name.Name object
33 | @see: RFC 2782"""
34 |
35 | __slots__ = ['priority', 'weight', 'port', 'target']
36 |
37 | def __init__(self, rdclass, rdtype, priority, weight, port, target):
38 | super(SRV, self).__init__(rdclass, rdtype)
39 | self.priority = priority
40 | self.weight = weight
41 | self.port = port
42 | self.target = target
43 |
44 | def to_text(self, origin=None, relativize=True, **kw):
45 | target = self.target.choose_relativity(origin, relativize)
46 | return '%d %d %d %s' % (self.priority, self.weight, self.port,
47 | target)
48 |
49 | def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
50 | priority = tok.get_uint16()
51 | weight = tok.get_uint16()
52 | port = tok.get_uint16()
53 | target = tok.get_name(None)
54 | target = target.choose_relativity(origin, relativize)
55 | tok.get_eol()
56 | return cls(rdclass, rdtype, priority, weight, port, target)
57 |
58 | from_text = classmethod(from_text)
59 |
60 | def to_wire(self, file, compress = None, origin = None):
61 | three_ints = struct.pack("!HHH", self.priority, self.weight, self.port)
62 | file.write(three_ints)
63 | self.target.to_wire(file, compress, origin)
64 |
65 | def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
66 | (priority, weight, port) = struct.unpack('!HHH',
67 | wire[current : current + 6])
68 | current += 6
69 | rdlen -= 6
70 | (target, cused) = dns.name.from_wire(wire[: current + rdlen],
71 | current)
72 | if cused != rdlen:
73 | raise dns.exception.FormError
74 | if not origin is None:
75 | target = target.relativize(origin)
76 | return cls(rdclass, rdtype, priority, weight, port, target)
77 |
78 | from_wire = classmethod(from_wire)
79 |
80 | def choose_relativity(self, origin = None, relativize = True):
81 | self.target = self.target.choose_relativity(origin, relativize)
82 |
83 | def _cmp(self, other):
84 | sp = struct.pack("!HHH", self.priority, self.weight, self.port)
85 | op = struct.pack("!HHH", other.priority, other.weight, other.port)
86 | v = cmp(sp, op)
87 | if v == 0:
88 | v = cmp(self.target, other.target)
89 | return v
90 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/IN/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | """Class IN rdata type classes."""
17 |
18 | __all__ = [
19 | 'A',
20 | 'AAAA',
21 | 'APL',
22 | 'DHCID',
23 | 'KX',
24 | 'NAPTR',
25 | 'NSAP',
26 | 'NSAP_PTR',
27 | 'PX',
28 | 'SRV',
29 | 'WKS',
30 | ]
31 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | """DNS rdata type classes"""
17 |
18 | __all__ = [
19 | 'ANY',
20 | 'IN',
21 | 'mxbase',
22 | 'nsbase',
23 | ]
24 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/dsbase.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2010, 2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | import struct
17 |
18 | import dns.rdata
19 | import dns.rdatatype
20 |
21 | class DSBase(dns.rdata.Rdata):
22 | """Base class for rdata that is like a DS record
23 |
24 | @ivar key_tag: the key tag
25 | @type key_tag: int
26 | @ivar algorithm: the algorithm
27 | @type algorithm: int
28 | @ivar digest_type: the digest type
29 | @type digest_type: int
30 | @ivar digest: the digest
31 | @type digest: int
32 | @see: draft-ietf-dnsext-delegation-signer-14.txt"""
33 |
34 | __slots__ = ['key_tag', 'algorithm', 'digest_type', 'digest']
35 |
36 | def __init__(self, rdclass, rdtype, key_tag, algorithm, digest_type,
37 | digest):
38 | super(DSBase, self).__init__(rdclass, rdtype)
39 | self.key_tag = key_tag
40 | self.algorithm = algorithm
41 | self.digest_type = digest_type
42 | self.digest = digest
43 |
44 | def to_text(self, origin=None, relativize=True, **kw):
45 | return '%d %d %d %s' % (self.key_tag, self.algorithm,
46 | self.digest_type,
47 | dns.rdata._hexify(self.digest,
48 | chunksize=128))
49 |
50 | def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
51 | key_tag = tok.get_uint16()
52 | algorithm = tok.get_uint8()
53 | digest_type = tok.get_uint8()
54 | chunks = []
55 | while 1:
56 | t = tok.get().unescape()
57 | if t.is_eol_or_eof():
58 | break
59 | if not t.is_identifier():
60 | raise dns.exception.SyntaxError
61 | chunks.append(t.value)
62 | digest = ''.join(chunks)
63 | digest = digest.decode('hex_codec')
64 | return cls(rdclass, rdtype, key_tag, algorithm, digest_type,
65 | digest)
66 |
67 | from_text = classmethod(from_text)
68 |
69 | def to_wire(self, file, compress = None, origin = None):
70 | header = struct.pack("!HBB", self.key_tag, self.algorithm,
71 | self.digest_type)
72 | file.write(header)
73 | file.write(self.digest)
74 |
75 | def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
76 | header = struct.unpack("!HBB", wire[current : current + 4])
77 | current += 4
78 | rdlen -= 4
79 | digest = wire[current : current + rdlen].unwrap()
80 | return cls(rdclass, rdtype, header[0], header[1], header[2], digest)
81 |
82 | from_wire = classmethod(from_wire)
83 |
84 | def _cmp(self, other):
85 | hs = struct.pack("!HBB", self.key_tag, self.algorithm,
86 | self.digest_type)
87 | ho = struct.pack("!HBB", other.key_tag, other.algorithm,
88 | other.digest_type)
89 | v = cmp(hs, ho)
90 | if v == 0:
91 | v = cmp(self.digest, other.digest)
92 | return v
93 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/nsbase.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | """NS-like base classes."""
17 |
18 | import cStringIO
19 |
20 | import dns.exception
21 | import dns.rdata
22 | import dns.name
23 |
24 | class NSBase(dns.rdata.Rdata):
25 | """Base class for rdata that is like an NS record.
26 |
27 | @ivar target: the target name of the rdata
28 | @type target: dns.name.Name object"""
29 |
30 | __slots__ = ['target']
31 |
32 | def __init__(self, rdclass, rdtype, target):
33 | super(NSBase, self).__init__(rdclass, rdtype)
34 | self.target = target
35 |
36 | def to_text(self, origin=None, relativize=True, **kw):
37 | target = self.target.choose_relativity(origin, relativize)
38 | return str(target)
39 |
40 | def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
41 | target = tok.get_name()
42 | target = target.choose_relativity(origin, relativize)
43 | tok.get_eol()
44 | return cls(rdclass, rdtype, target)
45 |
46 | from_text = classmethod(from_text)
47 |
48 | def to_wire(self, file, compress = None, origin = None):
49 | self.target.to_wire(file, compress, origin)
50 |
51 | def to_digestable(self, origin = None):
52 | return self.target.to_digestable(origin)
53 |
54 | def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
55 | (target, cused) = dns.name.from_wire(wire[: current + rdlen],
56 | current)
57 | if cused != rdlen:
58 | raise dns.exception.FormError
59 | if not origin is None:
60 | target = target.relativize(origin)
61 | return cls(rdclass, rdtype, target)
62 |
63 | from_wire = classmethod(from_wire)
64 |
65 | def choose_relativity(self, origin = None, relativize = True):
66 | self.target = self.target.choose_relativity(origin, relativize)
67 |
68 | def _cmp(self, other):
69 | return cmp(self.target, other.target)
70 |
71 | class UncompressedNS(NSBase):
72 | """Base class for rdata that is like an NS record, but whose name
73 | is not compressed when convert to DNS wire format, and whose
74 | digestable form is not downcased."""
75 |
76 | def to_wire(self, file, compress = None, origin = None):
77 | super(UncompressedNS, self).to_wire(file, None, origin)
78 |
79 | def to_digestable(self, origin = None):
80 | f = cStringIO.StringIO()
81 | self.to_wire(f, None, origin)
82 | return f.getvalue()
83 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/rdtypes/txtbase.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2006, 2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | """TXT-like base class."""
17 |
18 | import dns.exception
19 | import dns.rdata
20 | import dns.tokenizer
21 |
22 | class TXTBase(dns.rdata.Rdata):
23 | """Base class for rdata that is like a TXT record
24 |
25 | @ivar strings: the text strings
26 | @type strings: list of string
27 | @see: RFC 1035"""
28 |
29 | __slots__ = ['strings']
30 |
31 | def __init__(self, rdclass, rdtype, strings):
32 | super(TXTBase, self).__init__(rdclass, rdtype)
33 | if isinstance(strings, str):
34 | strings = [ strings ]
35 | self.strings = strings[:]
36 |
37 | def to_text(self, origin=None, relativize=True, **kw):
38 | txt = ''
39 | prefix = ''
40 | for s in self.strings:
41 | txt += '%s"%s"' % (prefix, dns.rdata._escapify(s))
42 | prefix = ' '
43 | return txt
44 |
45 | def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
46 | strings = []
47 | while 1:
48 | token = tok.get().unescape()
49 | if token.is_eol_or_eof():
50 | break
51 | if not (token.is_quoted_string() or token.is_identifier()):
52 | raise dns.exception.SyntaxError("expected a string")
53 | if len(token.value) > 255:
54 | raise dns.exception.SyntaxError("string too long")
55 | strings.append(token.value)
56 | if len(strings) == 0:
57 | raise dns.exception.UnexpectedEnd
58 | return cls(rdclass, rdtype, strings)
59 |
60 | from_text = classmethod(from_text)
61 |
62 | def to_wire(self, file, compress = None, origin = None):
63 | for s in self.strings:
64 | l = len(s)
65 | assert l < 256
66 | byte = chr(l)
67 | file.write(byte)
68 | file.write(s)
69 |
70 | def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
71 | strings = []
72 | while rdlen > 0:
73 | l = ord(wire[current])
74 | current += 1
75 | rdlen -= 1
76 | if l > rdlen:
77 | raise dns.exception.FormError
78 | s = wire[current : current + l].unwrap()
79 | current += l
80 | rdlen -= l
81 | strings.append(s)
82 | return cls(rdclass, rdtype, strings)
83 |
84 | from_wire = classmethod(from_wire)
85 |
86 | def _cmp(self, other):
87 | return cmp(self.strings, other.strings)
88 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/reversename.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2006, 2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | """DNS Reverse Map Names.
17 |
18 | @var ipv4_reverse_domain: The DNS IPv4 reverse-map domain, in-addr.arpa.
19 | @type ipv4_reverse_domain: dns.name.Name object
20 | @var ipv6_reverse_domain: The DNS IPv6 reverse-map domain, ip6.arpa.
21 | @type ipv6_reverse_domain: dns.name.Name object
22 | """
23 |
24 | import dns.name
25 | import dns.ipv6
26 | import dns.ipv4
27 |
28 | ipv4_reverse_domain = dns.name.from_text('in-addr.arpa.')
29 | ipv6_reverse_domain = dns.name.from_text('ip6.arpa.')
30 |
31 | def from_address(text):
32 | """Convert an IPv4 or IPv6 address in textual form into a Name object whose
33 | value is the reverse-map domain name of the address.
34 | @param text: an IPv4 or IPv6 address in textual form (e.g. '127.0.0.1',
35 | '::1')
36 | @type text: str
37 | @rtype: dns.name.Name object
38 | """
39 | try:
40 | v6 = dns.ipv6.inet_aton(text)
41 | if dns.ipv6.is_mapped(v6):
42 | parts = ['%d' % ord(byte) for byte in v6[12:]]
43 | origin = ipv4_reverse_domain
44 | else:
45 | parts = list(v6.encode('hex_codec'))
46 | origin = ipv6_reverse_domain
47 | except:
48 | parts = ['%d' % ord(byte) for byte in dns.ipv4.inet_aton(text)]
49 | origin = ipv4_reverse_domain
50 | parts.reverse()
51 | return dns.name.from_text('.'.join(parts), origin=origin)
52 |
53 | def to_address(name):
54 | """Convert a reverse map domain name into textual address form.
55 | @param name: an IPv4 or IPv6 address in reverse-map form.
56 | @type name: dns.name.Name object
57 | @rtype: str
58 | """
59 | if name.is_subdomain(ipv4_reverse_domain):
60 | name = name.relativize(ipv4_reverse_domain)
61 | labels = list(name.labels)
62 | labels.reverse()
63 | text = '.'.join(labels)
64 | # run through inet_aton() to check syntax and make pretty.
65 | return dns.ipv4.inet_ntoa(dns.ipv4.inet_aton(text))
66 | elif name.is_subdomain(ipv6_reverse_domain):
67 | name = name.relativize(ipv6_reverse_domain)
68 | labels = list(name.labels)
69 | labels.reverse()
70 | parts = []
71 | i = 0
72 | l = len(labels)
73 | while i < l:
74 | parts.append(''.join(labels[i:i+4]))
75 | i += 4
76 | text = ':'.join(parts)
77 | # run through inet_aton() to check syntax and make pretty.
78 | return dns.ipv6.inet_ntoa(dns.ipv6.inet_aton(text))
79 | else:
80 | raise dns.exception.SyntaxError('unknown reverse-map address family')
81 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/tsigkeyring.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | """A place to store TSIG keys."""
17 |
18 | import base64
19 |
20 | import dns.name
21 |
22 | def from_text(textring):
23 | """Convert a dictionary containing (textual DNS name, base64 secret) pairs
24 | into a binary keyring which has (dns.name.Name, binary secret) pairs.
25 | @rtype: dict"""
26 |
27 | keyring = {}
28 | for keytext in textring:
29 | keyname = dns.name.from_text(keytext)
30 | secret = base64.decodestring(textring[keytext])
31 | keyring[keyname] = secret
32 | return keyring
33 |
34 | def to_text(keyring):
35 | """Convert a dictionary containing (dns.name.Name, binary secret) pairs
36 | into a text keyring which has (textual DNS name, base64 secret) pairs.
37 | @rtype: dict"""
38 |
39 | textring = {}
40 | for keyname in keyring:
41 | keytext = keyname.to_text()
42 | secret = base64.encodestring(keyring[keyname])
43 | textring[keytext] = secret
44 | return textring
45 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/ttl.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | """DNS TTL conversion."""
17 |
18 | import dns.exception
19 |
20 | class BadTTL(dns.exception.SyntaxError):
21 | pass
22 |
23 | def from_text(text):
24 | """Convert the text form of a TTL to an integer.
25 |
26 | The BIND 8 units syntax for TTLs (e.g. '1w6d4h3m10s') is supported.
27 |
28 | @param text: the textual TTL
29 | @type text: string
30 | @raises dns.ttl.BadTTL: the TTL is not well-formed
31 | @rtype: int
32 | """
33 |
34 | if text.isdigit():
35 | total = long(text)
36 | else:
37 | if not text[0].isdigit():
38 | raise BadTTL
39 | total = 0L
40 | current = 0L
41 | for c in text:
42 | if c.isdigit():
43 | current *= 10
44 | current += long(c)
45 | else:
46 | c = c.lower()
47 | if c == 'w':
48 | total += current * 604800L
49 | elif c == 'd':
50 | total += current * 86400L
51 | elif c == 'h':
52 | total += current * 3600L
53 | elif c == 'm':
54 | total += current * 60L
55 | elif c == 's':
56 | total += current
57 | else:
58 | raise BadTTL("unknown unit '%s'" % c)
59 | current = 0
60 | if not current == 0:
61 | raise BadTTL("trailing integer")
62 | if total < 0L or total > 2147483647L:
63 | raise BadTTL("TTL should be between 0 and 2^31 - 1 (inclusive)")
64 | return total
65 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/version.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | """dnspython release version information."""
17 |
18 | MAJOR = 1
19 | MINOR = 12
20 | MICRO = 0
21 | RELEASELEVEL = 0x0f
22 | SERIAL = 0
23 |
24 | if RELEASELEVEL == 0x0f:
25 | version = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
26 | elif RELEASELEVEL == 0x00:
27 | version = '%d.%d.%dx%d' % \
28 | (MAJOR, MINOR, MICRO, SERIAL)
29 | else:
30 | version = '%d.%d.%d%x%d' % \
31 | (MAJOR, MINOR, MICRO, RELEASELEVEL, SERIAL)
32 |
33 | hexversion = MAJOR << 24 | MINOR << 16 | MICRO << 8 | RELEASELEVEL << 4 | \
34 | SERIAL
35 |
--------------------------------------------------------------------------------
/invalid-email-filter/dns/wiredata.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2011 Nominum, Inc.
2 | #
3 | # Permission to use, copy, modify, and distribute this software and its
4 | # documentation for any purpose with or without fee is hereby granted,
5 | # provided that the above copyright notice and this permission notice
6 | # appear in all copies.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 | # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 |
16 | """DNS Wire Data Helper"""
17 |
18 | import sys
19 |
20 | import dns.exception
21 |
22 | # Figure out what constant python passes for an unspecified slice bound.
23 | # It's supposed to be sys.maxint, yet on 64-bit windows sys.maxint is 2^31 - 1
24 | # but Python uses 2^63 - 1 as the constant. Rather than making pointless
25 | # extra comparisons, duplicating code, or weakening WireData, we just figure
26 | # out what constant Python will use.
27 |
28 | class _SliceUnspecifiedBound(str):
29 | def __getslice__(self, i, j):
30 | return j
31 |
32 | _unspecified_bound = _SliceUnspecifiedBound('')[1:]
33 |
34 | class WireData(str):
35 | # WireData is a string with stricter slicing
36 | def __getitem__(self, key):
37 | try:
38 | return WireData(super(WireData, self).__getitem__(key))
39 | except IndexError:
40 | raise dns.exception.FormError
41 | def __getslice__(self, i, j):
42 | try:
43 | if j == _unspecified_bound:
44 | # handle the case where the right bound is unspecified
45 | j = len(self)
46 | if i < 0 or j < 0:
47 | raise dns.exception.FormError
48 | # If it's not an empty slice, access left and right bounds
49 | # to make sure they're valid
50 | if i != j:
51 | super(WireData, self).__getitem__(i)
52 | super(WireData, self).__getitem__(j - 1)
53 | return WireData(super(WireData, self).__getslice__(i, j))
54 | except IndexError:
55 | raise dns.exception.FormError
56 | def __iter__(self):
57 | i = 0
58 | while 1:
59 | try:
60 | yield self[i]
61 | i += 1
62 | except dns.exception.FormError:
63 | raise StopIteration
64 | def unwrap(self):
65 | return str(self)
66 |
67 | def maybe_wrap(wire):
68 | if not isinstance(wire, WireData):
69 | return WireData(wire)
70 | else:
71 | return wire
72 |
--------------------------------------------------------------------------------
/ixquick.php:
--------------------------------------------------------------------------------
1 | $v){
19 | $strings.="&".urlencode($k)."=".urlencode($v);
20 | }
21 | return $strings;
22 | }
23 |
24 | function get_result($strings){
25 | $content="";
26 | preg_match_all("/[\s\S]*?<\/li>/i",$strings,$match);
27 | foreach($match[0] as $list){
28 | preg_match("/(.*?)<\/span>/i",$list,$m);
29 | preg_match("/
') return $content; 52 | preg_match_all("/
"); 22 | -------------------------------------------------------------------------------- /auto website/templates/media/main-products.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hitoy/seotools/950dc87fcb82306c5f8d4f936289f1d21ed41329/auto website/templates/media/main-products.jpg -------------------------------------------------------------------------------- /auto website/templates/robots.php: -------------------------------------------------------------------------------- 1 | 7 | User-agent: * 8 | sitemap: 9 | 10 | Disallow: /wp-admin/ 11 | Disallow: /wp-includes/ 12 | Disallow: /data/ 13 | Disallow: /cache/ 14 | Allow: / 15 | 28 | -------------------------------------------------------------------------------- /auto website/templates/sitemap.php: -------------------------------------------------------------------------------- 1 | 8 | 9 |([\s\S\n]*?)<\/p>/i",$content,$match); 53 | if(!$match[0]) return $content; 54 | $content = preg_replace("/
[^<>]*<\/h2>/i","",$content); 55 | $arr=explode('',$content); 56 | if(count($arr)>$imgoffset){ 57 | $arr[$imgoffset]=$arr[$imgoffset]."\n".show_rand_img($alt,1,$imgdir)."\n"; 58 | }else if(count($arr)>1){ 59 | $arr[0]=$arr[0]."\n".show_rand_img($alt,1,$imgdir)."\n"; 60 | } 61 | $content=implode('',$arr); 62 | $content=strip_tags($content,'
');
63 | $content=str_replace("...","",$content);
64 | return $content;
65 | }
66 | //show just p
67 | function showp($content){
68 | $content=trim($content);
69 | if(substr($content,0,4) != '
') return $content; 70 | preg_match_all("/
([\s\S\n]*?)<\/p>/i",$content,$match); 71 | if(!$match[0]) return $content; 72 | $content = preg_replace("/
[^<>]*<\/h2>/i","",$content); 73 | $content = str_replace("...","",$content); 74 | return $content; 75 | } 76 | -------------------------------------------------------------------------------- /auto website/templates/index.php: -------------------------------------------------------------------------------- 1 | get_the_list($offset); 6 | ?> 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
40 |
41 |
42 |
43 |
44 |
45 |
50 |
51 | pageinfo();
54 | ?>
55 |
56 |
90 |
91 |
92 |
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/auto website/templates/media/70years.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hitoy/seotools/950dc87fcb82306c5f8d4f936289f1d21ed41329/auto website/templates/media/70years.jpg
--------------------------------------------------------------------------------
/auto website/templates/media/70years.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hitoy/seotools/950dc87fcb82306c5f8d4f936289f1d21ed41329/auto website/templates/media/70years.png
--------------------------------------------------------------------------------
/auto website/templates/media/banner1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hitoy/seotools/950dc87fcb82306c5f8d4f936289f1d21ed41329/auto website/templates/media/banner1.jpg
--------------------------------------------------------------------------------
/auto website/templates/media/banner10.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hitoy/seotools/950dc87fcb82306c5f8d4f936289f1d21ed41329/auto website/templates/media/banner10.jpg
--------------------------------------------------------------------------------
/auto website/templates/media/banner11.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hitoy/seotools/950dc87fcb82306c5f8d4f936289f1d21ed41329/auto website/templates/media/banner11.jpg
--------------------------------------------------------------------------------
/auto website/templates/media/banner12.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hitoy/seotools/950dc87fcb82306c5f8d4f936289f1d21ed41329/auto website/templates/media/banner12.jpg
--------------------------------------------------------------------------------
/auto website/templates/media/banner13.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hitoy/seotools/950dc87fcb82306c5f8d4f936289f1d21ed41329/auto website/templates/media/banner13.jpg
--------------------------------------------------------------------------------
/auto website/templates/media/banner14.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hitoy/seotools/950dc87fcb82306c5f8d4f936289f1d21ed41329/auto website/templates/media/banner14.jpg
--------------------------------------------------------------------------------
/auto website/templates/media/banner15.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hitoy/seotools/950dc87fcb82306c5f8d4f936289f1d21ed41329/auto website/templates/media/banner15.jpg
--------------------------------------------------------------------------------
/auto website/templates/media/banner16.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hitoy/seotools/950dc87fcb82306c5f8d4f936289f1d21ed41329/auto website/templates/media/banner16.jpg
--------------------------------------------------------------------------------
/auto website/templates/media/banner17.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hitoy/seotools/950dc87fcb82306c5f8d4f936289f1d21ed41329/auto website/templates/media/banner17.jpg
--------------------------------------------------------------------------------
/auto website/templates/media/banner18.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hitoy/seotools/950dc87fcb82306c5f8d4f936289f1d21ed41329/auto website/templates/media/banner18.jpg
--------------------------------------------------------------------------------
/auto website/templates/media/banner2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hitoy/seotools/950dc87fcb82306c5f8d4f936289f1d21ed41329/auto website/templates/media/banner2.jpg
--------------------------------------------------------------------------------
/auto website/templates/media/banner3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hitoy/seotools/950dc87fcb82306c5f8d4f936289f1d21ed41329/auto website/templates/media/banner3.jpg
--------------------------------------------------------------------------------
/auto website/templates/media/banner4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hitoy/seotools/950dc87fcb82306c5f8d4f936289f1d21ed41329/auto website/templates/media/banner4.jpg
--------------------------------------------------------------------------------
/auto website/templates/media/banner5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hitoy/seotools/950dc87fcb82306c5f8d4f936289f1d21ed41329/auto website/templates/media/banner5.jpg
--------------------------------------------------------------------------------
/auto website/templates/media/banner6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hitoy/seotools/950dc87fcb82306c5f8d4f936289f1d21ed41329/auto website/templates/media/banner6.jpg
--------------------------------------------------------------------------------
/auto website/templates/media/banner7.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hitoy/seotools/950dc87fcb82306c5f8d4f936289f1d21ed41329/auto website/templates/media/banner7.jpg
--------------------------------------------------------------------------------
/auto website/templates/media/banner8.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hitoy/seotools/950dc87fcb82306c5f8d4f936289f1d21ed41329/auto website/templates/media/banner8.jpg
--------------------------------------------------------------------------------
/auto website/templates/media/banner9.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hitoy/seotools/950dc87fcb82306c5f8d4f936289f1d21ed41329/auto website/templates/media/banner9.jpg
--------------------------------------------------------------------------------
/auto website/templates/media/form1.js:
--------------------------------------------------------------------------------
1 | document.writeln("
删除字数小于指定数量的文章
21 | 25 | query("delete from wp_posts where length(post_content) < $words"); 33 | } 34 | 35 | add_action('admin_menu', 'display_delete_menu'); 36 | -------------------------------------------------------------------------------- /directindustry.com/a.json: -------------------------------------------------------------------------------- 1 | window.ve.floatingBar.tree = [{"hasSelectedChild":false,"order":0,"isFeature":true,"isCompany":null,"isSubConcept":null,"isSuggestion":null,"isSpec":null,"label":"PORTABILITY","items":[{"id":2263,"label":"mobile","nbProducts":52,"hasChild":true,"checked":false,"hasSelectedChild":null,"childs":[]},{"id":20437,"label":"fixed","nbProducts":30,"hasChild":false,"checked":false,"hasSelectedChild":null,"childs":[]},{"id":471900,"label":"not specified","nbProducts":61,"hasChild":false,"checked":false,"hasSelectedChild":null,"childs":[]}],"spec":null},{"hasSelectedChild":false,"order":1,"isFeature":true,"isCompany":null,"isSubConcept":null,"isSuggestion":null,"isSpec":null,"label":"CONFIGURATION","items":[{"id":22107,"label":"chest","nbProducts":57,"hasChild":false,"checked":false,"hasSelectedChild":null,"childs":[]},{"id":37477,"label":"compact","nbProducts":18,"hasChild":false,"checked":false,"hasSelectedChild":null,"childs":[]},{"id":22105,"label":"cabinet","nbProducts":10,"hasChild":false,"checked":false,"hasSelectedChild":null,"childs":[]},{"id":475092,"label":"not specified","nbProducts":61,"hasChild":false,"checked":false,"hasSelectedChild":null,"childs":[]}],"spec":null},{"hasSelectedChild":false,"order":2,"isFeature":true,"isCompany":null,"isSubConcept":null,"isSuggestion":null,"isSpec":null,"label":"OTHER CHARACTERISTICS","items":[{"id":66119,"label":"continuous","nbProducts":10,"hasChild":false,"checked":false,"hasSelectedChild":null,"childs":[]},{"id":784084,"label":"double chassis","nbProducts":3,"hasChild":false,"checked":false,"hasSelectedChild":null,"childs":[]},{"id":66115,"label":"reversing drum","nbProducts":2,"hasChild":false,"checked":false,"hasSelectedChild":null,"childs":[]},{"id":784082,"label":"single chassis","nbProducts":2,"hasChild":false,"checked":false,"hasSelectedChild":null,"childs":[]},{"id":686017,"label":"2-axis","nbProducts":1,"hasChild":false,"checked":false,"hasSelectedChild":null,"childs":[]},{"id":477426,"label":"not specified","nbProducts":126,"hasChild":false,"checked":false,"hasSelectedChild":null,"childs":[]}],"spec":null},{"hasSelectedChild":false,"order":3,"isFeature":null,"isCompany":null,"isSubConcept":null,"isSuggestion":null,"isSpec":true,"label":"CAPACITY","items":[],"spec":{"order":3,"id":658,"label":"capacity","unitId":19,"unitLabel":"m³/h","secondaryUnitLabel":"ft³/h","conceptMin":0.0,"conceptMax":300.0,"resultMin":0.0,"resultMax":300.0,"userMin":null,"userMax":null,"precision":2,"unit":"m³/h","type":"SPECIFICATION"}},{"hasSelectedChild":null,"order":-1,"isFeature":null,"isCompany":true,"isSubConcept":null,"isSuggestion":null,"isSpec":null,"label":"MANUFACTURERS","items":[{"id":41134,"label":"Ammann","nbProducts":6,"checked":false},{"id":56888,"label":"ARCEN ENGENHARIA, S.A.","nbProducts":10,"checked":false},{"id":61414,"label":"BHS Sonthofen","nbProducts":2,"checked":false},{"id":157316,"label":"Chongqing Bincheng Electrical And Mechanical Techn","nbProducts":1,"checked":false},{"id":50140,"label":"CIFA S.p.A","nbProducts":8,"checked":false},{"id":64673,"label":"EUROMECC SRL","nbProducts":19,"checked":false},{"id":64523,"label":"fibo intercon","nbProducts":13,"checked":false},{"id":54193,"label":"Guangxi Liugong Machinery Co., Ltd.","nbProducts":4,"checked":false},{"id":168725,"label":"HAWK PALNT","nbProducts":2,"checked":false},{"id":66087,"label":"Jaypee India Limited","nbProducts":3,"checked":false},{"id":23275,"label":"Liebherr-Mischtechnik","nbProducts":17,"checked":false},{"id":62622,"label":"Marcantonini S.r.l.","nbProducts":7,"checked":false},{"id":52887,"label":"SANY Group Co.,Ltd","nbProducts":7,"checked":false},{"id":88531,"label":"SBM Mineral Processing GmbH","nbProducts":8,"checked":false},{"id":71778,"label":"SCHWING GmbH","nbProducts":9,"checked":false},{"id":57420,"label":"SHANDONG SHANTUI CONSTRUCTION MACHINERY IMP&EXP CO","nbProducts":10,"checked":false},{"id":69249,"label":"SIMEM ITALIA","nbProducts":7,"checked":false},{"id":50713,"label":"XCMG","nbProducts":3,"checked":false},{"id":57428,"label":"Zoomlion International Trade Co., Ltd.","nbProducts":7,"checked":false}],"spec":null}]; 2 | -------------------------------------------------------------------------------- /directindustry.com/collection.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding:utf-8 -*- 3 | import urllib2,urllib,sys,gzip,StringIO 4 | 5 | class Collection: 6 | __headers = {"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","Accept-Encoding":"gzip, identity","Accept-Language":"en-US,en;q=0.8","Cache-Control":"max-age=0","Connection":"keep-alive","User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36","Referer":"http://www.directindustry.com/"} 7 | 8 | def __init__(self,url): 9 | self.content = "" 10 | self.url = url 11 | 12 | def add_header(self,key,value): 13 | self.__headers[key] = value 14 | 15 | def get_content(self): 16 | try: 17 | req = urllib2.Request(self.url,headers=self.__headers) 18 | page = urllib2.urlopen(req,timeout=10) 19 | rpheader = page.info() 20 | body = page.read() 21 | except Exception,e: 22 | self.content='' 23 | return None 24 | encoding = rpheader.get("Content-Encoding") 25 | if encoding == 'gzip': 26 | self.content=gz_decoding(body).strip() 27 | else: 28 | self.content=body.strip() 29 | return self.content 30 | 31 | 32 | def gz_decoding(data): 33 | compressedstream = StringIO.StringIO(data) 34 | gziper = gzip.GzipFile(fileobj=compressedstream) 35 | data2 = gziper.read() 36 | return data2 37 | 38 | if __name__ == "__main__": 39 | sys.exit(-1) 40 | -------------------------------------------------------------------------------- /directindustry.com/collection.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hitoy/seotools/950dc87fcb82306c5f8d4f936289f1d21ed41329/directindustry.com/collection.pyc -------------------------------------------------------------------------------- /directindustry.com/endb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hitoy/seotools/950dc87fcb82306c5f8d4f936289f1d21ed41329/directindustry.com/endb -------------------------------------------------------------------------------- /domai-cron-submit/replace.txt: -------------------------------------------------------------------------------- 1 | |-> 2 | --> 3 | ...-> 4 | …-> 5 | re:eBay->Camelway 6 | re:Alibaba->Camelway 7 | re:Quora-> 8 | re:\b[a-z0-9-_\.]+\.[a-z]{2,6}\b-> 9 | re:\\-> 10 | re:\/-> 11 | re:>-> 12 | re:\t+-> 13 | re:\s+-> 14 | -------------------------------------------------------------------------------- /domai-time-modifie/modifie.php: -------------------------------------------------------------------------------- 1 | get_var('select count(ID) from ##_posts'); 12 | 13 | //需要的天数 14 | $total_days = ceil($total_posts/$posts_per_day); 15 | 16 | //最开始的时间 17 | $starttime = time() - $total_days * 3600*24; 18 | 19 | //当前ID 20 | $id = intval($_GET['id']); 21 | 22 | //前面的post条数 23 | $offset = $dmdb->get_var('select count(ID) from ##_posts where ID < '.$id); 24 | 25 | 26 | for($i = 0; $i < 1000; $i++){ 27 | //应该增加的天数 28 | $addtime = floor($offset / $posts_per_day) * 3600 * 24; 29 | $post_date = date('Y-m-d H:i:s',$starttime + $addtime + rand(0,3600*24)); 30 | 31 | $result = $dmdb->query("update ##_posts set post_date = \"$post_date\", post_modified=\"$post_date\" where ID = $id"); 32 | $offset += 1; 33 | $id = $id + 1; 34 | } 35 | 36 | $nxt = $id + 1; 37 | if(!empty($result) && $dmdb->get_var('select ID from ##_posts where ID > '.$id)){ 38 | echo "\r\n"; 39 | echo "总文章条数:$total_posts \t 每天的文章条数: $posts_per_day \t 已经更改文章: $offset"; 40 | }else{ 41 | echo "更新完成!"; 42 | } 43 | -------------------------------------------------------------------------------- /email-recorder/.htaccess: -------------------------------------------------------------------------------- 1 | RewriteEngine on 2 | RewriteCond %{REQUEST_URI} !/openlog.php 3 | RewriteRule . /openlog.php [L] 4 | -------------------------------------------------------------------------------- /email-recorder/openlog.php: -------------------------------------------------------------------------------- 1 | "image/jpeg","png"=>"image/png","gif"=>"image/gif"); 3 | $request = $_SERVER["REQUEST_URI"]; 4 | if(strpos($request,"?")){ 5 | $filename = substr($request,0,strpos($request,"?")); 6 | }else{ 7 | $filename = $request; 8 | } 9 | $mail = isset($_GET["mail"])?$_GET["mail"]:""; 10 | 11 | $subfix = substr($filename,strpos($filename,".")+1); 12 | if(array_key_exists($subfix,$mimetype)){ 13 | $mime = $mimetype[$subfix]; 14 | }else{ 15 | $mime = "text/html"; 16 | } 17 | 18 | if(file_exists($_SERVER["DOCUMENT_ROOT"].$filename)){ 19 | $content = file_get_contents($_SERVER["DOCUMENT_ROOT"].$filename); 20 | $len = strlen($content); 21 | header("Content-Length:$len"); 22 | header("Content-Type:$mime"); 23 | echo $content; 24 | if(!empty($mail)){ 25 | file_put_contents("emailopen.txt",$_SERVER["REMOTE_ADDR"]." - ".$mail." - ".date("Y-y-d H:i:s")."\r\n",LOCK_EX|FILE_APPEND); 26 | } 27 | }else{ 28 | header("HTTP/1.1 404 Not Found"); 29 | } 30 | -------------------------------------------------------------------------------- /email-recorder/unsubscribe.php: -------------------------------------------------------------------------------- 1 | 20 | 21 | 22 | 23 | 24 |34 | 39 |
(.*?)<\/p>/i",$list,$d); 30 | $title = $m[1]; 31 | $pos = stripos($title,"-")?stripos($title,"-"):strlen($title); 32 | $title = substr($title,0,$pos); 33 | $p = $d[1]; 34 | if($title=="" || $p=="") continue; 35 | $content.="
".$title."
\r\n".$p."
\r\n"; 36 | } 37 | return $content; 38 | } 39 | function get_next_page_data($strings){ 40 | global $url; 41 | preg_match("/