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

📄 286.htm

📁 unix高级编程原吗
💻 HTM
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>CTerm非常精华下载</title>
</head>
<body bgcolor="#FFFFFF">
<table border="0" width="100%" cellspacing="0" cellpadding="0" height="577">
<tr><td width="32%" rowspan="3" height="123"><img src="DDl_back.jpg" width="300" height="129" alt="DDl_back.jpg"></td><td width="30%" background="DDl_back2.jpg" height="35"><p align="center"><a href="http://apue.dhs.org"><font face="黑体"><big><big>apue</big></big></font></a></td></tr>
<tr>
<td width="68%" background="DDl_back2.jpg" height="44"><big><big><font face="黑体"><p align="center">               ● UNIX网络编程                       (BM: clown)                </font></big></big></td></tr>
<tr>
<td width="68%" height="44" bgcolor="#000000"><font face="黑体"><big><big><p   align="center"></big></big><a href="http://cterm.163.net"><img src="banner.gif" width="400" height="60" alt="banner.gif"border="0"></a></font></td>
</tr>
<tr><td width="100%" colspan="2" height="100" align="center" valign="top"><br><p align="center">[<a href="index.htm">回到开始</a>][<a href="193.htm">上一层</a>][<a href="287.htm">下一篇</a>]
<hr><p align="left"><small>发信人: cpu (奔腾的心), 信区: Solaris <br>

标  题: SOCKS原码: IP FILTER模块ipauth.c <br>

发信站: 华南网木棉站 (Tue Jul  7 11:36:52 1998), 转信 <br>

  <br>

/************************************************************************/ <br>

/* ipauth.c, by digger                                                  */ <br>

/* ip.auth is the file that include all IPs that authorized to access   */ <br>

/* some services of localhost, the format is just like:                 */ <br>

/************************************************************************/ <br>

/* # this is one comments line begin with "#"                           */ <br>

/* 172.18.86.146                                                        */ <br>

/* 172.18.86.145                                                        */ <br>

/* ...                                                                  */ <br>

/************************************************************************/ <br>

/* function InitAuthIP read the authorized IP into memory array, and    */ <br>

/* function IPIsAuthed check if the given IP is authorized              */ <br>

/************************************************************************/ <br>

  <br>

# include       <stdio.h> <br>

# include       <sys/types.h> <br>

# include       <string.h> <br>

# include       <sys/socket.h> <br>

# include       <netinet/in.h> <br>



# include       <arpa/inet.h> <br>

  <br>

# define        MAXHOSTS        32 <br>

# define        TRUE            0 <br>

# define        FALSE           -1 <br>

  <br>

u_long  AuthedIP[MAXHOSTS];     /* authorized IPs */ <br>

int     AuthedIPNum;            /* number of authorized IPs */ <br>

  <br>

int InitAuthIP( )       /* read IP from file ip.auth into memory array */ <br>

{ <br>

        FILE    *fp; <br>

        char    sBuf[64]; <br>

        char    *tmp; <br>

        char    *s; <br>

        u_long  IP; <br>

  <br>

        if ((fp  = fopen("ip.auth","r")) == NULL) { <br>

                return FALSE; <br>

        } <br>

        AuthedIPNum = 0; <br>

        while (AuthedIPNum < MAXHOSTS && !feof(fp) && fgets(sBuf, 64, fp)) { <br>



                tmp = sBuf; <br>

                s = strtok(tmp, " \t\r\n"); <br>

                if (s == NULL) continue;        /* ignore empty line */ <br>

                if (s[0] == '#') continue;      /* ignore commits line */ <br>

                if ((IP = inet_addr(s)) != -1) { <br>

                        AuthedIP[AuthedIPNum ++] = IP; <br>

                } <br>

        } <br>

        if (AuthedIPNum == 0) {                 /* default Authorized IP */ <br>

                AuthedIP[0] = inet_addr("127.0.0.1"); <br>

                AuthedIPNum ++ ; <br>

        } <br>

        fclose(fp); <br>

        return TRUE; <br>

} <br>

  <br>

int IPIsAuthed(u_long IP) <br>

{ <br>

        int     i; <br>

        for (i = 0;i < AuthedIPNum && AuthedIP[i] != IP;i ++); <br>

        if (i == AuthedIPNum) return FALSE; <br>

  <br>



        else return TRUE; <br>

} <br>

  <br>

-- <br>

  <br>

        ****************************************************** <br>

  <br>

               青岛啤酒,可能是世界上最好的啤酒 。。。 。。。 <br>

  <br>

        ****************************************************** <br>

  <br>

</small><hr>
<p align="center">[<a href="index.htm">回到开始</a>][<a href="193.htm">上一层</a>][<a href="287.htm">下一篇</a>]
<p align="center"><a href="http://cterm.163.net">欢迎访问Cterm主页</a></p>
</table>
</body>
</html>

⌨️ 快捷键说明

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