大家提供了许多linux开代理的方法,一般用到python等语言,一些服务器可能不会安装,然而perl可以说是linux标配的语言,给大家一款Perl语言的socket代理,代码非常少,而且还支持密码,效果还是不错,感觉很稳定。

#!/usr/bin/perl 
 
$auth_enabled = 0; 
$auth_login = "hidden"; 
$auth_pass = "hidden"; 
$port = 44269; 
 
use IO::Socket::INET; 
 
$SIG{'CHLD'} = 'IGNORE'; 
$bind = IO::Socket::INET->new(Listen=>10, Reuse=>1, LocalPort=>$port) or die "Нельзя забиндить порт $port\n"; 
 
while($client = $bind->accept()) { 
$client->autoflush(); 
 
if(fork()){ $client->close(); } 
else { $bind->close(); new_client($client); exit(); } 
} 
 
sub new_client { 
local $t, $i, $buff, $ord, $success; 
local $client = $_[0]; 
sysread($client, $buff, 1); 
 
if(ord($buff) == 5) { 
 sysread($client, $buff, 1); 
 $t = ord($buff); 
 
 unless(sysread($client, $buff, $t) == $t) { return; } 
 
 $success = 0; 
 for($i = 0; $i < $t; $i++) { 
 $ord = ord(substr($buff, $i, 1)); 
 if($ord == 0 && !$auth_enabled) { 
  syswrite($client, "\x05\x00", 2); 
  $success++; 
  break; 
 } 
 elsif($ord == 2 && $auth_enabled) { 
  unless(do_auth($client)){ return; } 
  $success++; 
  break; 
 } 
 } 
 
 if($success) { 
 $t = sysread($client, $buff, 3); 
 
 if(substr($buff, 0, 1) == '\x05') { 
  if(ord(substr($buff, 2, 1)) == 0) { 
  ($host, $raw_host) = socks_get_host($client); 
  if(!$host) { return; } 
  ($port, $raw_port) = socks_get_port($client); 
  if(!$port) { return; } 
  $ord = ord(substr($buff, 1, 1)); 
  $buff = "\x05\x00\x00".$raw_host.$raw_port; 
  syswrite($client, $buff, length($buff)); 
  socks_do($ord, $client, $host, $port); 
  } 
 } 
 } else { syswrite($client, "\x05\xFF", 2); }; 
} 
$client->close(); 
} 
 
sub do_auth { 
local $buff, $login, $pass; 
local $client = $_[0]; 
 
syswrite($client, "\x05\x02", 2); 
sysread($client, $buff, 1); 
 
if(ord($buff) == 1) { 
 sysread($client, $buff, 1); 
 sysread($client, $login, ord($buff)); 
 sysread($client, $buff, 1); 
 sysread($client, $pass, ord($buff)); 
 
 if($login eq $auth_login && $pass eq $auth_pass) { 
 syswrite($client, "\x05\x00", 2); 
 return 1; 
 } else { syswrite($client, "\x05\x01", 2); } 
} 
 
$client->close(); 
return 0; 
} 
 
sub socks_get_host { 
local $client = $_[0]; 
local $t, $ord, $raw_host; 
local $host = ""; 
 
sysread($client, $t, 1); 
$ord = ord($t); 
if($ord == 1) { 
 sysread($client, $raw_host, 4); 
 @host = $raw_host =~ /(.)/g; 
 $host = ord($host[0]).".".ord($host[1]).".".ord($host[2]).".".ord($host[3]); 
} elsif($ord == 3) { 
 sysread($client, $raw_host, 1); 
 sysread($client, $host, ord($raw_host)); 
 $raw_host .= $host; 
} elsif($ord == 4) { 
 #ipv6 - not supported 
} 
 
return ($host, $t.$raw_host); 
} 
 
sub socks_get_port { 
local $client = $_[0]; 
local $raw_port, $port; 
sysread($client, $raw_port, 2); 
$port = ord(substr($raw_port, 0, 1)) << 8 | ord(substr($raw_port, 1, 1)); 
return ($port, $raw_port); 
} 
 
sub socks_do { 
local($t, $client, $host, $port) = @_; 
 
if($t == 1) { socks_connect($client, $host, $port); } 
elsif($t == 2) { socks_bind($client, $host, $port); } 
elsif($t == 3) { socks_udp_associate($client, $host, $port); } 
else { return 0; } 
 
return 1; 
} 
 
sub socks_connect { 
my($client, $host, $port) = @_; 
my $target = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $port, Proto => 'tcp', Type => SOCK_STREAM); 
 
unless($target) { return; } 
 
$target->autoflush(); 
while($client || $target) { 
 my $rin = ""; 
 vec($rin, fileno($client), 1) = 1 if $client; 
 vec($rin, fileno($target), 1) = 1 if $target; 
 my($rout, $eout); 
 select($rout = $rin, undef, $eout = $rin, 120); 
 if (!$rout && !$eout) { return; } 
 my $cbuffer = ""; 
 my $tbuffer = ""; 
 
 if ($client && (vec($eout, fileno($client), 1) || vec($rout, fileno($client), 1))) { 
 my $result = sysread($client, $tbuffer, 1024); 
 if (!defined($result) || !$result) { return; } 
 } 
 
 if ($target && (vec($eout, fileno($target), 1) || vec($rout, fileno($target), 1))) { 
 my $result = sysread($target, $cbuffer, 1024); 
 if (!defined($result) || !$result) { return; } 
 } 
 
 if ($fh && $tbuffer) { print $fh $tbuffer; } 
 
 while (my $len = length($tbuffer)) { 
 my $res = syswrite($target, $tbuffer, $len); 
 if ($res > 0) { $tbuffer = substr($tbuffer, $res); } else { return; } 
 } 
 
 while (my $len = length($cbuffer)) { 
 my $res = syswrite($client, $cbuffer, $len); 
 if ($res > 0) { $cbuffer = substr($cbuffer, $res); } else { return; } 
 } 
} 
} 
 
sub socks_bind { 
my($client, $host, $port) = @_; 
} 
 
sub socks_udp_associate { 
my($client, $host, $port) = @_; 
}
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!

《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线

暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。

艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。

《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。