免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
123下一页
最近访问板块 发新帖
查看: 10867 | 回复: 21
打印 上一主题 下一主题

(原创)构建基于Linux下支持ssl的IRC服务器 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-08-27 21:58 |只看该作者 |倒序浏览
有人在网络问题要此类安装文档没找到,我就把我7月份的笔记整理下贴出来给想架设irc的朋友做个参考吧。


一、目的
因为老哥想大家一起关于技术讨论沟通,于是想到使用IRC。IRC是英文“Internet Relay Chat”的缩写,它是一种即时交谈工具,是

目前全球最流行的在线聊天方式之一。它的特点是速度快,方便的自建和使用个人聊天室,同时开20多个小窗与人聊天不影响速度

,强大的聊天室管理、文件传送功能,是全球网友网上交流的最佳选择。所以我们决定使用开源的ircd-hybrid,最新发布的源代码

可以在http://sourceforge.net/ 网站获得。而IRC聊天则需要使用IRC专门的聊天软件在win下自然推荐mIRC,目前汉化版有6.2对

ssl支持的很不错。想mIRC支持SSL只需要下载安装Win32OpenSSL支持库,下载地址为

http://www.shininglightpro.com/d ... SL_Light-0_9_7m.exe

二、安装前的准备
首先,在服务器上推荐选择完全安装方式安装好Linux系统,推荐使用Redhat Linux 8和9以上的操作系统。
其次,获得ircd-hybrid软件包。
以root用户登陆Linux平台服务器,并下载最新的源代码到/home/irc目录
#adduser ircadmin
#cd /home/ircadmin
#wget http://puzzle.dl.sourceforge.net ... cd-hybrid-7.2.3.tgz


三、安装配置的具体步骤
首先要确定系统中是否安装有以下基础包:
gcc libc-dev make openssl ssl-dev本文以irc.test.com域IRC服务器的建立为例,来详细介绍ircd-hybrid系统在Linux服务器上的构建。

PS:安装前要注意一个问题
因为Red Hat Linux 8.0/9.0 的 krb5-devel 套件把 kerberos 的 include file 放到了 /usr/kerberos/include 这里

,而不是一般位置的 /usr/include 这个目录。而 openssl 支援 kerberos,因此在 compile 使用到 openssl 的程序就很容易发

生找不到kerberos 的 include file 的错误。
而解决办法很简单,首先要确定krb5-devel 以及 krb5-libs等包必须安装在系统上,而不是根本没安装,接下来建立以下
symbolic links:
ln -s /usr/kerberos/include/com_err.h /usr/include/
ln -s /usr/kerberos/include/profile.h /usr/include/
ln -s /usr/kerberos/include/krb5.h /usr/include/


装备编译安装ircd-hybrid:
#cd /home/ircadmin/
#tar ircd-hybrid-7.2.3.tgz
#cd ircd-hybrid-7.2.3
#./configure --enable-openssl(为了起用支持ssl)
#make
#make install


以上为解压编译安装,约五分钟后可完成,接下来可根据需要配置ircd.conf文件。我们可以根据源代码压缩包提供的配置文件为实

例,在此文件基础上直接编辑修改,这样就可以省去很大的配置工作。

cp etc/example.conf /usr/local/ircd/etc/ircd.conf


生成证书和key:
#openssl genrsa -out /usr/local/ircd/etc/rsa.key 2048
Generating RSA private key, 2048 bit long modulus
.............................................................................+++
openssl rsa -in /usr/local/ircd/etc/rsa.key -pubout -out /usr/local/ircd/etc/rsa.pub
chmod 0600 /usr/local/ircd/etc/rsa.key
chmod 0644 /usr/local/ircd/etc/rsa.pub


生成ssl数字证书
#openssl req -new -days 365 -x509 -key /usr/local/ircd/etc/rsa.key -out /usr/local/ircd/etc/cert.pem
/usr/local/ircd/etc/cert.pem
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:CN
State or Province Name (full name) [Some-State]:MIS
Locality Name (eg, city) []:BeJing
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Jian
Organizational Unit Name (eg, section) []:irc.test.com
Common Name (eg, YOUR name) []:irc.test.com
Email Address []:jian@test.com

#chown -R ircadmin.ircadmin /usr/local/ircd/


