⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 net-lib.pl

📁 Unix下基于Web的管理工具
💻 PL
字号:
# net-lib.pl# Common local networking functionsdo '../web-lib.pl';&init_config();do "./$gconfig{'os_type'}-lib.pl";# list_hosts()# Parse hosts from /etc/hosts into a data structuresub list_hosts{local @rv;local $lnum = 0;open(HOSTS, $config{'hosts_file'});while(<HOSTS>) {	s/\r|\n//g;	s/#.*$//g;	s/\s+$//g;	if (/(\d+\.\d+\.\d+\.\d+)\s+(.*)$/) {		push(@rv, { 'address' => $1,			    'hosts' => [ split(/\s+/, $2) ],			    'line', $lnum,			    'index', scalar(@rv) });		}	$lnum++;	}close(HOSTS);return @rv;}# create_host(&host)# Add a new host to /etc/hostssub create_host{open(HOSTS, ">>$config{'hosts_file'}");print HOSTS $_[0]->{'address'},"\t",join(" ",@{$_[0]->{'hosts'}}),"\n";close(HOSTS);}# modify_host(&host)# Update the address and hosts of a line in /etc/hostssub modify_host{&replace_file_line($config{'hosts_file'},		   $_[0]->{'line'},		   $_[0]->{'address'}."\t".join(" ",@{$_[0]->{'hosts'}})."\n");}# delete_host(&host)# Delete a host from /etc/hostssub delete_host{&replace_file_line($config{'hosts_file'}, $_[0]->{'line'});}# parse_hex(hex)# Convert an address like ff000000 into 255.0.0.0sub parse_hex{$_[0] =~ /(..)(..)(..)(..)/;return join(".", (hex($1), hex($2), hex($3), hex($4)));}1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -