Chinaunix

标题: (原创)构建基于Linux下支持ssl的IRC服务器 [打印本页]

作者: 剑次狼    时间: 2008-08-27 21:58
标题: (原创)构建基于Linux下支持ssl的IRC服务器
有人在网络问题要此类安装文档没找到,我就把我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 编辑 ]
作者: 飞哥2005    时间: 2008-08-27 22:09
没人顶。。。。。。。。。。。。。。。
作者: 剑次狼    时间: 2008-08-27 22:41
好像国内没人关注IRC服务
作者: yffl1987    时间: 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
作者: yffl1987    时间: 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 编辑 ]
作者: 剑次狼    时间: 2008-08-28 10:17
原帖由 yffl1987 于 2008-8-28 10:02 发表
我这台是普通的机子  不是服务器
想做一个IRC聊天的服务器
是不是我要作一些什么服务器方面的配置呢?

IRC聊天的服务器看你想带多少用户了,好像普通PC就基本满足了。如果说稳定性来说自然是专业服务器好啊,看你肯投资多少了,呵呵
作者: yffl1987    时间: 2008-08-28 10:30
标题: 回复 #6 剑次狼 的帖子
我带的人不多 就是我上面出现的错误是怎么回事呢?
作者: 剑次狼    时间: 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
作者: yffl1987    时间: 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
作者: yffl1987    时间: 2008-08-28 10:51
标题: 回复 #8 剑次狼 的帖子
那两个包果然没装  
出了那两个还有其他的要装吗?
我一并给它装了再试试
作者: 剑次狼    时间: 2008-08-28 10:58
原帖由 yffl1987 于 2008-8-28 10:51 发表
那两个包果然没装  
出了那两个还有其他的要装吗?
我一并给它装了再试试

你装了再试试,我感觉是少包
你./configure 时候EFnet server 和Halfops support 提示为NO。
作者: yffl1987    时间: 2008-08-28 11:59
标题: 回复 #11 剑次狼 的帖子
它们分别是属于哪个rpm包呢?
我这个还没找到
能帮我找找吗?
作者: 剑次狼    时间: 2008-08-28 13:38
我的汗。我说的是
EFnet server ............ no (use example.conf)
Halfops support ......... no
这两个自检条件不满足。
不是安装包!
你先检查下你的基础包安装没?你的操作系统是什么?
gcc
libc6-dev
make
openssl
libssl-dev

要不带ssl选项直接configure看看结果如何

In file included from /usr/include/sys/stat.h:105,这个错误我没找到相关信息,你看看/usr/include/sys/stat.h起的代码是什么?
作者: yffl1987    时间: 2008-08-28 14:07
标题: 回复 #13 剑次狼 的帖子
我的系统是centos5  
libc6-dev这个我没找到 网上也没找到合适的安装包
from /usr/include/sys/stat.h:105 这个我把文件那几行复制下来你看看
# ifndef __blksize_t_defined
typedef __blksize_t blksize_t;
#  define __blksize_t_defined
# endif
#endif  /* Unix98 */

__BEGIN_DECLS

#include <bits/stat.h>                                       (第105行)

#if defined __USE_BSD || defined __USE_MISC || defined __USE_XOPEN
# define S_IFMT         __S_IFMT
# define S_IFDIR        __S_IFDIR
# define S_IFCHR        __S_IFCHR
# define S_IFBLK        __S_IFBLK
# define S_IFREG        __S_IFREG
# ifdef __S_IFIFO
#  define S_IFIFO       __S_IFIFO
# endif
作者: yffl1987    时间: 2008-08-28 14:11
原帖由 剑次狼 于 2008-8-28 13:38 发表
我的汗。我说的是
EFnet server ............ no (use example.conf)
Halfops support ......... no
这两个自检条件不满足。
不是安装包!
你先检查下你的基础包安装没?你的操作系统是什么?
gcc
libc6 ...



openssl-0.9.8b-8.3.el5
make-3.81-1.1
gcc-4.1.1-52.el5
其他2个没找到
作者: yffl1987    时间: 2008-08-28 15:07
标题: 回复 #13 剑次狼 的帖子
不带ssl选项直接configure  错误是一样的
作者: 剑次狼    时间: 2008-08-29 00:10
原帖由 yffl1987 于 2008-8-28 14:11 发表



openssl-0.9.8b-8.3.el5
make-3.81-1.1
gcc-4.1.1-52.el5
其他2个没找到


我用的ubuntu和reahat的,所以包名不一样。
估计应该是这两个包
glibc-devel-2.3.4
openssl-devel-0.9.8b

你再用命令检查下rpm -qf /usr/include/sys/stat.h
glibc-headers-2.4-4
看看你的头文件glibc-headers是不是有问题?

你的centos5默认安装还是完全安装?
作者: platinum    时间: 2008-08-29 07:18
你用我的包直接 make install 试试

ircd-hybrid-7.2.3.tar.bz2

3.42 MB, 下载次数: 44


作者: yffl1987    时间: 2008-08-29 08:26
标题: 回复 #18 platinum 的帖子
我用ircu配了一个简单的  每次要重建channnel
是不是可以弄一个固定的channel
每次登上服务器就能直接连接  这样办公室里用起来方便
作者: yffl1987    时间: 2008-08-29 10:15
上面的问题已经解决了
我现在想能不能实现像QQ那样的功能
来了消息会有提示呢?
而且这个好像也不能加好友吧
我的XChat2.6.6是英文版的  有些设置都不会
谁能指点一下我吗?
作者: 水田青蛙    时间: 2011-01-27 11:41
这个东西必须顶 !
呵呵 ~
作者: nagaregawa    时间: 2011-01-31 13:16
回复 3# 剑次狼


    我们公司就天天用 irc




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2