修改配置文件
vi /usr/local/ircd/etc/ircd.conf
我就对配置文件关键设置做下简单说明:
#44行修改如下
serverinfo {
       name = "ircd"; #你服务器名称
       sid = "1ST";    #必须按提示说明设置3个安符,其中第一个必须是数字1-9,后两个必须是字母组合,否则ircd服务不能正常启动。
network_name = "MyNet"; #网络信息
network_desc = "This is My Network"; #网络信息描述
       max_clients = 512;
};
#177行修改为如下:
listen {
       flags = ssl; #设置为ssl加密
     port = 7000;   #服务端口
};
#282行可修改为如下:
auth {
        user = "*@*"; #用户@主机允许连接

        password = "myirc"; #设置了话任何用户登陆irc服务器都需要提前输入此密码,也可以不设置,可为加密和非加密模式

        encrypted = no; #登陆密码是否起用加密模式

        spoof = "I.still.hate.packets"; #用语隐藏用户真实IP地址可以起用作为伪装地址
        class = "opers";  #默认即可
        flags = need_password, spoof_notice, exceed_limit, kline_exempt,
                gline_exempt, resv_exempt, no_tilde, can_flood, can_idle;
};       #默认即可   


#353行可修改为
operator {

        name = "god";  #管理OP(关键)

        user = "*god@*"; #允许任何连接上来带god的名称帐号可切换成管理OP
#        user = "*@127.0.0.1"; #只允许本地连接的管理者

        password = "woshiadmin"; #管理OP的非加密密码

        encrypted = NO; #管理密码是否加密

        class = "opers"; #以下默认即可
        flags = global_kill, remote, kline, unkline, xline,
                die, rehash, nick_changes, admin, operwall;
};
#1133行必须修改
        /* REMOVE ME.  The following line checks you've been reading. */
        havent_read_conf = 1; #必须注销掉此行。否则不让你运行



以上为简略常用功能设置,详细设置可以根据/home/ircadmin/ircd-hybrid-7.2.3/etc/example.conf文档各项说明具体详细设置,这里不一一说明,以上配置可保证IRC服务器ssl版正常运行。
到这里,ircd-hybrid系统的IRC服务器安装设置已经完成,就可以运行启动ircd服务了。

su - ircadmin
$/usr/local/ircd/bin/ircd
ircd: version hybrid-ru-7.2.3
ircd: pid 1513
ircd: running in background mode from /usr/local/ircd


其中ircd服务不能以root权限运行,必须切换非root用户状态,以上我们是创建了一个ircadmin的系统用户。运行正常后,可以通过ps -er|grep ircd 来查看服务进程。
1513 ?        00:00:00 ircd
这样,服务器就正常启动了ircd服务,开放7000加密端口,成功构建起一台IRC加密版服务器,提供一个交流平台。普通用户登陆IRC服务器,加入频道后就可以与朋友聊天交流,传送文件等。频道管理员可以实施简单管理功能。同时管理员也可通过mIRC等客户端软件登陆所构建的IRC服务器,获得更为强大的管理功能,具体使用方法不在这里赘述,大家可以参考相关文献。

三、结束语
本文详细了Linux平台下ircd-hybrid支持SSL加密通讯,提供了一个较完整与清晰的构建流程。(痛苦通宵两个晚上搞定)

PS:版权所有,转载、刊登、摘录请注明出处

