socke5 使用curl 测试_使用php的curl类,检测socket5、Http代理服务器可用性

该博客介绍了如何使用PHP的cURL类来测试SOCKS5和HTTP代理服务器的可用性。通过发起请求并验证返回的MD5值,确保代理服务器正常工作。文章包含一个初始化cURL会话的示例代码,设置了代理类型、主机、端口等相关参数。
摘要由CSDN通过智能技术生成

设计初衷当然是用php curl bind不一个sokcet5去访问一个随机页面(公网)这个页面的功能就是通过一个md5来验证sokcet5服务器是否真的可用

A服务器通过 socket5发出http://www.xxorg.com/a.php?t=randkey

B服务器,echo md5($_GET[‘t’] . mykey);

A服务器拿到content以后也用相同算法算一个$resut看看是不是等于B服务器的echo值,如果一样,就是success 不一样就是failed

1.第一个文件curl.inc.php

10. * ’host’ => ”,

11. * ‘header’ => ”,

12. * ‘method’ => ”,

13. * ‘referer’ => ”,

14. * ‘cookie’ => ”,

15. * ‘post_fields’ => ”,

16. * ['login' => '',]

17. * ['password' => '',]

18. * ‘timeout’ => 0

19. * );

20. */

21. public function init($params)

22. {

23. if($this->ch==0)

24. $this->ch = curl_init();

25. $user_agent = ‘Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.8.0.9) Gecko/20061206 Firefox/1.5.0.9′;

26. $header = array(

27. "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5",

28. "Accept-Language: ru-ru,ru;q=0.7,en-us;q=0.5,en;q=0.3",

29. "Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7",

30. "Keep-Alive: 300");

31. if (isset($params[‘host’]) && $params[‘host’]) $header[]="Host: ".$params[‘host’];

32. if (isset($params[‘header’]) && $params[‘header’]) $header[]=$params[‘header’];

33.

34. @curl_setopt ( $this -> ch , CURLOPT_RETURNTRANSFER , 1 );

35. @curl_setopt ( $this -> ch , CURLOPT_VERBOSE , 1 );

36. @curl_setopt ( $this -> ch , CURLOPT_HEADER , 1 );

37. if(strlen($params[‘proxy’])>0) curl_setopt($this->ch, CURLOPT_PROXY,$params[‘proxy’]);

38. if(strlen($params[‘proxyport’])>0) curl_setopt($this->ch, CURLOPT_PROXYPORT, $params[‘proxyprot’]);

39. curl_setopt($this->ch,CURLOPT_PROXYTYPE,CURLPROXY_SOCKS5);

40. if ($params[‘method’] == "HEAD") @curl_setopt($this -> ch,CURLOPT_NOBODY,1);

41. @curl_setopt ( $this -> ch, CURLOPT_FOLLOWLOCATION, 1);

42. @curl_setopt ( $this -> ch , CURLOPT_HTTPHEADER, $header );

43. if ($params[‘referer’]) @curl_setopt ($this -> ch , CURLOPT_REFERER, $params[‘referer’] );

44. @curl_setopt ( $this -> ch , CURLOPT_USERAGENT, $user_agent);

45. if ($params[‘cookie’]) @curl_setopt ($this -> ch , CURLOPT_COOKIE, $params[‘cookie’]);

46.

47. if ( $params[‘method’] == "POST" )

48. {

49. curl_setopt( $this -> ch, CURLOPT_POST, true );

50. curl_setopt( $this -> ch, CURLOPT_POSTFIELDS, $params[‘post_fields’] );

51. }

52. @curl_setopt( $this -> ch, CURLOPT_URL, $params[‘url’]);

53. @curl_setopt ( $this -> ch , CURLOPT_SSL_VERIFYPEER, 0 );

54. @curl_setopt ( $this -> ch , CURLOPT_SSL_VERIFYHOST, 0 );

55. if (i

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值