[ 本帖最后由 剑次狼 于 2008-8-28 10:49 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2008-08-27 22:09 |只看该作者
没人顶。。。。。。。。。。。。。。。

论坛徽章:
0
3 [报告]
发表于 2008-08-27 22:41 |只看该作者
好像国内没人关注IRC服务

论坛徽章:
0
4 [报告]
发表于 2008-08-28 09:34 |只看该作者

回复 #1 剑次狼 的帖子

我的目录是/usr/include  所以我没有建你上述的symbolic links
而直接 ./configure --enable-openssl
然后make 出问题了  :
In file included from /usr/include/sys/stat.h:105,
                 from ../include/stdinc.h:123,
                 from ircd_lexer.l:31:
/usr/include/bits/stat.h:103: 错误:expected identifier or ‘(’ before ‘[’ token
make[1]: *** [lex.yy.o] 错误 1
make[1]: Leaving directory `/home/irc/ircd-hybrid-7.2.3/src'
make: *** [build] 错误 2

论坛徽章:
0
5 [报告]
发表于 2008-08-28 10:02 |只看该作者

回复 #1 剑次狼 的帖子

我这台是普通的机子  不是服务器
想做一个IRC聊天的服务器
是不是我要作一些什么服务器方面的配置呢?
另外MKAE中还发现
client.c: 在函数 ‘exit_client’ 中:
client.c:1063: 警告:格式 ‘%llu’ 需要类型 ‘long long unsigned int’,但实参 5 的类型为 ‘uint64_t’
client.c:1063: 警告:格式 ‘%llu’ 需要类型 ‘long long unsigned int’,但实参 6 的类型为 ‘uint64_t’

[ 本帖最后由 yffl1987 于 2008-8-28 10:20 编辑 ]

论坛徽章:
0
6 [报告]
发表于 2008-08-28 10:17 |只看该作者
原帖由 yffl1987 于 2008-8-28 10:02 发表
我这台是普通的机子  不是服务器
想做一个IRC聊天的服务器
是不是我要作一些什么服务器方面的配置呢?

IRC聊天的服务器看你想带多少用户了,好像普通PC就基本满足了。如果说稳定性来说自然是专业服务器好啊,看你肯投资多少了,呵呵

论坛徽章:
0
7 [报告]
发表于 2008-08-28 10:30 |只看该作者

回复 #6 剑次狼 的帖子

我带的人不多 就是我上面出现的错误是怎么回事呢?

论坛徽章:
0
8 [报告]
发表于 2008-08-28 10:37 |只看该作者
原帖由 yffl1987 于 2008-8-28 09:34 发表
我的目录是/usr/include  所以我没有建你上述的symbolic links
而直接 ./configure --enable-openssl
然后make 出问题了  :
In file included from /usr/include/sys/stat.h:105,
                 from . ...

错误信息再贴完整点吧
你确定你的基础包都安装了吗?gcc libc6-dev make openssl libssl-dev

论坛徽章:
0
9 [报告]
发表于 2008-08-28 10:47 |只看该作者

回复 #8 剑次狼 的帖子

Compiling ircd-hybrid 7.2.2

Installing into: /usr/local/ircd
Ziplinks ................ yes
OpenSSL ................. yes - BF/168 BF/128 CAST/128 3DES/168 DES/56
Modules ................. shared
IPv6 support ............ yes
Net I/O implementation .. epoll
EFnet server ............ no (use example.conf)
Halfops support ......... no
Small network ........... no
G-Line voting ........... yes

Configured limits:
NICKLEN ................. 9
TOPICLEN ................ 160

#make
...
...
.......

gcc -I../include -I../lib/pcre   -Wall -O2 -g -c balloc.c
gcc -I../include -I../lib/pcre   -Wall -O2 -g -c channel.c
gcc -I../include -I../lib/pcre   -Wall -O2 -g -c channel_mode.c
gcc -I../include -I../lib/pcre   -Wall -O2 -g -c client.c
client.c: 在函数 ‘exit_client’ 中:
client.c:1063: 警告:格式 ‘%llu’ 需要类型 ‘long long unsigned int’,但实参 5 的类型为 ‘uint64_t’
client.c:1063: 警告:格式 ‘%llu’ 需要类型 ‘long long unsigned int’,但实参 6 的类型为 ‘uint64_t’
gcc -I../include -I../lib/pcre   -Wall -O2 -g -c csvlib.c
gcc -I../include -I../lib/pcre   -Wall -O2 -g -c dbuf.c
gcc -I../include -I../lib/pcre   -Wall -O2 -g -c dynlink.c
gcc -I../include -I../lib/pcre   -Wall -O2 -g -c event.c
gcc -I../include -I../lib/pcre   -Wall -O2 -g -c fdlist.c
gcc -I../include -I../lib/pcre   -Wall -O2 -g -c fileio.c
gcc -I../include -I../lib/pcre   -Wall -O2 -g -c getopt.c
gcc -I../include -I../lib/pcre   -Wall -O2 -g -c hash.c
gcc -I../include -I../lib/pcre   -Wall -O2 -g -c hook.c
gcc -I../include -I../lib/pcre   -Wall -O2 -g -c hostmask.c
gcc -I../include -I../lib/pcre   -Wall -O2 -g -c irc_getaddrinfo.c
gcc -I../include -I../lib/pcre   -Wall -O2 -g -c irc_getnameinfo.c
gcc -I../include -I../lib/pcre   -Wall -O2 -g -c irc_res.c
gcc -I../include -I../lib/pcre   -Wall -O2 -g -c irc_reslib.c
gcc -I../include -I../lib/pcre   -Wall -O2 -g -c irc_string.c
gcc -I../include -I../lib/pcre   -Wall -O2 -g -c ircd.c
gcc -I../include -I../lib/pcre   -Wall -O2 -g -c ircd_signal.c
gcc -I../include -I../lib/pcre   -Wall -O2 -g -I. -c lex.yy.c
In file included from /usr/include/sys/stat.h:105,
                 from ../include/stdinc.h:123,
                 from ircd_lexer.l:31:
/usr/include/bits/stat.h:103: 错误:expected identifier or ‘(’ before ‘[’ token
make[1]: *** [lex.yy.o] 错误 1
make[1]: Leaving directory `/home/ircadmin/ircd-hybrid-7.2.3/src'
make: *** [build] 错误 2

论坛徽章:
0
10 [报告]
发表于 2008-08-28 10:51 |只看该作者

回复 #8 剑次狼 的帖子

那两个包果然没装  
出了那两个还有其他的要装吗?
我一并给它装了再试试
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP